hexlify util: v2c helper function return type is signed char
`v2c` helper function returns -1 on error, hovewer its return type was char - which may cause an overflow situation on architectures where char is interpreted as unsigned char, which was reported by the CI. The return type has been changed to signed char. Signed-off-by: Blachut, Bartosz <bartosz.blachut@intel.com> Change-Id: I84f5784b2de7d681f78c69b5f3646e851e8dee88 Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/14273 Tested-by: SPDK CI Jenkins <sys_sgci@intel.com> Community-CI: Mellanox Build Bot Reviewed-by: Shuhei Matsumoto <smatsumoto@nvidia.com> Reviewed-by: Aleksey Marchuk <alexeymar@nvidia.com> Reviewed-by: Jacek Kalwas <jacek.kalwas@intel.com>
This commit is contained in:
parent
750896ce36
commit
1a24dc8fef
@ -93,7 +93,7 @@ __c2v(char c)
|
||||
return -1;
|
||||
}
|
||||
|
||||
static inline char
|
||||
static inline signed char
|
||||
__v2c(int c)
|
||||
{
|
||||
const char hexchar[] = "0123456789abcdef";
|
||||
@ -121,8 +121,8 @@ hexlify(const char *bin, size_t len)
|
||||
}
|
||||
phex = hex;
|
||||
for (size_t i = 0; i < len; i++) {
|
||||
char c0 = __v2c((bin[i] >> 4) & 0x0f);
|
||||
char c1 = __v2c((bin[i]) & 0x0f);
|
||||
signed char c0 = __v2c((bin[i] >> 4) & 0x0f);
|
||||
signed char c1 = __v2c((bin[i]) & 0x0f);
|
||||
if (c0 < 0 || c1 < 0) {
|
||||
assert(false);
|
||||
free(hex);
|
||||
|
Loading…
Reference in New Issue
Block a user