[cfe-commits] [PATCH 1/1] Checking zero byte allocation for realloc() and calloc().

Cyril Roelandt tipecaml at gmail.com
Sun Dec 4 14:22:21 PST 2011


On 11/27/2011 07:42 AM, Jordy Rose wrote:
> On Nov 27, 2011, at 13:26, Ted Kremenek wrote:
>
>> Here's what I think we should do.  I think we should put this checking logic into both UnixAPIChecker and MallocChecker.  When MallocChecker is enabled by default, we remove this logic from UnixAPIChecker.  We could possibly enhance UnixAPIChecker to check if the MallocChecker is enabled, and if so, not warn about these cases (avoiding duplicate checking).
>>
>> Cyril/Jordy: what do you think?
>>
>> Cheers,
>> Ted
>
> Sorry for throwing you in the wrong direction, Cyril. I knew there was a reason for the current split between UnixAPIChecker and MallocChecker, but I forgot what it was. And this certainly is a check that can be enabled now safely, and doesn't cost much to check.
>

No problem :)

> I don't like the idea of having duplicated code, or even shared code between MallocChecker and UnixAPIChecker. The two checkers really shouldn't know about each other, and in practical use I think it's rare for people to run the analyzer with MallocChecker enabled and UnixAPIChecker disabled. I guess, even though there's duplicated work /now/, I'd leave it the original way. And maybe eventually we'll have a way to enable or disable certain checks in a checker, right? Then we can move the logic to MallocChecker where it belongs, even if we don't have IPA yet.
>

I agree with you. I don't think it would be a good idea to have the zero 
byte allocation check done in two different places.

Maybe for now, we could use my previous patch, which only added features 
to the UnixAPIChecker, so that checks are performed for calloc() and 
realloc(), and move all these checks to the MallocChecker when it is no 
longer an experimental checker. What do you think ? Ted ?

Cyril.



More information about the cfe-commits mailing list