Date: Fri, 19 Sep 2025 09:44:28 +0800 From: Zhenlei Huang <zlei@FreeBSD.org> To: Paul Vixie <paul@redbarn.org> Cc: Nakayama Kenjiro <nakayamakenjiro@gmail.com>, freebsd-net@freebsd.org, freebsd-hackers@freebsd.org Subject: Re: Build failure with Clang/LLVM 22 due to alloc-size diagnostic Message-ID: <C796D9EE-0D88-48E3-8F60-7F783BDB581B@FreeBSD.org> In-Reply-To: <4985340.OV4Wx5bFTl@localhost> References: <CAA_ZtA_184k892=5v0OtZsjweWSgSCX%2BWWR6se_aVCJCAh-apQ@mail.gmail.com> <9B7C5718-5F5E-46FB-BB97-0F75FB5CD117@FreeBSD.org> <4985340.OV4Wx5bFTl@localhost>
next in thread | previous in thread | raw e-mail | index | archive | help
> On Sep 19, 2025, at 3:42 AM, Paul Vixie <paul@redbarn.org> wrote: >=20 > On Donderdag 18 September 2025 14:29:36 UTC Zhenlei Huang wrote: > > > On Sep 18, 2025, at 7:17 PM, Nakayama Kenjiro = <nakayamakenjiro@gmail.com> > > > ... > > > freebsd/sys/netinet/in_mcast.c:749:10: error: allocation of = insufficient > > > size '40' for type 'struct ip_msource' with size '48' > > > ... > > The following lines has this > > ``` > > lims =3D (struct in_msource *)nims; > > ``` > > > > So probably assign the alloced memory directly to lims would make = Clang > > happy, say ``` > > lims =3D malloc(sizeof( .... ; > > nims =3D (struct ip_mfilter *)lims; > > ``` > > > > You can have a try with that. Good luck with you ! >=20 > ideally, clang will eventually get around to complaining about that = type cast on the same basis (destination points to a longer object than = the source.) is there a reason we're not using a union{} for this data? I've no idea why not using a union, probably because it wastes a little = memory ? In C world, basically it is the developer's duty to ensure no = out of bounds memory access. I'm not sure how many type casts like this will make Clang unhappy, but = I think the first step would be turning the warning on but not fail the = build, so that it is easy to do statistic and then plan what to do next. >=20 > -- > Paul Vixie Best regards, Zhenlei
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?C796D9EE-0D88-48E3-8F60-7F783BDB581B>