[LLVMbugs] [Bug 18297] New: Warn if comparison result is passed as last argument to memcmp and friends (or when it's passed as size_t more generally?)

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Fri Dec 20 16:25:56 PST 2013


http://llvm.org/bugs/show_bug.cgi?id=18297

            Bug ID: 18297
           Summary: Warn if comparison result is passed as last argument
                    to memcmp and friends (or when it's passed as size_t
                    more generally?)
           Product: clang
           Version: unspecified
          Hardware: PC
                OS: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: Frontend
          Assignee: unassignedclangbugs at nondot.org
          Reporter: nicolasweber at gmx.de
                CC: llvmbugs at cs.uiuc.edu
    Classification: Unclassified

The motivation is to find bugs like
https://codereview.chromium.org/99423002/diff/1/net/third_party/nss/ssl/ssl3con.c
at compile time:

-    memcmp(spki->data, P256_SPKI_PREFIX, sizeof(P256_SPKI_PREFIX) != 0)) {
+    memcmp(spki->data, P256_SPKI_PREFIX, sizeof(P256_SPKI_PREFIX)) != 0) {


rnk suggested: " warn when passing comparison results to functions that expect
sizes (memset et al)?". Give that a try.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20131221/cea51f18/attachment.html>


More information about the llvm-bugs mailing list