Page MenuHomeFreeBSD

sys/sys/kernel.h: Remove intermediate type casting
Needs ReviewPublic

Authored by zlei on Dec 6 2024, 5:54 PM.
Tags
None
Referenced Files
Unknown Object (File)
Tue, Aug 11, 10:59 PM
Unknown Object (File)
Tue, Aug 11, 10:57 PM
Unknown Object (File)
Tue, Aug 4, 7:50 AM
Unknown Object (File)
Tue, Aug 4, 7:22 AM
Unknown Object (File)
Mon, Aug 3, 6:18 AM
Unknown Object (File)
Jul 21 2026, 4:28 AM
Unknown Object (File)
Jul 20 2026, 6:26 AM
Unknown Object (File)
Jul 18 2026, 8:36 AM
Subscribers
None

Details

Reviewers
imp
mhorne
kib
Summary

The type of sysinit's member udata is const void *, it is perfect valid to do implicit type casting from other pointer types, so no need for the intermediate type casting to void *.

MFC after: 1 week

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Skipped
Unit
Tests Skipped

Event Timeline

zlei requested review of this revision.Dec 6 2024, 5:54 PM
zlei created this revision.

For the udata part, I agree.

For the func, IMO the goal of changes, if any, should be the removal of any casts. Perhaps consumers should explicitly use C_SYSINIT if they need a const arg.

zlei edited the summary of this revision. (Show Details)

Remove only for the udata right now, to move fast.

sys/sys/kernel.h
298

Ah, I see why this casting.

From the comments above,

The casts are necessary to have the compiler produce the correct warnings when -Wcast-qual is used.

Well, this will catch mistake like the following one, the func is type void (*)(char *) but the udata is type const char *. The casting to void * is intentional, so that SYSINIT accept only non-const multiplexer.