[cfe-dev] Silencing an analyzer warning

Ted Kremenek kremenek at apple.com
Thu Apr 29 09:21:32 PDT 2010


There is currently no good way to silence warnings using attributes or pragmas, but you should be able to get around the issue with a wrapper function:

  static inline CFTypeRef CFRetainForCurl(CFTypeRef obj) { CFRetain(obj);  return obj; }
  ...
  curl_easy_setopt(handle, CURLOPT_PRIVATE, CFRetainForCurl(result));

This isn't a permanent solution; it's essentially relying on a deficiency in the analyzer when it comes to wrapper functions (and so eventually a leak will be reported for this case as well).  However, the plan is to eventually add pragma support (or something like that) to silence specific analyzer warnings.

On Apr 29, 2010, at 5:08 AM, Joe Ranieri wrote:

> CURL *handle = curl_easy_init();
> RequestInfo *result = [[[RequestInfo alloc] init] autorelease];
> 
> // Keep a pointer to this object around so that curl can give it back to 
> us in callbacks
> curl_easy_setopt(handle, CURLOPT_PRIVATE, CFRetain(result)));
> 
> 
> The static analyzer tells us that result is leaked (which, without it 
> knowing about curl, it does look like). However, it's not actually being 
> leaked and gets cleaned up later when we clean up the CURL handle. Is 
> there any way to silence this analyzer warning? We'd like to get our 
> project analyzer-warning free and require no warnings before committing 
> things.
> 
> -- Joe Ranieri
> _______________________________________________
> cfe-dev mailing list
> cfe-dev at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev





More information about the cfe-dev mailing list