diff mbox series

tests/nsm_client: Fix nsm_client compile warnings

Message ID tencent_A858F696592599629C0E743528247B763F07@qq.com (mailing list archive)
State New
Headers show
Series tests/nsm_client: Fix nsm_client compile warnings | expand

Commit Message

597607025@qq.com July 17, 2024, 1:58 a.m. UTC
From: Zhang Yaqi <zhangyaqi@kylinos.cn>

when compiling after make
cd tests/nsm_client
make nsm_client
then it shows:
nsm_client.c: In function ‘hex2bin’:
nsm_client.c:104:24: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for (i = 0; *src && i < dstlen; i++) {
                        ^
nsm_client.c: In function ‘bin2hex’:
nsm_client.c:122:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for (i = 0; i < srclen; i++)

Signed-off-by: Zhang Yaqi <zhangyaqi@kylinos.cn>
---
 tests/nsm_client/nsm_client.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
diff mbox series

Patch

diff --git a/tests/nsm_client/nsm_client.c b/tests/nsm_client/nsm_client.c
index 8dc05917..67b593fa 100644
--- a/tests/nsm_client/nsm_client.c
+++ b/tests/nsm_client/nsm_client.c
@@ -101,7 +101,7 @@  hex2bin(char *dst, size_t dstlen, char *src)
 	int i;
 	unsigned int tmp;
 
-	for (i = 0; *src && i < dstlen; i++) {
+	for (i = 0; *src && (size_t)i < dstlen; i++) {
 		if (sscanf(src, "%2x", &tmp) != 1)
 			return 0;
 		dst[i] = tmp;
@@ -119,7 +119,7 @@  bin2hex(char *dst, char *src, size_t srclen)
 {
 	int i;
 
-	for (i = 0; i < srclen; i++)
+	for (i = 0; (size_t)i < srclen; i++)
 		dst += sprintf(dst, "%02x", 0xff & src[i]);
 }