Commit 1a24dc8f authored by Blachut, Bartosz's avatar Blachut, Bartosz Committed by Tomasz Zawadzki
Browse files

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: default avatarBlachut, Bartosz <bartosz.blachut@intel.com>
Change-Id: I84f5784b2de7d681f78c69b5f3646e851e8dee88
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/14273


Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Community-CI: Mellanox Build Bot
Reviewed-by: default avatarShuhei Matsumoto <smatsumoto@nvidia.com>
Reviewed-by: default avatarAleksey Marchuk <alexeymar@nvidia.com>
Reviewed-by: default avatarJacek Kalwas <jacek.kalwas@intel.com>
parent 750896ce
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
@@ -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);