Oh, one other thing. I do not know who does the committing when the patch is approved. Should I prove a patch that has my commit message in it and username? Would either of you be pushing the change, or would I be pushing it?<br>
<br>Also, thanks for your comments and discussion on this patch, and for keeping with it for so long! I appreciate your feedback and the opportunity to learn some about the static analyzer of clang.<br><br>- Branden<br><br>
<div class="gmail_quote">On Thu, Jan 31, 2013 at 10:10 PM, Branden Archer <span dir="ltr"><<a href="mailto:b.m.archer4@gmail.com" target="_blank">b.m.archer4@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div class="im"><blockquote style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex" class="gmail_quote">Have you double checked that the tests did not generate the warnings before the patch?<br>
</blockquote>
<br></div>When you mentioned this, I had a moment of doubt. I checked for compiler warnings and the 'make test' before I emailed my patches, and all came back clean. Just to be sure I updated my source and compiled again, all still clean. Did you see something in particular, or just wanted to make sure?<div class="im">
<br>
<br><blockquote style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex" class="gmail_quote"><div><div>+void testPassConstPointerIndirectly() {</div><div>+  struct HasPtr hp;</div><div>+  hp.p = fopen("myfile.txt", "w");</div>

<div>+  fputc(0, (FILE *)&hp);</div><div>+  return; // expected-warning {{Opened file is never closed; potential resource leak}}</div><div>+}</div></div><div><br></div><div>Heh. Did you really want this test case? It's not actually valid (&hp is a FILE**, not a FILE*):</div>

</blockquote></div><div><br>I knew the test was not proper code, but it was the only way I could think of to pass a structure to a known library function that was known to not close a file. I replaced it in the attached patches with passing the HasPtr structure to a function that accepts it as a const parameter. I am not sure this still tests the same thing (as I do not fully appreciate how the analyzer knows that a function will not close the stream. I am hoping that if the parameter is passed as a const that it will assume this).<span class="HOEnZb"><font color="#888888"><br>

</font></span></div><span class="HOEnZb"><font color="#888888"><br>- Branden</font></span><div class="HOEnZb"><div class="h5"><br><br><div class="gmail_quote">On Thu, Jan 31, 2013 at 8:26 PM, Jordan Rose <span dir="ltr"><<a href="mailto:jordan_rose@apple.com" target="_blank">jordan_rose@apple.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div style="word-wrap:break-word"><div><br><div><div>On Jan 31, 2013, at 5:21 , Branden Archer <<a href="mailto:b.m.archer4@gmail.com" target="_blank">b.m.archer4@gmail.com</a>> wrote:</div><br><blockquote type="cite">

<blockquote style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex" class="gmail_quote"><div>Basically, you need to pass a pointer which we are tracking to a 
function call indirectly (ex: as a field in a struct..). You should pass
 it to a function which is known not to free memory or close stream. 
Finally, you leak that resource/pointer.</div><div><br></div><div>Previously, we would have a false negative - no leak would be reported. Now, we should be catching the leak.</div></blockquote><br>Ah, got you. See the first attached patch for these added cases.<br>


<br>- Branden<br></blockquote></div><div><br></div></div><div><div>+void testPassConstPointerIndirectly() {</div><div>+  struct HasPtr hp;</div><div>+  hp.p = fopen("myfile.txt", "w");</div><div>+  fputc(0, (FILE *)&hp);</div>

<div>+  return; // expected-warning {{Opened file is never closed; potential resource leak}}</div><div>+}</div></div><div><br></div><div>Heh. Did you really want this test case? It's not actually valid (&hp is a FILE**, not a FILE*):</div>

<div><br></div><div><br></div><div>A few remaining comments for the MallocChecker patch:</div><div><br></div><div><div>+  if (ExplodedNode *N = C.generateSink()) {</div></div><div><br></div><div>Please use an early return here.</div>

<div><br></div><div><br></div><div><div>+    int offsetBytes = Offset.getOffset()/C.getASTContext().getCharWidth();</div></div><div><br></div><div><i>Very</i> nitpicky, but can you put spaces around the /?</div><div><br>
</div>
<div><br></div><div><div>+       << ((abs(offsetBytes) > 1) ? "bytes" : "byte")</div></div><div><br></div><div>Perfect!</div><span><font color="#888888"><div><br></div><div>Jordan</div>
</font></span></div></blockquote></div><br>
</div></div></blockquote></div><br>