[cfe-dev] static analyzer false positive
Dennis Cote
DennisC at harding.ca
Thu Jun 27 11:13:31 PDT 2013
Hi Anna,
No need for a bug report. While preparing the preprocessed file you
requested I discovered that gctime() was defined as NULL by a macro. No
function was being called, and hence the error report was accurate.
Dennis Cote
From: Anna Zaks [mailto:ganna at apple.com]
Sent: June 27, 2013 10:51 AM
To: Dennis Cote
Cc: cfe-dev at cs.uiuc.edu
Subject: Re: [cfe-dev] static analyzer false positive
Dennis,
Please, file a Bugzilla report
(http://clang-analyzer.llvm.org/filing_bugs.html) and attach a
preprocessed file so that we could reproduce.
Thanks,
Anna.
On Jun 27, 2013, at 9:39 AM, Dennis Cote <DennisC at harding.ca> wrote:
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
_______________________________________________
cfe-dev mailing list
cfe-dev at cs.uiuc.edu <mailto:cfe-dev at cs.uiuc.edu>
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
<http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20130627/9dda7505/attachment.html>
More information about the cfe-dev
mailing list