[cfe-dev] static analyzer false positive
Anna Zaks
ganna at apple.com
Thu Jun 27 09:51:16 PDT 2013
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
> 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/1ff1637a/attachment.html>
More information about the cfe-dev
mailing list