erofs-utils: tests: fix build warning in test_LZ4_compress_HC_destSize
PATCH 2/2 erofs-utils: tests: fix build warning in test_LZ4_compress_HC_destSize
From: Yue Hu <[email protected]>
badlz4.c:72:58: warning: format ‘%d’ expects argument of type ‘int’, but argument 4 has type ‘long unsigned int’ [-Wformat=]
printf("test LZ4_compress_HC_destSize(%d) error (%d < %d)\n",
~^
%ld--- tests/src/badlz4.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
tests/src/badlz4.c +4 -3
@@ -60,17 +60,18 @@ int test_LZ4_compress_HC_destSize(int inlen)char buf[1642496 ];int SrcSize = inlen;char dst[4116 ]; +int DstSize =sizeof (dst);int compressed;void *ctx =LZ4_createStreamHC ();memset (buf,0 , inlen); compressed =LZ4_compress_HC_destSize (ctx, buf, dst, &SrcSize, -sizeof (dst),1 ); + DstSize,1 );LZ4_freeStreamHC (ctx); -if (SrcSize <=sizeof (dst)) { +if (SrcSize <= DstSize) {printf ("test LZ4_compress_HC_destSize(%d) error (%d < %d)\n" , - inlen, SrcSize,sizeof (dst)); + inlen, SrcSize, DstSize);return 1 ; }printf ("test LZ4_compress_HC_destSize(%d) OK\n" , inlen);
Signature · 1 line
2.17.1
Hi Yue,
Quoted 24 lines · Yue Hu
From: Yue Hu <[email protected]>
badlz4.c:72:58: warning: format ‘%d’ expects argument of type ‘int’, but argument 4 has type ‘long unsigned int’ [-Wformat=]
printf("test LZ4_compress_HC_destSize(%d) error (%d < %d)\n", ~^ %ldSigned-off-by Yue Hu <[email protected]>--- tests/src/badlz4.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)tests/src/badlz4.c +1
-0@@ -60,17 +60,18 @@ int test_LZ4_compress_HC_destSize(int inlen)char buf[1642496 ];int SrcSize = inlen;char dst[4116 ]; +int DstSize =sizeof (dst);int compressed;void *ctx =LZ4_createStreamHC ();
tests/src/badlz4.c int test_LZ4_compress_HC_destSize(int inlen) · line 73
Quoted 10 lines
tests/src/badlz4.c +2
-3memset (buf,0 , inlen); compressed =LZ4_compress_HC_destSize (ctx, buf, dst, &SrcSize, -sizeof (dst),1 ); + DstSize,1 );LZ4_freeStreamHC (ctx); -if (SrcSize <=sizeof (dst)) { +if (SrcSize <= DstSize) { printf("test LZ4_compress_HC_destSize(%d) error (%d < %d)\n", - inlen, SrcSize,sizeof (dst));
Could we just use printf(...., (int)sizeof(dst)); instead?
Thanks,
Gao Xiang
Quoted 4 lines
tests/src/badlz4.c +1
-0+ inlen, SrcSize, DstSize);return 1 ; }printf ("test LZ4_compress_HC_destSize(%d) OK\n" , inlen);
Quoted 28 lines · On Fri, 24 Nov 2023 11:46:53 +0800 Gao Xiang <[email protected]>…
Hi Yue,
Quoted 25 lines · Yue Hu
From: Yue Hu <[email protected]>
badlz4.c:72:58: warning: format ‘%d’ expects argument of type ‘int’, but argument 4 has type ‘long unsigned int’ [-Wformat=]
printf("test LZ4_compress_HC_destSize(%d) error (%d < %d)\n", ~^ %ldSigned-off-by Yue Hu <[email protected]>--- tests/src/badlz4.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)tests/src/badlz4.c +1
-0@@ -60,17 +60,18 @@ int test_LZ4_compress_HC_destSize(int inlen)char buf[1642496 ];int SrcSize = inlen;char dst[4116 ]; +int DstSize =sizeof (dst);int compressed;void *ctx =LZ4_createStreamHC ();
Quoted 11 lines
tests/src/badlz4.c int test_LZ4_compress_HC_destSize(int inlen) · line 73
Quoted 9 lines
tests/src/badlz4.c +2
-3memset (buf,0 , inlen); compressed =LZ4_compress_HC_destSize (ctx, buf, dst, &SrcSize, -sizeof (dst),1 ); + DstSize,1 );LZ4_freeStreamHC (ctx); -if (SrcSize <=sizeof (dst)) { +if (SrcSize <= DstSize) { printf("test LZ4_compress_HC_destSize(%d) error (%d < %d)\n", - inlen, SrcSize,sizeof (dst));Could we just use
printf(...., (int)sizeof(dst)); instead?
Then it should be if (SrcSize <= (int)sizeof(dst)) as well?
Quoted 8 lines
Thanks,
Gao XiangQuoted 4 lines
tests/src/badlz4.c +1
-0+ inlen, SrcSize, DstSize);return 1 ; }printf ("test LZ4_compress_HC_destSize(%d) OK\n" , inlen);
Quoted 43 lines · Yue Hu
Quoted 28 lines · On Fri, 24 Nov 2023 11:46:53 +0800 Gao Xiang <[email protected]>…
Hi Yue,
Quoted 25 lines · Yue Hu
From: Yue Hu <[email protected]>
badlz4.c:72:58: warning: format ‘%d’ expects argument of type ‘int’, but argument 4 has type ‘long unsigned int’ [-Wformat=]
printf("test LZ4_compress_HC_destSize(%d) error (%d < %d)\n", ~^ %ldSigned-off-by Yue Hu <[email protected]>--- tests/src/badlz4.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)tests/src/badlz4.c +1
-0@@ -60,17 +60,18 @@ int test_LZ4_compress_HC_destSize(int inlen)char buf[1642496 ];int SrcSize = inlen;char dst[4116 ]; +int DstSize =sizeof (dst);int compressed;void *ctx =LZ4_createStreamHC ();Quoted 11 lines
tests/src/badlz4.c int test_LZ4_compress_HC_destSize(int inlen) · line 73
Quoted 9 lines
tests/src/badlz4.c +2
-3memset (buf,0 , inlen); compressed =LZ4_compress_HC_destSize (ctx, buf, dst, &SrcSize, -sizeof (dst),1 ); + DstSize,1 );LZ4_freeStreamHC (ctx); -if (SrcSize <=sizeof (dst)) { +if (SrcSize <= DstSize) { printf("test LZ4_compress_HC_destSize(%d) error (%d < %d)\n", - inlen, SrcSize,sizeof (dst));Could we just use
printf(...., (int)sizeof(dst)); instead?
Quoted 1 line
Then it should be
if (SrcSize <= (int)sizeof(dst))as well?
Why? SrcSize is always > 0 in practice, and sizeof(dst) is always 4116, I have no idea why it's needed. Unless there is some another warning we need to resolve.
Thanks,
Gao Xiang
Quoted 9 lines
Quoted 9 lines
Thanks,
Gao XiangQuoted 4 lines
tests/src/badlz4.c +1
-0+ inlen, SrcSize, DstSize);return 1 ; }printf ("test LZ4_compress_HC_destSize(%d) OK\n" , inlen);
Quoted 44 lines · On Fri, 24 Nov 2023 12:00:39 +0800 Gao Xiang <[email protected]>…
Quoted 43 lines · Yue Hu
Quoted 39 lines · On Fri, 24 Nov 2023 11:46:53 +0800 Gao Xiang <[email protected]>…
Hi Yue,
Quoted 24 lines · Yue Hu
From: Yue Hu <[email protected]>
badlz4.c:72:58: warning: format ‘%d’ expects argument of type ‘int’, but argument 4 has type ‘long unsigned int’ [-Wformat=]
printf("test LZ4_compress_HC_destSize(%d) error (%d < %d)\n", ~^ %ldSigned-off-by Yue Hu <[email protected]>--- tests/src/badlz4.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)tests/src/badlz4.c +1
-0@@ -60,17 +60,18 @@ int test_LZ4_compress_HC_destSize(int inlen)char buf[1642496 ];int SrcSize = inlen;char dst[4116 ]; +int DstSize =sizeof (dst);int compressed;void *ctx =LZ4_createStreamHC ();tests/src/badlz4.c int test_LZ4_compress_HC_destSize(int inlen) · line 73
Quoted 10 lines
tests/src/badlz4.c +2
-3memset (buf,0 , inlen); compressed =LZ4_compress_HC_destSize (ctx, buf, dst, &SrcSize, -sizeof (dst),1 ); + DstSize,1 );LZ4_freeStreamHC (ctx); -if (SrcSize <=sizeof (dst)) { +if (SrcSize <= DstSize) { printf("test LZ4_compress_HC_destSize(%d) error (%d < %d)\n", - inlen, SrcSize,sizeof (dst));Could we just use
printf(...., (int)sizeof(dst)); instead?
Quoted 5 lines
Quoted 1 line
Then it should be
if (SrcSize <= (int)sizeof(dst))as well?Why? SrcSize is always > 0 in practice, and sizeof(dst) is always 4116, I have no idea why it's needed. Unless there is some another warning we need to resolve.
Okay, let me send v2 later.
Quoted 13 lines
Thanks,
Gao XiangQuoted 9 lines
Quoted 9 lines
Thanks,
Gao XiangQuoted 4 lines
tests/src/badlz4.c +1
-0+ inlen, SrcSize, DstSize);return 1 ; }printf ("test LZ4_compress_HC_destSize(%d) OK\n" , inlen);