Skip site navigation (1)Skip section navigation (2)


| 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>&gt; I&#39;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 &lt;<a href=3D"mailto:zlei@freebsd.org">zlei@free=
bsd.org</a>&gt; 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>
&gt; On Sep 19, 2025, at 3:42 AM, Paul Vixie &lt;<a href=3D"mailto:paul@red=
barn.org" target=3D"_blank">paul@redbarn.org</a>&gt; wrote:<br>
&gt; <br>
&gt; On Donderdag 18 September 2025 14:29:36 UTC Zhenlei Huang wrote:<br>
&gt; &gt; &gt; On Sep 18, 2025, at 7:17 PM, Nakayama Kenjiro &lt;<a href=3D=
"mailto:nakayamakenjiro@gmail.com" target=3D"_blank">nakayamakenjiro@gmail.=
com</a>&gt;<br>
&gt; &gt; &gt; ...<br>
&gt; &gt; &gt; freebsd/sys/netinet/in_mcast.c:749:10: error: allocation of =
insufficient<br>
&gt; &gt; &gt; size &#39;40&#39; for type &#39;struct ip_msource&#39; with =
size &#39;48&#39;<br>
&gt; &gt; &gt; ...<br>
&gt; &gt; The following lines has this<br>
&gt; &gt; ```<br>
&gt; &gt; lims =3D (struct in_msource *)nims;<br>
&gt; &gt; ```<br>
&gt; &gt;<br>
&gt; &gt; So probably assign the alloced memory directly to lims would make=
 Clang<br>
&gt; &gt; happy, say ```<br>
&gt; &gt; lims =3D malloc(sizeof( .... ;<br>
&gt; &gt; nims =3D (struct ip_mfilter *)lims;<br>
&gt; &gt; ```<br>
&gt; &gt;<br>
&gt; &gt; You can have a try with that. Good luck with you !<br>
&gt; <br>
&gt; 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&#39;re not using a union{} for this data?<br>
<br>
I&#39;ve no idea why not using a union, probably because it wastes a little=
 memory ? In C world, basically it is the developer&#39;s duty to ensure no=
 out of bounds memory access.<br>
<br>
I&#39;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>
&gt; <br>
&gt; --<br>
&gt; 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 &lt;<a href=3D"mailto:nakayamak=
enjiro@gmail.com" target=3D"_blank">nakayamakenjiro@gmail.com</a>&gt;<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?>