<div dir="ltr">My environment:<div>LLVM 3.3 + CLANG 3.3<br><div><br></div><div><br></div><div>Build command:</div><div><div><div>CHECKER="-enable-checker alpha.unix.Stream -enable-checker alpha.unix.SimpleStream -enable-checker alpha.core.SizeofPtr -enable-checker alpha.unix.cstring.BufferOverlap -enable-checker alpha.security.ArrayBoundV2 -enable-checker alpha.unix.PthreadLock"</div>
<div><br></div><div>scan-build-3.3 ${CHECKER} g++ static_analyzer.cpp -pthread</div></div></div></div></div><div class="gmail_extra"><br><br><div class="gmail_quote">2013/10/20 Jean Lee <span dir="ltr"><<a href="mailto:xiaoyur347@gmail.com" target="_blank">xiaoyur347@gmail.com</a>></span><br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div>#include <stdio.h></div><div>void FunctionFread(const char* szFile)</div><div>{</div><div><span style="white-space:pre-wrap"> </span>FILE *fp = fopen(szFile, "rb");</div>
<div><span style="white-space:pre-wrap"> </span>if (fp == NULL)</div>
<div><span style="white-space:pre-wrap"> </span>{</div><div><span style="white-space:pre-wrap"> </span>return;</div><div><span style="white-space:pre-wrap"> </span>}</div><div><span style="white-space:pre-wrap"> </span></div>
<div><span style="white-space:pre-wrap"> </span>int ofs[2], len;</div><div><span style="white-space:pre-wrap"> </span>int nReadNum = fread( ofs, sizeof(int), 2, fp );</div><div><br></div><div><span style="white-space:pre-wrap"> </span>if ( nReadNum != 2 )</div>
<div><span style="white-space:pre-wrap"> </span>{</div><div><span style="white-space:pre-wrap"> </span>fclose(fp);</div><div><span style="white-space:pre-wrap"> </span>return;</div><div><span style="white-space:pre-wrap"> </span>}</div>
<div><span style="white-space:pre-wrap"> </span></div><div><span style="white-space:pre-wrap"> // warning: The left operand of '-' is a garbage value</span></div><div><span style="white-space:pre-wrap"> </span>len = ofs[1] - ofs[0];</div>
<div><span style="white-space:pre-wrap"> </span>printf("length=%d\n", len);</div><div><span style="white-space:pre-wrap"> </span>fclose(fp);</div><div>}</div></div>
</blockquote></div><br></div>