Re: [PATCH] include/builddefs.in: ignore unused-result warning

[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]



On Thu, Jan 16, 2025 at 05:55:49PM +0800, Shiyang Ruan wrote:
> 
> 
> 在 2025/1/15 23:33, Zorro Lang 写道:
> > On Mon, Jan 06, 2025 at 05:59:06PM +0800, Shiyang Ruan wrote:
> > > When build xfstests, a lot of "unused result" warning are reported:
> > > 
> > >      [CC] write_log.lo
> > > write_log.c: In function 'wlog_record_write':
> > > write_log.c:205:13: warning: ignoring return value of 'write' declared with attribute 'warn_unused_result' [-Wunused-result]
> > >    205 |             write(wfile->w_afd, wbuf, reclen);
> > >        |             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> > > write_log.c:209:13: warning: ignoring return value of 'write' declared with attribute 'warn_unused_result' [-Wunused-result]
> > >    209 |             write(wfile->w_rfd, wbuf, reclen);
> > >        |             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> > >      [CC] random.lo
> > 
> > Hi,
> > 
> > I never hit this build warning:
> > 
> > # make
> > ...
> > Building lib
> >      [LTDEP]
> >      [CC] write_log.lo
> >      [LD]
> > Building ltp
> >      [CC]    doio
> >      [CC]    fsstress
> > ...
> > 
> > Besides that ...
> 
> Could you share me the info of your build environment?  Such as OS, kernel,
> gcc version.  I'd like to find out what wrong with mine.

Do you use gcc-15?

> 
> 
> --
> Thanks,
> Ruan.
> 
> > 
> > > 
> > > Mostly are calused by not using the return value of read()/write()/...
> > > Ignore this warning by adding `-Wno-unused-result` to CCFLAGS.  This
> > > won't cause other problem but make the log clean.
> > > 
> > > Signed-off-by: Shiyang Ruan <ruansy.fnst@xxxxxxxxxxx>
> > > ---
> > >   include/builddefs.in | 2 +-
> > >   1 file changed, 1 insertion(+), 1 deletion(-)
> > > 
> > > diff --git a/include/builddefs.in b/include/builddefs.in
> > > index 7274cde8d..edf87ff00 100644
> > > --- a/include/builddefs.in
> > > +++ b/include/builddefs.in
> > > @@ -75,7 +75,7 @@ HAVE_RLIMIT_NOFILE = @have_rlimit_nofile@
> > >   NEED_INTERNAL_XFS_IOC_EXCHANGE_RANGE = @need_internal_xfs_ioc_exchange_range@
> > >   HAVE_FICLONE = @have_ficlone@
> > > -GCCFLAGS = -funsigned-char -fno-strict-aliasing -Wall
> > > +GCCFLAGS = -funsigned-char -fno-strict-aliasing -Wall -Wno-unused-result
> > 
> > I'm not an expert of gcc. From the manual of gcc, it says:
> > 
> >         -Wno-unused-result
> >             Do not warn if a caller of a function marked with attribute "warn_unused_result" does not use its return value. The default is -Wunused-result.
> > 
> > Looks like the "-Wno-unused-result" works for "a function marked with
> > attribute warn_unused_result", e.g.
> > 
> >      int __attribute__((warn_unused_result)) foo(void)
> > 
> > I think fstests doesn't use that attribute.
> > 
> > Thanks,
> > Zorro
> > 
> > 
> > >   ifeq ($(PKG_PLATFORM),linux)
> > >   PCFLAGS = -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 $(GCCFLAGS)
> > > -- 
> > > 2.43.0
> > > 
> > > 
> > 
> 





[Index of Archives]     [Linux Filesystems Development]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux