Lines Matching +full:0 +full:- +full:2
4 * SPDX-License-Identifier: Apache-2.0
14 if ((c >= '0') && (c <= '9')) { in char2hex()
15 *x = c - '0'; in char2hex()
17 *x = c - 'a' + 10; in char2hex()
19 *x = c - 'A' + 10; in char2hex()
21 return -EINVAL; in char2hex()
24 return 0; in char2hex()
30 *c = x + (char)'0'; in hex2char()
32 *c = x - 10 + (char)'a'; in hex2char()
34 return -EINVAL; in hex2char()
37 return 0; in hex2char()
42 if (hexlen < ((buflen * 2U) + 1U)) { in bin2hex()
43 return 0; in bin2hex()
46 for (size_t i = 0; i < buflen; i++) { in bin2hex()
47 if (hex2char(buf[i] >> 4, &hex[2U * i]) < 0) { in bin2hex()
48 return 0; in bin2hex()
50 if (hex2char(buf[i] & 0xf, &hex[2U * i + 1U]) < 0) { in bin2hex()
51 return 0; in bin2hex()
55 hex[2U * buflen] = '\0'; in bin2hex()
56 return 2U * buflen; in bin2hex()
63 if (buflen < (hexlen / 2U + hexlen % 2U)) { in hex2bin()
64 return 0; in hex2bin()
68 if ((hexlen % 2U) != 0) { in hex2bin()
69 if (char2hex(hex[0], &dec) < 0) { in hex2bin()
70 return 0; in hex2bin()
72 buf[0] = dec; in hex2bin()
78 for (size_t i = 0; i < (hexlen / 2U); i++) { in hex2bin()
79 if (char2hex(hex[2U * i], &dec) < 0) { in hex2bin()
80 return 0; in hex2bin()
84 if (char2hex(hex[2U * i + 1U], &dec) < 0) { in hex2bin()
85 return 0; in hex2bin()
90 return hexlen / 2U + hexlen % 2U; in hex2bin()