[PATCH] D13126: New static analyzer checker for loss of sign/precision

Daniel Marjamäki via cfe-commits cfe-commits at lists.llvm.org
Wed Mar 23 05:29:45 PDT 2016


danielmarjamaki added a comment.

Here are some false positives I have marked... let me know if you want more...

I have marked this as a FP:

URL:  ftp://ftp.se.debian.org/debian/pool/main/m/m17n-lib/m17n-lib_1.7.0.orig.tar.gz
File: m17n-lib-1.7.0/src/mtext.c
Line 1946

Code:

  int mtext_set_char (MText *mt, int pos, int c) {
      ...
      switch (mt->format)
      {
          case MTEXT_FORMAT_US_ASCII:
              mt->data[pos_unit] = c;  // <- WARNING
              break;
        .....
      }
  }

The precision of "c" can be too large for "mt->data[pos_unit]" if the format is not MTEXT_FORMAT_US_ASCII.

I believe it's a FP but it can probably be fixed by an assertion inside the "case".

I have marked this as a FP:

URL:  ftp://ftp.se.debian.org/debian/pool/main/n/netkit-ftp/netkit-ftp_0.17.orig.tar.gz
File: netkit-ftp-0.17/ftp/ftp.c
Line 416

Code:

  		while ((c = getc(cin)) != '\n') {
                  ...
                  if (c == EOF) {
                      ....
                      return 4;
                  }
  
                  ...
                  *cp++ = c;  // <- WARNING
              }

I have marked this as a FP:

URL:  ftp://ftp.se.debian.org/debian/pool/main/o/owl/owl_2.2.2.orig.tar.gz
File: owl-2.2.2.orig/keypress.c
Line: 185

Code:

  if (isascii(j)) {
    kb2[0] = j;  // <- WARNING
    kb2[1] = 0;
    strcat(kb, kb2);    
  }

If isascii() returns 1 then j is a 7-bit value. Then there is not loss of precision.


http://reviews.llvm.org/D13126





More information about the cfe-commits mailing list