Page MenuHomeFreeBSD

cache_fplookup: quiet gcc -Wreturn-type
ClosedPublic

Authored by rlibby on Dec 10 2020, 7:24 PM.
Tags
None
Referenced Files
Unknown Object (File)
Thu, Oct 31, 2:29 PM
Unknown Object (File)
Thu, Oct 31, 2:29 PM
Unknown Object (File)
Thu, Oct 31, 2:28 PM
Unknown Object (File)
Thu, Oct 31, 2:10 PM
Unknown Object (File)
Mon, Oct 14, 4:25 PM
Unknown Object (File)
Sep 24 2024, 5:20 PM
Unknown Object (File)
Sep 24 2024, 3:33 AM
Unknown Object (File)
Sep 18 2024, 2:43 AM
Subscribers

Details

Test Plan
env MAKEOBJDIRPREFIX=/usr/obj/gcc6 CROSS_TOOLCHAIN=amd64-gcc make buildkernel
env MAKEOBJDIRPREFIX=/usr/obj/clang make buildkernel

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
Lint Passed
Unit
No Test Coverage
Build Status
Buildable 35322
Build 32253: arc lint + arc unit

Event Timeline

Reporting this is a bug in gcc and adding default label defeats the check from clang which makes sure all enums are handled.

iow this would be a regression

Worst the case the following can be added:

diff --git a/sys/kern/vfs_cache.c b/sys/kern/vfs_cache.c
index 7a9fb0aada6..58c82eecb59 100644
--- a/sys/kern/vfs_cache.c
+++ b/sys/kern/vfs_cache.c
@@ -4603,6 +4603,7 @@ cache_fplookup_impl(struct vnode *dvp, struct cache_fpl *fpl)
                        cache_fpl_cleanup_cnp(cnp);
                return (error);
        }
+       __assert_unreachable();
 }
 
 /*

which i suspect may be enough to take care of it.

however, you are likely going to get many other warns elsewhere and once more, adding default label defeats the compilation time check in clang that cases are handled so I don't htink it's a good idea.

In D27555#615781, @mjg wrote:

Reporting this is a bug in gcc and adding default label defeats the check from clang which makes sure all enums are handled.

iow this would be a regression

I can try reporting it as a bug and seeing what they think. For the purposes of moving forward, how about we leave the case labels alone and move the __assert_unreachable to the last line of the function?

In D27555#615791, @mjg wrote:

which i suspect may be enough to take care of it.

Sorry, comments crossed, will do.

however, you are likely going to get many other warns elsewhere and once more, adding default label defeats the compilation time check in clang that cases are handled so I don't htink it's a good idea.

Actually I only encountered one other, D27553, in getting the tree to build with gcc6 and gcc9.

They know for years now, see https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87950

I like the current cases as they are, I'm not going to oppose just adding __assert_unreachable by the end of the func.

In D27555#615781, @mjg wrote:

Reporting this is a bug in gcc and adding default label defeats the check from clang which makes sure all enums are handled.

iow this would be a regression

I can try reporting it as a bug and seeing what they think. For the purposes of moving forward, how about we leave the case labels alone and move the __assert_unreachable to the last line of the function?

There is a gcc bug report, filed 2 years ago: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87950

mjg feedback: appease gcc but don't break clang's switch case coverage

This revision is now accepted and ready to land.Dec 10 2020, 7:58 PM
This revision was automatically updated to reflect the committed changes.