| raw e-mail | index | archive | help
--=20 Kenjiro NAKAYAMA <nakayamakenjiro@gmail.com> GPG Key fingerprint =3D ED8F 049D E67A 727D 9A44 8E25 F44B E208 C946 5EB9 --000000000000fc740a063f6c4cce Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable <div dir=3D"ltr">Thank you, Zhenlei and Paul<br><br>> I'm not sure h= ow 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.<br><br>It might depend= on the build options, but as far as I can tell, the only code that actuall= y triggers the alloc-size diagnostic is the mcast code I reported.<br>So it= would be great if that code could be fixed. We could verify that Zhenlei&#= 39;s suggestion can avoid the diagnostic, although using a union{} might be= the ideal solution.<br>Would it make sense to open a Bugzilla ticket for t= his?<br><div><br></div></div><br><div class=3D"gmail_quote gmail_quote_cont= ainer"><div dir=3D"ltr" class=3D"gmail_attr">On Fri, Sep 19, 2025 at 10:44= =E2=80=AFAM Zhenlei Huang <<a href=3D"mailto:zlei@freebsd.org">zlei@free= bsd.org</a>> wrote:<br></div><blockquote class=3D"gmail_quote" style=3D"= margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-lef= t:1ex"><br> <br> > On Sep 19, 2025, at 3:42 AM, Paul Vixie <<a href=3D"mailto:paul@red= barn.org" target=3D"_blank">paul@redbarn.org</a>> wrote:<br> > <br> > On Donderdag 18 September 2025 14:29:36 UTC Zhenlei Huang wrote:<br> > > > On Sep 18, 2025, at 7:17 PM, Nakayama Kenjiro <<a href=3D= "mailto:nakayamakenjiro@gmail.com" target=3D"_blank">nakayamakenjiro@gmail.= com</a>><br> > > > ...<br> > > > freebsd/sys/netinet/in_mcast.c:749:10: error: allocation of = insufficient<br> > > > size '40' for type 'struct ip_msource' with = size '48'<br> > > > ...<br> > > The following lines has this<br> > > ```<br> > > lims =3D (struct in_msource *)nims;<br> > > ```<br> > ><br> > > So probably assign the alloced memory directly to lims would make= Clang<br> > > happy, say ```<br> > > lims =3D malloc(sizeof( .... ;<br> > > nims =3D (struct ip_mfilter *)lims;<br> > > ```<br> > ><br> > > You can have a try with that. Good luck with you !<br> > <br> > ideally, clang will eventually get around to complaining about that ty= pe cast on the same basis (destination points to a longer object than the s= ource.) is there a reason we're not using a union{} for this data?<br> <br> 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.<br> <br> 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 bu= ild, so that it is easy to do statistic and then plan what to do next.<br> <br> > <br> > --<br> > Paul Vixie<br> <br> Best regards,<br> Zhenlei<br> <br> </blockquote></div><div><br clear=3D"all"></div><div><br></div><span class= =3D"gmail_signature_prefix">-- </span><br><div dir=3D"ltr" class=3D"gmail_s= ignature"><div dir=3D"ltr">Kenjiro NAKAYAMA <<a href=3D"mailto:nakayamak= enjiro@gmail.com" target=3D"_blank">nakayamakenjiro@gmail.com</a>><br>GP= G Key fingerprint =3D ED8F 049D E67A 727D 9A44=C2=A0 8E25 F44B E208 C946 5E= B9<br></div></div> --000000000000fc740a063f6c4cce--
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?>