* [PATCH] include/builddefs.in: ignore unused-result warning
@ 2025-01-06 9:59 Shiyang Ruan
2025-01-15 9:15 ` Shiyang Ruan
2025-01-15 15:33 ` Zorro Lang
0 siblings, 2 replies; 8+ messages in thread
From: Shiyang Ruan @ 2025-01-06 9:59 UTC (permalink / raw)
To: fstests; +Cc: ruansy.fnst
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
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@fujitsu.com>
---
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
ifeq ($(PKG_PLATFORM),linux)
PCFLAGS = -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 $(GCCFLAGS)
--
2.43.0
^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH] include/builddefs.in: ignore unused-result warning
2025-01-06 9:59 [PATCH] include/builddefs.in: ignore unused-result warning Shiyang Ruan
@ 2025-01-15 9:15 ` Shiyang Ruan
2025-01-15 15:33 ` Zorro Lang
1 sibling, 0 replies; 8+ messages in thread
From: Shiyang Ruan @ 2025-01-15 9:15 UTC (permalink / raw)
To: fstests, Zorro Lang
ping~
在 2025/1/6 17:59, Shiyang Ruan 写道:
> 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
>
> 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@fujitsu.com>
> ---
> 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
>
> ifeq ($(PKG_PLATFORM),linux)
> PCFLAGS = -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 $(GCCFLAGS)
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] include/builddefs.in: ignore unused-result warning
2025-01-06 9:59 [PATCH] include/builddefs.in: ignore unused-result warning Shiyang Ruan
2025-01-15 9:15 ` Shiyang Ruan
@ 2025-01-15 15:33 ` Zorro Lang
2025-01-15 21:45 ` Darrick J. Wong
2025-01-16 9:55 ` Shiyang Ruan
1 sibling, 2 replies; 8+ messages in thread
From: Zorro Lang @ 2025-01-15 15:33 UTC (permalink / raw)
To: Shiyang Ruan; +Cc: fstests
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 ...
>
> 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@fujitsu.com>
> ---
> 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
>
>
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] include/builddefs.in: ignore unused-result warning
2025-01-15 15:33 ` Zorro Lang
@ 2025-01-15 21:45 ` Darrick J. Wong
2025-01-17 4:11 ` Zorro Lang
2025-01-16 9:55 ` Shiyang Ruan
1 sibling, 1 reply; 8+ messages in thread
From: Darrick J. Wong @ 2025-01-15 21:45 UTC (permalink / raw)
To: Zorro Lang; +Cc: Shiyang Ruan, fstests
On Wed, Jan 15, 2025 at 11:33:27PM +0800, Zorro Lang wrote:
> 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 ...
>
> >
> > 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@fujitsu.com>
> > ---
> > 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.
No, but unistd.h does for write():
extern ssize_t write (int __fd, const void *__buf, size_t __n) __wur
__attr_access ((__read_only__, 2, 3));
where "__wur" is a macro wrapping __attribute__
((__warn_unused_result__)) if available and FORTIFY_SOURCE is nonzero.
But, uh, shouldn't we fix these programs either to fail the test because
some part of its execution failed, or declare that the return value is
irrelevant if that's the case?
--D
> Thanks,
> Zorro
>
>
> >
> > ifeq ($(PKG_PLATFORM),linux)
> > PCFLAGS = -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 $(GCCFLAGS)
> > --
> > 2.43.0
> >
> >
>
>
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] include/builddefs.in: ignore unused-result warning
2025-01-15 15:33 ` Zorro Lang
2025-01-15 21:45 ` Darrick J. Wong
@ 2025-01-16 9:55 ` Shiyang Ruan
2025-01-17 4:01 ` Zorro Lang
1 sibling, 1 reply; 8+ messages in thread
From: Shiyang Ruan @ 2025-01-16 9:55 UTC (permalink / raw)
To: Zorro Lang; +Cc: fstests, Darrick J. Wong
在 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.
--
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@fujitsu.com>
>> ---
>> 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
>>
>>
>
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] include/builddefs.in: ignore unused-result warning
2025-01-16 9:55 ` Shiyang Ruan
@ 2025-01-17 4:01 ` Zorro Lang
2025-01-17 5:55 ` Shiyang Ruan
0 siblings, 1 reply; 8+ messages in thread
From: Zorro Lang @ 2025-01-17 4:01 UTC (permalink / raw)
To: Shiyang Ruan; +Cc: fstests, Darrick J. Wong
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@fujitsu.com>
> > > ---
> > > 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
> > >
> > >
> >
>
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] include/builddefs.in: ignore unused-result warning
2025-01-15 21:45 ` Darrick J. Wong
@ 2025-01-17 4:11 ` Zorro Lang
0 siblings, 0 replies; 8+ messages in thread
From: Zorro Lang @ 2025-01-17 4:11 UTC (permalink / raw)
To: Darrick J. Wong; +Cc: Shiyang Ruan, fstests
On Wed, Jan 15, 2025 at 01:45:47PM -0800, Darrick J. Wong wrote:
> On Wed, Jan 15, 2025 at 11:33:27PM +0800, Zorro Lang wrote:
> > 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 ...
> >
> > >
> > > 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@fujitsu.com>
> > > ---
> > > 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.
>
> No, but unistd.h does for write():
>
> extern ssize_t write (int __fd, const void *__buf, size_t __n) __wur
> __attr_access ((__read_only__, 2, 3));
>
> where "__wur" is a macro wrapping __attribute__
> ((__warn_unused_result__)) if available and FORTIFY_SOURCE is nonzero.
Oh, good to know that :)
>
> But, uh, shouldn't we fix these programs either to fail the test because
> some part of its execution failed, or declare that the return value is
> irrelevant if that's the case?
The warning is not a big deal, /but/ I just found GCC-15 changed lots of
default things, especially use -std=gnu23 by default:
https://gcc.gnu.org/gcc-15/porting_to.html
that causes xfstests can't be built with gcc-15 ... lots of build errors.
It can be "fixed"(skipped) by set -std=gnu17:
-GCCFLAGS = -funsigned-char -fno-strict-aliasing -Wall
+GCCFLAGS = -funsigned-char -fno-strict-aliasing -std=gnu17 -Wall
but I'm not sure if it's a good way. I'm wondering should we port to C23
totally... It needs to changes lots of "old style" C codes.
Thanks,
Zorro
>
> --D
>
> > Thanks,
> > Zorro
> >
> >
> > >
> > > ifeq ($(PKG_PLATFORM),linux)
> > > PCFLAGS = -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 $(GCCFLAGS)
> > > --
> > > 2.43.0
> > >
> > >
> >
> >
>
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] include/builddefs.in: ignore unused-result warning
2025-01-17 4:01 ` Zorro Lang
@ 2025-01-17 5:55 ` Shiyang Ruan
0 siblings, 0 replies; 8+ messages in thread
From: Shiyang Ruan @ 2025-01-17 5:55 UTC (permalink / raw)
To: Zorro Lang; +Cc: fstests, Darrick J. Wong
在 2025/1/17 12:01, Zorro Lang 写道:
> 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?
I'm using gcc v13, installed from Ubuntu 24.04's apt.
$ gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/libexec/gcc/x86_64-linux-gnu/13/lto-wrapper
OFFLOAD_TARGET_NAMES=nvptx-none:amdgcn-amdhsa
OFFLOAD_TARGET_DEFAULT=1
Target: x86_64-linux-gnu
Configured with: ...
Thread model: posix
Supported LTO compression algorithms: zlib zstd
gcc version 13.3.0 (Ubuntu 13.3.0-6ubuntu2~24.04)
--
Thanks,
Ruan.
>
>>
>>
>> --
>> 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@fujitsu.com>
>>>> ---
>>>> 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
>>>>
>>>>
>>>
>>
>
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2025-01-17 5:55 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-01-06 9:59 [PATCH] include/builddefs.in: ignore unused-result warning Shiyang Ruan
2025-01-15 9:15 ` Shiyang Ruan
2025-01-15 15:33 ` Zorro Lang
2025-01-15 21:45 ` Darrick J. Wong
2025-01-17 4:11 ` Zorro Lang
2025-01-16 9:55 ` Shiyang Ruan
2025-01-17 4:01 ` Zorro Lang
2025-01-17 5:55 ` Shiyang Ruan
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox