[SSSD] [Patch] Added null checks to authtok module

Lukas Slebodnik lslebodn at redhat.com
Mon Nov 18 11:31:23 UTC 2013


On (18/11/13 11:05), Pavel Březina wrote:
>On 11/18/2013 10:49 AM, Lukas Slebodnik wrote:
>>On (16/11/13 09:39), Simo Sorce wrote:
>>>On Sat, 2013-11-16 at 19:16 +0530, Pallavi Jha wrote:
>>>>Hello,
>>>>
>>>>Please find the attachment below. Kindly review.
>>>>
>>>I am not really a fan of these null checks, I prefer the code to crash
>>>in this case because these functions should never be called with an
>>>empty context.
>>>
>>>Simo.
>>>
>>We can make a compromise. extra runtime check will not be added, but we can use
>>__attribute__(nonnull), but only to functions with extern modifier.
>>http://gcc.gnu.org/onlinedocs/gcc/Function-Attributes.html#index-g_t_0040code_007bnonnull_007d-function-attribute-2821
>
>From my tests this will only catch calls where NULL is passed
>directly: my_func(NULL) so it is kinda useless in this code.
Yes, but on the other hand atributte nonnull is additional hint for static
analysers (scan-build). Scan-build report is attached in this mail.
As you can see in the source code, there is warning.

If you try to compile source code there will not be any warning (neither clang
nor gcc). BTW program will not crash, because printf can be safely caled with
null argument.

bash$ ./program
before
>>(null)<<
after

LS
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.fedorahosted.org/pipermail/sssd-devel/attachments/20131118/09e1c340/attachment.html>


More information about the sssd-devel mailing list