Page MenuHomeFreeBSD

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

Authored by zlei on Fri, Dec 6, 5:54 PM.
Tags
None
Referenced Files
Unknown Object (File)
Tue, Dec 10, 3:15 AM
Unknown Object (File)
Tue, Dec 10, 1:14 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.Fri, Dec 6, 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.