Page MenuHomeFreeBSD

linuxkpi: Add add_taint stub
ClosedPublic

Authored by manu on Aug 10 2022, 6:50 AM.
Tags
None
Referenced Files
Unknown Object (File)
Wed, Oct 30, 5:11 PM
Unknown Object (File)
Oct 9 2024, 2:08 AM
Unknown Object (File)
Oct 9 2024, 2:08 AM
Unknown Object (File)
Oct 9 2024, 2:08 AM
Unknown Object (File)
Oct 9 2024, 2:08 AM
Unknown Object (File)
Oct 9 2024, 1:38 AM
Unknown Object (File)
Oct 4 2024, 10:56 AM
Unknown Object (File)
Oct 3 2024, 10:19 AM

Details

Summary

Needed by drm-kmod.

Sponsored by: Beckhoff Automation GmbH & Co. KG

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

manu requested review of this revision.Aug 10 2022, 6:50 AM
bz added inline comments.
sys/compat/linuxkpi/common/include/linux/kernel.h
685

I would have said do {} while (0).

sys/compat/linuxkpi/common/include/linux/kernel.h
685

You've been suggesting this for a number of reviews, what's the point if you don't mind be asking ?

bz added inline comments.
sys/compat/linuxkpi/common/include/linux/kernel.h
685

I believe most the ones I suggested are void functions, no return value; @hselasky in the past has always suggested to me for LinuxKPI to use do {} while(0) in those cases and that seems general style in FreeBSD.

Here's a quick test putting a (0); into an empty main function and you get a warning ...
I think we simply suppress them in the builds currently:

share/mk/bsd.sys.mk:CWARNFLAGS.clang+=  -Wno-tautological-compare -Wno-unused-value\
share/mk/bsd.sys.mk:            -Wno-error=unused-value
% cc -Wall 0.c -o 0-2
0.c:7:3: warning: expression result unused [-Wunused-value]
        (0);
         ^
1 warning generated.
sys/compat/linuxkpi/common/include/linux/kernel.h
685

Right, do { ... } while(0) is generally good practice so that it behaves similarly to a function with respect to cases like @bz mentions, the trailing ; after the macro behaves as expected, and (in the case of macros with actual bodies) it works properly inside of another block like if ... else ....

I think it's reasonable to just always put void function-like macros in do { } while (0)

Yes, "do { } while (0)" is the right thing here, if there is no return value.

sys/compat/linuxkpi/common/include/linux/kernel.h
685

Thanks for the explanation, I'll update all the reviews to do this :)

This revision is now accepted and ready to land.Aug 16 2022, 1:41 PM
This revision was automatically updated to reflect the committed changes.