MCPcopy Create free account
hub / github.com/F-Stack/f-stack / parse_hex_string

Function parse_hex_string

dpdk/app/test-pmd/cmdline_flow.c:10919–10949  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

10917}
10918
10919static int
10920parse_hex_string(const char *src, uint8_t *dst, uint32_t *size)
10921{
10922 const uint8_t *head = dst;
10923 uint32_t left;
10924
10925 if (*size == 0)
10926 return -1;
10927
10928 left = *size;
10929
10930 /* Convert chars to bytes */
10931 while (left) {
10932 char tmp[3], *end = tmp;
10933 uint32_t read_lim = left & 1 ? 1 : 2;
10934
10935 snprintf(tmp, read_lim + 1, "%s", src);
10936 *dst = strtoul(tmp, &end, 16);
10937 if (*end) {
10938 *dst = 0;
10939 *size = (uint32_t)(dst - head);
10940 return -1;
10941 }
10942 left -= read_lim;
10943 src += read_lim;
10944 dst++;
10945 }
10946 *dst = 0;
10947 *size = (uint32_t)(dst - head);
10948 return 0;
10949}
10950
10951static int
10952parse_hex(struct context *ctx, const struct token *token,

Callers 1

parse_hexFunction · 0.70

Calls 2

snprintfFunction · 0.85
strtoulFunction · 0.85

Tested by

no test coverage detected