Page MenuHomeFreeBSD

netlink: Do not cast to int in NLMSG_HDRLEN and _NLMSG_LEN
Needs ReviewPublic

Authored by arrowd on Tue, Oct 29, 6:45 PM.
Tags
None
Referenced Files
F102123150: D47333.diff
Thu, Nov 7, 9:54 PM
F102099878: D47333.diff
Thu, Nov 7, 2:52 PM
Unknown Object (File)
Sun, Nov 3, 11:16 PM
Unknown Object (File)
Sun, Nov 3, 12:29 PM
Subscribers

Details

Reviewers
glebius
melifaro
jhb
Group Reviewers
Src Committers
Test Plan

make buildkernel passes

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Passed
Unit
No Test Coverage
Build Status
Buildable 60288
Build 57172: arc lint + arc unit

Event Timeline

Some other cleanups to consider as separate commits: Just use the userspace version of NLMSG_ALIGNTO and NLMSG_ALIGN always (so move them above the #ifndef _KERNEL). Also, replace roundup2() with just using __align_up() from <sys/cdefs.h> unconditionally.

I'm also not convinced that NLMSG_HDRLEN isn't in practice the same for both userspace and the kernel.

sys/netlink/netlink.h
213–214

sizeof() already returns a size_t, so you can just remove this cast instead

225

I'm not sure you need this cast either

arrowd marked 2 inline comments as done.

Address comments

arrowd retitled this revision from netlink: Cast to (size_t) instead of (int) in NLMSG_HDRLEN and _NLMSG_LEN to netlink: Do not cast to int in NLMSG_HDRLEN and _NLMSG_LEN.Thu, Oct 31, 4:49 PM

I'm fine with doing all this at once, though you might want to update the log to mention using __align_up and reducing duplication, etc.

sys/netlink/netlink.h
225

You can use tabs to align the macro value now while you are here.

This revision is now accepted and ready to land.Thu, Oct 31, 4:52 PM
In D47333#1080149, @jhb wrote:

I'm fine with doing all this at once, though you might want to update the log to mention using __align_up and reducing duplication, etc.

I did it as three commits, see the "Commits" tab.

arrowd marked an inline comment as done.
  • Align with tabs
This revision now requires review to proceed.Thu, Oct 31, 4:58 PM

Ah, ok. I tend to upload individual commits as a stack. Still LGTM, thanks!

Let’s make sure that the constants /macro still has the same type as in Linux and check that, for example, net/bird2 compiles without additional warnings after this change

net/bird2 compiles without additional warnings after this change

Check that, it builds with no new warnings.