[LLVMbugs] [Bug 14041] New: false positive: The left operand of '>=' is a garbage value

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Sun Oct 7 21:54:12 PDT 2012


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

             Bug #: 14041
           Summary: false positive: The left operand of '>=' is a garbage
                    value
           Product: clang
           Version: 3.1
          Platform: PC
        OS/Version: FreeBSD
            Status: NEW
          Severity: normal
          Priority: P
         Component: Static Analyzer
        AssignedTo: kremenek at apple.com
        ReportedBy: marka at isc.org
                CC: llvmbugs at cs.uiuc.edu
    Classification: Unclassified


Created attachment 9318
  --> http://llvm.org/bugs/attachment.cgi?id=9318
pre-processed false positive example

clang version 3.1 (branches/release_31)
Target: i386-portbld-freebsd8.3
Thread model: posix

isc__buffer_init() initialises 'b' to port to 'namestr'
dns_name_totext() populates 'namestr' (pointed to by b->base).
isc_buffer_putuint8() NUL terminate 'namestr'
str[i] >= 'A' is then flagged with "The left operand of '>=' is a garbage
value"
despite it being populated.

Mark


#include <string.h>

#include <isc/buffer.h>
#include <dns/name.h>
#include <dns/fixedname.h>
#include <dns/result.h>

static void
dns_sdlz_tolower(char *str) {
        unsigned int len = strlen(str);
        unsigned int i;

        for (i = 0; i < len; i++) {
                if (str[i] >= 'A' && str[i] <= 'Z')
                        str[i] += 32;
        }
}

int
main() {
        isc_buffer_t b;
        char namestr[DNS_NAME_MAXTEXT + 1];
        isc_result_t result;
        dns_fixedname_t fixed;
        dns_name_t *name;

        dns_fixedname_init(&fixed);
        name = dns_fixedname_name(&fixed);
        result = dns_name_fromstring(name, "EXAMPLE.NET", 0, NULL);
        if (result != ISC_R_SUCCESS)
                return (1);

        isc_buffer_init(&b, namestr, sizeof(namestr));
        result = dns_name_totext(name, ISC_TRUE, &b);
        if (result != ISC_R_SUCCESS)
                return (1);
        isc_buffer_putuint8(&b, 0);     /* NUL terminate. */

        dns_sdlz_tolower(namestr);
        printf("%s\n", namestr);
        return(0);
}

-- 
Configure bugmail: http://llvm.org/bugs/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.



More information about the llvm-bugs mailing list