Linux-EROFS Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Yue Hu <zbestahu@gmail.com>
To: Gao Xiang <hsiangkao@linux.alibaba.com>
Cc: Yue Hu <huyue2@coolpad.com>, linux-erofs@lists.ozlabs.org
Subject: Re: [PATCH 2/2] erofs-utils: tests: fix build warning in test_LZ4_compress_HC_destSize
Date: Fri, 24 Nov 2023 11:50:59 +0800	[thread overview]
Message-ID: <20231124115059.00006559.zbestahu@gmail.com> (raw)
In-Reply-To: <6b899bdb-23c5-50bf-6ba6-ab9d6261fafe@linux.alibaba.com>

[-- 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);  


  reply	other threads:[~2023-11-24  3:51 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]
2023-11-24  4:00     ` Gao Xiang
2023-11-24  5:02       ` Yue Hu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20231124115059.00006559.zbestahu@gmail.com \
    --to=zbestahu@gmail.com \
    --cc=hsiangkao@linux.alibaba.com \
    --cc=huyue2@coolpad.com \
    --cc=linux-erofs@lists.ozlabs.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox