Re: NULL safety

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




On 24/11/2023 22:25, Alejandro Colomar wrote:
> Hi Jonny,
> 
> On Sat, Nov 18, 2023 at 11:21:00PM +0000, Jonny Grant wrote:
>> I saw Christopher Bazley was talking about this. As I understand it, _Nonnull is milder than attribute nonnull. _Nonnull probably helps with static analysis, but doesn't optimize out any code checking if(ptr == NULL) return -1;
>>
>> Saw this, did you get traction with your proposal?
>>
>> https://discourse.llvm.org/t/iso-c3x-proposal-nonnull-qualifier/59269?page=2
> 
> I didn't follow up with that.  I'd first like to be able to try Clang's
> static analyzer with _Nullable, to be able to play with it.  An
> _Optional qualifier would only be usable by something like -fanalyzer,
> or Clang's analyzer, since it needs to avoid false positives that are
> quite complex.  It's not a warning that you'd want in -Wall.
> 
> And since Clang's analyzer isn't easy to use, I'm not working on that
> until they make it easier.

Ok I see. GCC's -fanalyzer is useful I find, I've not tried Clang.

I made my own compile_assert() that may/may not be of use for the things you are working on, it works in GCC, its just like regular code. I use to check for things like NULL pointers, or overflows at compile time, rather than runtime like assert().

https://github.com/jonnygrant/compile_assert

There will be some false positives on complex areas of code. It's quite simple, and is just using the tooling we have with GCC to catch things at compile time, that static_assert() can't. Anyway, interested to hear any feedback if you do try it.

Cheers, Jonny





[Index of Archives]     [Kernel Documentation]     [Netdev]     [Linux Ethernet Bridging]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]

  Powered by Linux