[LLVMbugs] [Bug 11186] New: Check for incorrect use of out-error

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Wed Oct 19 18:39:41 PDT 2011


           Summary: Check for incorrect use of out-error
           Product: clang
           Version: 2.8
          Platform: PC
        OS/Version: All
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: Static Analyzer
        AssignedTo: kremenek at apple.com
        ReportedBy: tjw at me.com
                CC: llvmbugs at cs.uiuc.edu

NSError usage says that you shouldn't look at what was written into an outError
unless your call to the method/function that filled it returns a value that
results in a false condition check.

That is, if you have

  - (BOOL)foo:(NSError **)outError;

then this should be valid:

   NSError *error;
   if (![self foo:&error]) {
     ... do something with "error"

but this should produce an diagnostic:

  NSError *error;
  [self foo:&error];
  if (error) {

Non-condition return type methods/functions should be considered OK, though.
These are often used as utility functions to fill out NSError objects:

static void _makeError(NSString *domain, NSInteger code, NSError **outError) {
    if (outError) {
        ... make an error ...

Configure bugmail: http://llvm.org/bugs/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.

More information about the llvm-bugs mailing list