Re: [RFC PATCH 0/1] compiler_types.h: introduce ASSUME_NONNULL macro for static analysis
Siddh Raman Pant <[email protected]> Fri, 25 Jul 2025 18:58:53 +0530
| Newsgroups | org.kernelnewbies.kernelnewbies |
|---|---|
| Message-ID | <[email protected]> |
--===============4314651233454379020== Content-Type: multipart/alternative; boundary="----=_Part_945185_1404750437.1753450133926" ------=_Part_945185_1404750437.1753450133926 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable ---- Fri, 25 Jul 2025 18:12:14 +0530 =E0=A4=95=E0=A5=8B [email protected]= om =E0=A4=A8=E0=A5=87 =E0=A4=B2=E0=A4=BF=E0=A4=96=E0=A4=BE ---- > - Clarity to readers that the pointer is guaranteed to be non-null, Assumption isn't a guarantee. > and that a check is redundant (because performance critical context, > etc.) Compiler optimises it away usually. > - Future patches that decide to use this macro can be a signal to > reviewers to actually check correctness that a pointer is indeed > invariably non-null That can pretty easily change in future. > - Make static analysis more useful by documenting when a certain false > positive is actually false Is your case really a false positive? There is an explicit check for NULL in some other using the get_node function,=C2=A0most visibly in the macro below. If we know NULL won't be there, we should add an assert in code instead of a silent assumption. Thanks, Siddh ------=_Part_945185_1404750437.1753450133926 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html><head>= <meta content=3D"text/html;charset=3DUTF-8" http-equiv=3D"Content-Type"></h= ead><body ><div dir=3D'auto' style=3D'font-size:10pt;font-family:Verdana,Ar= ial,Helvetica,sans-serif;'><div id=3D"message" dir=3D"auto"><div dir=3D"aut= o" style=3D"font-size:10pt;font-family:Verdana,Arial,Helvetica,sans-serif;"= ><div id=3D"message" dir=3D"auto"><div>---- Fri, 25 Jul 2025 18:12:14 +0530= =E0=A4=95=E0=A5=8B [email protected] =E0=A4=A8=E0=A5=87 =E0=A4=B2=E0= =A4=BF=E0=A4=96=E0=A4=BE ----</div></div><div id=3D"content" dir=3D"auto"><= div><[email protected][mailto:[email protected]]>> - Cla= rity to readers that the pointer is guaranteed to be non-null,</mulyadi.san= [email protected][mailto:[email protected]]></div><div><mulyadi.santos= [email protected][mailto:[email protected]]><br></[email protected]= om[mailto:[email protected]]></div><div>Assumption isn't a guarante= e.</div><div><[email protected][mailto:[email protected]]><= br></[email protected][mailto:[email protected]]></div><div= ><[email protected][mailto:[email protected]]>> and that= a check is redundant (because performance critical context,<br>> etc.)<= /[email protected][mailto:[email protected]]></div><div><mu= [email protected][mailto:[email protected]]><br></mulyadi.san= [email protected][mailto:[email protected]]></div><div><mulyadi.santos= [email protected][mailto:[email protected]]>Compiler optimises it away us= ually.</[email protected][mailto:[email protected]]></div><= div><[email protected][mailto:[email protected]]><br>> -= Future patches that decide to use this macro can be a signal to<br>> re= viewers to actually check correctness that a pointer is indeed<br>> inva= riably non-null</[email protected][mailto:[email protected]= ]></div><div><br></div><div dir=3D"auto">That can pretty easily change in f= uture.</div><div dir=3D"auto"><br></div><div><[email protected][mai= lto:[email protected]]>> - Make static analysis more useful by d= ocumenting when a certain false<br>> positive is actually false</mulyadi= [email protected][mailto:[email protected]]></div><div><br></div><= div>Is your case really a false positive?</div><div dir=3D"auto"><br></div>= <div><[email protected][mailto:[email protected]]>There is = an explicit check for NULL in some other using the</[email protected]= om[mailto:[email protected]]></div><div><[email protected][= mailto:[email protected]]>get_node function, </mulyadi.santosa= @gmail.com[mailto:[email protected]]><span style=3D"font-size: 10pt= ;">most visibly in the macro below.</span></div><div><span style=3D"font-si= ze: 10pt;"><br></span></div><div><span style=3D"font-size: 10pt;">If we kno= w NULL won't be there, we should add an</span></div><div><span style=3D"fon= t-size: 10pt;">assert in code instead of a silent assumption.</span></div><= div><span style=3D"font-size: 10pt;"><br></span></div><div><span style=3D"f= ont-size: 10pt;">Thanks,</span></div><div><span style=3D"font-size: 10pt;">= Siddh</span></div></div></div></div><div id=3D"signature" dir=3D"auto"></di= v><div id=3D"content" dir=3D"auto"></div></div><br></body></html> ------=_Part_945185_1404750437.1753450133926-- --===============4314651233454379020== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Kernelnewbies mailing list [email protected] https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies --===============4314651233454379020==--