[cfe-dev] static analyzer false positive
Dennis Cote
DennisC at harding.ca
Thu Jun 27 09:39:58 PDT 2013
Using the latest Clang static analyzer (SVN update yesterday) I got the
following false positive error.
build\DXL\GoAheadWeb\webs.c:2429:3: warning: Value stored to 'now' is
never read
now = sbuf->mtime;
^ ~~~~~~~~~~~
The function in questions is:
/*
* Build an ASCII time string. If sbuf is NULL we use the
current time,
* else we use the last modified time of sbuf;
*/
char_t *websGetDateString(websStatType *sbuf)
{
char_t* cp, *r;
time_t now;
if (sbuf == NULL) {
time(&now);
} else {
now = sbuf->mtime;
}
if ((cp = gctime(&now)) != NULL) {
cp[gstrlen(cp) - 1] = '\0';
r = bstrdup(B_L, cp);
return r;
}
return NULL;
}
The function gctime() in the following if statement condition does read
the value of now. It seems like the analyzer may be assuming the
function is passed the address of the variable now for writing only.
Hopefully this can help someone correct this type of false positive
error report in the future.
--
Dennis Cote
Harding Instruments
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20130627/345fb89e/attachment.html>
More information about the cfe-dev
mailing list