<div dir="ltr">Nice!  LGTM.  Looking forward to rolling this out over more code.  :)</div><div class="gmail_extra"><br><br><div class="gmail_quote">On Fri, Dec 20, 2013 at 11:31 PM, Nico Weber <span dir="ltr"><<a href="mailto:thakis@chromium.org" target="_blank">thakis@chromium.org</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Hi,<div><br></div><div>the attached patch adds a new warning that makes memcmp & co warn on misplaced parentheses such as</div>
<div><br></div><div>  if (memcmp(a, b, sizeof(a) != 0))</div><div><br></div>
<div>like so:</div><div><br></div><div><div>test4.cc:5:30: warning: size argument in 'memcmp' call is a comparison [-Wmemsize-comparison]</div><div>  if (memcmp(a, b, sizeof(a) != 0))</div><div>                   ~~~~~~~~~~^~~~</div>

<div>test4.cc:5:7: note: did you mean to compare the result of 'memcmp' instead?</div><div>  if (memcmp(a, b, sizeof(a) != 0))</div><div>      ^                          ~</div><div>                            )</div>

<div>test4.cc:5:20: note: explicitly cast the argument to size_t to silence this warning</div><div>  if (memcmp(a, b, sizeof(a) != 0))</div><div>                   ^</div><div>                   (size_t)(     )</div><div>

1 warning generated.</div></div><div><br></div><div><br></div><div>This would have found one bug in NSS that we recently fixed [1] and found one more bug in chromium we didn't know about before [2]. It had 0 false positives on all of chromium.</div>

<div><br></div><div>The idea of triggering this warning on a binop in the size argument is due to rnk.</div><div><br></div><div>This warning can possibly be extended later on, but I feel this is a good start.</div><div><br>

</div><div>Thoughts?</div><div><br></div><div>Nico</div><div><br></div><div>[1]: <a href="https://codereview.chromium.org/99423002/diff/1/net/third_party/nss/ssl/ssl3con.c" target="_blank">https://codereview.chromium.org/99423002/diff/1/net/third_party/nss/ssl/ssl3con.c</a></div>

<div>[2]: <a href="https://codereview.chromium.org/8431007/#msg12" target="_blank">https://codereview.chromium.org/8431007/#msg12</a></div></div>
<br>_______________________________________________<br>
cfe-commits mailing list<br>
<a href="mailto:cfe-commits@cs.uiuc.edu">cfe-commits@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits</a><br>
<br></blockquote></div><br></div>