* [PATCH 2/2] erofs-utils: tests: fix build warning in test_LZ4_compress_HC_destSize
@ 2023-11-24 3:36 Yue Hu
2023-11-24 3:46 ` Gao Xiang
0 siblings, 1 reply; 5+ messages in thread
From: Yue Hu @ 2023-11-24 3:36 UTC (permalink / raw)
To: linux-erofs; +Cc: Yue Hu
From: Yue Hu <huyue2@coolpad.com>
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
Signed-off-by: Yue Hu <huyue2@coolpad.com>
---
tests/src/badlz4.c | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/tests/src/badlz4.c b/tests/src/badlz4.c
index f2f1f05..2a4a908 100644
--- a/tests/src/badlz4.c
+++ b/tests/src/badlz4.c
@@ -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);
--
2.17.1
^ permalink raw reply related [flat|nested] 5+ messages in thread* Re: [PATCH 2/2] erofs-utils: tests: fix build warning in test_LZ4_compress_HC_destSize 2023-11-24 3:36 [PATCH 2/2] erofs-utils: tests: fix build warning in test_LZ4_compress_HC_destSize Yue Hu @ 2023-11-24 3:46 ` Gao Xiang 2023-11-24 3:50 ` Yue Hu 0 siblings, 1 reply; 5+ messages in thread From: Gao Xiang @ 2023-11-24 3:46 UTC (permalink / raw) To: Yue Hu, linux-erofs; +Cc: Yue Hu Hi Yue, On 2023/11/24 11:36, Yue Hu wrote: > From: Yue Hu <huyue2@coolpad.com> > > 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 > > Signed-off-by: Yue Hu <huyue2@coolpad.com> > --- > tests/src/badlz4.c | 7 ++++--- > 1 file changed, 4 insertions(+), 3 deletions(-) > > diff --git a/tests/src/badlz4.c b/tests/src/badlz4.c > index f2f1f05..2a4a908 100644 > --- a/tests/src/badlz4.c > +++ b/tests/src/badlz4.c > @@ -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)); Could we just use printf(...., (int)sizeof(dst)); instead? Thanks, Gao Xiang > + inlen, SrcSize, DstSize); > return 1; > } > printf("test LZ4_compress_HC_destSize(%d) OK\n", inlen); ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH 2/2] erofs-utils: tests: fix build warning in test_LZ4_compress_HC_destSize 2023-11-24 3:46 ` Gao Xiang @ 2023-11-24 3:50 ` Yue Hu 2023-11-24 4:00 ` Gao Xiang 0 siblings, 1 reply; 5+ messages in thread From: Yue Hu @ 2023-11-24 3:50 UTC (permalink / raw) To: Gao Xiang; +Cc: Yue Hu, linux-erofs [-- Warning: decoded text below may be mangled, UTF-8 assumed --] [-- Attachment #1: Type: text/plain; charset=GB18030, Size: 1741 bytes --] On Fri, 24 Nov 2023 11:46:53 +0800 Gao Xiang <hsiangkao@linux.alibaba.com> wrote: > Hi Yue, > > On 2023/11/24 11:36, Yue Hu wrote: > > From: Yue Hu <huyue2@coolpad.com> > > > > 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 > > > > Signed-off-by: Yue Hu <huyue2@coolpad.com> > > --- > > tests/src/badlz4.c | 7 ++++--- > > 1 file changed, 4 insertions(+), 3 deletions(-) > > > > diff --git a/tests/src/badlz4.c b/tests/src/badlz4.c > > index f2f1f05..2a4a908 100644 > > --- a/tests/src/badlz4.c > > +++ b/tests/src/badlz4.c > > @@ -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)); > > Could we just use printf(...., (int)sizeof(dst)); instead? Then it should be `if (SrcSize <= (int)sizeof(dst))` as well? > > Thanks, > Gao Xiang > > > + inlen, SrcSize, DstSize); > > return 1; > > } > > printf("test LZ4_compress_HC_destSize(%d) OK\n", inlen); ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH 2/2] erofs-utils: tests: fix build warning in test_LZ4_compress_HC_destSize 2023-11-24 3:50 ` Yue Hu @ 2023-11-24 4:00 ` Gao Xiang 2023-11-24 5:02 ` Yue Hu 0 siblings, 1 reply; 5+ messages in thread From: Gao Xiang @ 2023-11-24 4:00 UTC (permalink / raw) To: Yue Hu; +Cc: Yue Hu, linux-erofs On 2023/11/24 11:50, Yue Hu wrote: > On Fri, 24 Nov 2023 11:46:53 +0800 > Gao Xiang <hsiangkao@linux.alibaba.com> wrote: > >> Hi Yue, >> >> On 2023/11/24 11:36, Yue Hu wrote: >>> From: Yue Hu <huyue2@coolpad.com> >>> >>> 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 >>> >>> Signed-off-by: Yue Hu <huyue2@coolpad.com> >>> --- >>> tests/src/badlz4.c | 7 ++++--- >>> 1 file changed, 4 insertions(+), 3 deletions(-) >>> >>> diff --git a/tests/src/badlz4.c b/tests/src/badlz4.c >>> index f2f1f05..2a4a908 100644 >>> --- a/tests/src/badlz4.c >>> +++ b/tests/src/badlz4.c >>> @@ -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)); >> >> Could we just use printf(...., (int)sizeof(dst)); instead? > > 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 > >> >> Thanks, >> Gao Xiang >> >>> + inlen, SrcSize, DstSize); >>> return 1; >>> } >>> printf("test LZ4_compress_HC_destSize(%d) OK\n", inlen); ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH 2/2] erofs-utils: tests: fix build warning in test_LZ4_compress_HC_destSize 2023-11-24 4:00 ` Gao Xiang @ 2023-11-24 5:02 ` Yue Hu 0 siblings, 0 replies; 5+ messages in thread From: Yue Hu @ 2023-11-24 5:02 UTC (permalink / raw) To: Gao Xiang; +Cc: Yue Hu, linux-erofs [-- Warning: decoded text below may be mangled, UTF-8 assumed --] [-- Attachment #1: Type: text/plain; charset=GB18030, Size: 2240 bytes --] On Fri, 24 Nov 2023 12:00:39 +0800 Gao Xiang <hsiangkao@linux.alibaba.com> wrote: > On 2023/11/24 11:50, Yue Hu wrote: > > On Fri, 24 Nov 2023 11:46:53 +0800 > > Gao Xiang <hsiangkao@linux.alibaba.com> wrote: > > > >> Hi Yue, > >> > >> On 2023/11/24 11:36, Yue Hu wrote: > >>> From: Yue Hu <huyue2@coolpad.com> > >>> > >>> 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 > >>> > >>> Signed-off-by: Yue Hu <huyue2@coolpad.com> > >>> --- > >>> tests/src/badlz4.c | 7 ++++--- > >>> 1 file changed, 4 insertions(+), 3 deletions(-) > >>> > >>> diff --git a/tests/src/badlz4.c b/tests/src/badlz4.c > >>> index f2f1f05..2a4a908 100644 > >>> --- a/tests/src/badlz4.c > >>> +++ b/tests/src/badlz4.c > >>> @@ -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)); > >> > >> Could we just use printf(...., (int)sizeof(dst)); instead? > > > > 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. > > Thanks, > Gao Xiang > > > > >> > >> Thanks, > >> Gao Xiang > >> > >>> + inlen, SrcSize, DstSize); > >>> return 1; > >>> } > >>> printf("test LZ4_compress_HC_destSize(%d) OK\n", inlen); ^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2023-11-24 5:02 UTC | newest] Thread overview: 5+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2023-11-24 3:36 [PATCH 2/2] erofs-utils: tests: fix build warning in test_LZ4_compress_HC_destSize Yue Hu 2023-11-24 3:46 ` Gao Xiang 2023-11-24 3:50 ` Yue Hu 2023-11-24 4:00 ` Gao Xiang 2023-11-24 5:02 ` Yue Hu
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox