<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40"><head><meta http-equiv=Content-Type content="text/html; charset=us-ascii"><meta name=Generator content="Microsoft Word 14 (filtered medium)"><style><!--
/* Font Definitions */
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0cm;
        margin-bottom:.0001pt;
        font-size:11.0pt;
        font-family:"Calibri","sans-serif";
        mso-fareast-language:EN-US;}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:purple;
        text-decoration:underline;}
span.EmailStyle17
        {mso-style-type:personal-compose;
        font-family:"Calibri","sans-serif";
        color:windowtext;}
.MsoChpDefault
        {mso-style-type:export-only;
        font-family:"Calibri","sans-serif";
        mso-fareast-language:EN-US;}
@page WordSection1
        {size:612.0pt 792.0pt;
        margin:72.0pt 72.0pt 72.0pt 72.0pt;}
div.WordSection1
        {page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]--></head><body lang=EN-CA link=blue vlink=purple><div class=WordSection1><p class=MsoNormal>Using the latest Clang static analyzer (SVN update yesterday) I got the following false positive error.<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>build\DXL\GoAheadWeb\webs.c:2429:3: warning: Value stored to 'now' is never read<o:p></o:p></p><p class=MsoNormal>                now = sbuf->mtime;<o:p></o:p></p><p class=MsoNormal>                ^     ~~~~~~~~~~~<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>The function in questions is:<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>/*<o:p></o:p></p><p class=MsoNormal> *            Build an ASCII time string.  If sbuf is NULL we use the current time,<o:p></o:p></p><p class=MsoNormal> *            else we use the last modified time of sbuf;<o:p></o:p></p><p class=MsoNormal> */<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>char_t *websGetDateString(websStatType *sbuf)<o:p></o:p></p><p class=MsoNormal>{<o:p></o:p></p><p class=MsoNormal>                char_t*                cp, *r;<o:p></o:p></p><p class=MsoNormal>                time_t  now;<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>                if (sbuf == NULL) {<o:p></o:p></p><p class=MsoNormal>                                time(&now);<o:p></o:p></p><p class=MsoNormal>                } else {<o:p></o:p></p><p class=MsoNormal>                                now = sbuf->mtime;<o:p></o:p></p><p class=MsoNormal>                }<o:p></o:p></p><p class=MsoNormal>                if ((cp = gctime(&now)) != NULL) {<o:p></o:p></p><p class=MsoNormal>                                cp[gstrlen(cp) - 1] = '\0';<o:p></o:p></p><p class=MsoNormal>                                r = bstrdup(B_L, cp);<o:p></o:p></p><p class=MsoNormal>                                return r;<o:p></o:p></p><p class=MsoNormal>                }<o:p></o:p></p><p class=MsoNormal>                return NULL;<o:p></o:p></p><p class=MsoNormal>}<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>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.  <o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>Hopefully this can help someone correct this type of false positive error report in the future.<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal><span style='mso-fareast-language:EN-CA'>--<o:p></o:p></span></p><p class=MsoNormal><span style='mso-fareast-language:EN-CA'>Dennis Cote<o:p></o:p></span></p><p class=MsoNormal><span style='mso-fareast-language:EN-CA'>Harding Instruments<o:p></o:p></span></p><p class=MsoNormal><o:p> </o:p></p></div></body></html>