Opened 8 years ago

Closed 8 years ago

Last modified 8 years ago

#640 closed defect (fixed)

Analyze errors from llvm scan-build

Reported by: Alex Samorukov Owned by: Christian Franke
Priority: minor Milestone: Release 6.5
Component: all Version: 6.4
Keywords: Cc:

Description

I tried to run clang scan-build tool and it produced a report. It seems that at least some of the warnings are real.

Change History (5)

comment:1 by Christian Franke, 8 years ago

Owner: set to Christian Franke
Status: newaccepted
Type: taskdefect

comment:2 by Christian Franke, 8 years ago

Resolution: fixed
Status: acceptedclosed

5 of 6 fixed in r4206, r4207, r4208, r4209.

1: cosmetic (r4208)
2: cosmetic (r4207)
3: longstanding crash bug in smartd.conf parser (r4206)
4: harmless bug (r4209)
5: false positive (no workaround for now)
6: harmless bug (r4207)

comment:3 by Alex Samorukov, 8 years ago

btw, as far as i could see from the logic 5 could happens if we have ATA controller w/o any devices on it (n wont increment). So i think something like that should be better:

  • os_freebsd.cpp

     
    15961596        n++;
    15971597      };
    15981598    };
    1599   };
    1600   mp = (char **)reallocf(mp,n*(sizeof (char*))); // shrink to correct size
     1599  };
     1600  if (n != 0) {
     1601    mp = (char **)reallocf(mp,n*(sizeof (char*))); // shrink to correct size
     1602  }
     1603  else {
     1604    goto end;
     1605  }
    16011606  if (mp == NULL && n > 0 ) { // reallocf never fail for size=0, but may return NULL
    16021607    serrno=errno;
    16031608    pout("Out of memory constructing scan device list (on line %d)\n", __LINE__);

comment:4 by Christian Franke, 8 years ago

The n > 0 check and comment following the reallocf() are no longer needed then. Probably better:

  • os_freebsd.cpp

     
    15971597      };
    15981598    };
    15991599  };
     1600  if (n <= 0)
     1601    goto end;
    16001602  mp = (char **)reallocf(mp,n*(sizeof (char*))); // shrink to correct size
    1601   if (mp == NULL && n > 0 ) { // reallocf never fail for size=0, but may return NULL
     1603  if (mp == NULL) {
    16021604    serrno=errno;
    16031605    pout("Out of memory constructing scan device list (on line %d)\n", __LINE__);
    16041606    n = -1;

(blind patch, I don't have a FreeBSD VM available here ...)

comment:5 by Alex Samorukov, 8 years ago

5 fixed in r4211

Note: See TracTickets for help on using tickets.