[LLVMbugs] [Bug 9288] New: false positive: division by zero

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Tue Feb 22 08:18:18 PST 2011


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

           Summary: false positive: division by zero
           Product: clang
           Version: 2.8
          Platform: PC
        OS/Version: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: Static Analyzer
        AssignedTo: kremenek at apple.com
        ReportedBy: mkbosmans at gmail.com
                CC: llvmbugs at cs.uiuc.edu


In the following code, the division by zero cannot occur, because
pa_cvolume_valid checks for a->channels > 0.

89  pa_volume_t pa_cvolume_avg(const pa_cvolume *a) {
90        uint64_t sum = 0;
91        unsigned c;
92     
93        pa_assert(a);
94        pa_return_val_if_fail(pa_cvolume_valid(a), PA_VOLUME_MUTED);
95     
96        for (c = 0; c < a->channels; c++)
97            sum += a->values[c];
98     
99        sum /= a->channels;
100     
101        return (pa_volume_t) sum;
102    }

Full source code available at:
http://git.0pointer.de/?p=pulseaudio.git;a=blob;f=src/pulse/volume.c;hb=HEAD

-- 
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