Page MenuHomeFreeBSD

netlink: Do not cast to int in NLMSG_HDRLEN and _NLMSG_LEN
ClosedPublic

Authored by arrowd on Oct 29 2024, 6:45 PM.
Tags
None
Referenced Files
F105203211: D47333.diff
Fri, Dec 13, 12:25 PM
Unknown Object (File)
Tue, Dec 10, 6:39 PM
Unknown Object (File)
Fri, Dec 6, 9:58 AM
Unknown Object (File)
Wed, Dec 4, 7:48 PM
Unknown Object (File)
Tue, Dec 3, 10:30 PM
Unknown Object (File)
Tue, Dec 3, 6:57 PM
Unknown Object (File)
Fri, Nov 22, 11:37 PM
Unknown Object (File)
Fri, Nov 22, 4:36 AM
Subscribers

Diff Detail

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

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

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

226

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.Oct 31 2024, 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
226

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

This revision is now accepted and ready to land.Oct 31 2024, 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.Oct 31 2024, 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

Checked that, it builds with no new warnings.

Apologies for the delay

This revision is now accepted and ready to land.Tue, Dec 10, 5:43 PM