On 09/03/2012 10:23 AM, stephane eranian wrote:
> Will,
> 
> I have fixed most of the warnings reported by your tool.
> Please pull and try again.
> 
> 
> On Tue, Aug 28, 2012 at 9:17 PM, William Cohen <wco...@redhat.com> wrote:
>> On 08/28/2012 12:03 PM, stephane eranian wrote:
>>> On Tue, Aug 28, 2012 at 4:45 PM, William Cohen <wco...@redhat.com> wrote:
>>
>>>>
>>>> Would it be possible to do the ldconf separately from the "make install"? 
>>>> The rpm packages are built as normal users with a staged install and the 
>>>> ldconf is done as a post install operation. The ldconf in the makefile 
>>>> needed to be disabled for the libpfm rpm to be built.
>>>>
>>> I just updated the libpfm.spec today to convert ldconfig to a nop
>>> (LDCONFIG=true), so
>>> it should not perturb the generation of the RPM. At least, it did not
>>> for me when I tried
>>> on Fedora 16.
>>>
>>
>> Hi Stephane,
>>
>>
>> Thanks for the libpfm.spec. The fedora rawhide libpfm-4.3.0 doesn't have any 
>> patches in it now:
>>
>>  http://koji.fedoraproject.org/koji/taskinfo?taskID=4432221
>>
>> I ran libpfm through coverity to see whether there were any serious problems 
>> with it.  Attached is the output of coverity. All errors are in the 
>> generated swig code and the examples.  Probably can't do much about the swig 
>> related error because there are all in generated code. The examples could be 
>> cleaned up a little, but those are not packaged in the libpfm rpms, so those 
>> are not a great problem.
>>
>> In perf_setup_list_events()  in perf_util.c why not make the for loop 
>> replace the ',' with '\0' the same structure as the earlier while loop 
>> counting the args?  That would make the code a bit easier to read and 
>> eliminate one of the coverity errors.
>> .
>> -Will

Hi Stephane,

The results are improved.  Most all the ones remaining are in the python swig 
wrappers.  The one that isn't in the swig wrappers is:

Error: NULL_RETURNS (CWE-476):
/builddir/build/BUILD/libpfm-4.3.0/examples/showevtinfo.c:659: example_assign: 
Assigning: "p" = return value from "strchr(arg, 44)".
/builddir/build/BUILD/libpfm-4.3.0/examples/showevtinfo.c:660: example_checked: 
"p" has its value checked in "p".
/builddir/build/BUILD/libpfm-4.3.0/lib/pfmlib_common.c:476: example_assign: 
Assigning: "p" = return value from "strchr(pfm_cfg.forced_pmu, 44)".
/builddir/build/BUILD/libpfm-4.3.0/lib/pfmlib_common.c:477: example_checked: 
"p" has its value checked in "p".
/builddir/build/BUILD/libpfm-4.3.0/lib/pfmlib_common.c:970: example_assign: 
Assigning: "p" = return value from "strchr(s, 44)".
/builddir/build/BUILD/libpfm-4.3.0/lib/pfmlib_common.c:971: example_checked: 
"p" has its value checked in "p".
/builddir/build/BUILD/libpfm-4.3.0/perf_examples/perf_util.c:127: 
example_checked: "strchr(q, 44)" has its value checked in "p = strchr(q, 44)".
/builddir/build/BUILD/libpfm-4.3.0/perf_examples/perf_util.c:141: 
returned_null: Function "strchr" returns null (checked 4 out of 5 times).
/builddir/build/BUILD/libpfm-4.3.0/perf_examples/perf_util.c:141: var_assigned: 
Assigning: "p" = null return value from "strchr".
/builddir/build/BUILD/libpfm-4.3.0/perf_examples/perf_util.c:142: dereference: 
Dereferencing a null pointer "p".


Earlier in the code have:

        q = events;
        while((p = strchr(q, ','))) {
                num++;
                q = p + 1;
        }
        num++;
        num++; /* term

Why not code the following for loop:


        for(i=0, q = events; i < num-2; i++, q = p + 1) {
                p = strchr(q, ',');
                *p = '\0';
                argv[i] = q;
        }
        argv[i++] = q;
        argv[i] = NULL;

to mirror the earlier loop so the strchr value is checked? So make the for loop 
into something like:

        q = events;
        i = 0;
        while((p = strchr(q, ','))) {
                *p = '\0';
                i++;
                q = p + 1;
        }
        argv[i++] = q;
        argv[i] =NULL; /* terminator */

-Will
Error: DEADCODE (CWE-561):
/builddir/build/BUILD/libpfm-4.3.0/python/src/perfmon_int_wrap.c:2394: 
dead_error_condition: On this path, the condition "ty" cannot be false.
/builddir/build/BUILD/libpfm-4.3.0/python/src/perfmon_int_wrap.c:2391: 
cannot_single: After this line (or expression), the value of "ty" cannot be 0.
/builddir/build/BUILD/libpfm-4.3.0/python/src/perfmon_int_wrap.c:2404: 
dead_error_line: Execution cannot reach this statement "*ptr = vptr;".

Error: NULL_RETURNS (CWE-476):
/builddir/build/BUILD/libpfm-4.3.0/examples/showevtinfo.c:659: example_assign: 
Assigning: "p" = return value from "strchr(arg, 44)".
/builddir/build/BUILD/libpfm-4.3.0/examples/showevtinfo.c:660: example_checked: 
"p" has its value checked in "p".
/builddir/build/BUILD/libpfm-4.3.0/lib/pfmlib_common.c:476: example_assign: 
Assigning: "p" = return value from "strchr(pfm_cfg.forced_pmu, 44)".
/builddir/build/BUILD/libpfm-4.3.0/lib/pfmlib_common.c:477: example_checked: 
"p" has its value checked in "p".
/builddir/build/BUILD/libpfm-4.3.0/lib/pfmlib_common.c:970: example_assign: 
Assigning: "p" = return value from "strchr(s, 44)".
/builddir/build/BUILD/libpfm-4.3.0/lib/pfmlib_common.c:971: example_checked: 
"p" has its value checked in "p".
/builddir/build/BUILD/libpfm-4.3.0/perf_examples/perf_util.c:127: 
example_checked: "strchr(q, 44)" has its value checked in "p = strchr(q, 44)".
/builddir/build/BUILD/libpfm-4.3.0/perf_examples/perf_util.c:141: 
returned_null: Function "strchr" returns null (checked 4 out of 5 times).
/builddir/build/BUILD/libpfm-4.3.0/perf_examples/perf_util.c:141: var_assigned: 
Assigning: "p" = null return value from "strchr".
/builddir/build/BUILD/libpfm-4.3.0/perf_examples/perf_util.c:142: dereference: 
Dereferencing a null pointer "p".

Error: RESOURCE_LEAK (CWE-404):
/builddir/build/BUILD/libpfm-4.3.0/python/src/perfmon_int_wrap.c:10327: 
alloc_fn: Calling allocation function "malloc".
/builddir/build/BUILD/libpfm-4.3.0/python/src/perfmon_int_wrap.c:10327: 
var_assign: Assigning: "arg3" =  storage returned from "malloc(80UL)".
/builddir/build/BUILD/libpfm-4.3.0/python/src/perfmon_int_wrap.c:10328: 
noescape: Variable "arg3" is not freed or pointed-to in function "memset".
/builddir/build/BUILD/libpfm-4.3.0/python/src/perfmon_int_wrap.c:10376: 
leaked_storage: Variable "arg3" going out of scope leaks the storage it points 
to.

Error: RESOURCE_LEAK (CWE-404):
/builddir/build/BUILD/libpfm-4.3.0/python/src/perfmon_int_wrap.c:9921: 
alloc_fn: Calling allocation function "malloc".
/builddir/build/BUILD/libpfm-4.3.0/python/src/perfmon_int_wrap.c:9921: 
var_assign: Assigning: "arg2" =  storage returned from "malloc(56UL)".
/builddir/build/BUILD/libpfm-4.3.0/python/src/perfmon_int_wrap.c:9922: 
noescape: Variable "arg2" is not freed or pointed-to in function "memset".
/builddir/build/BUILD/libpfm-4.3.0/python/src/perfmon_int_wrap.c:9930: 
noescape: Variable "arg2" is not freed or pointed-to in function 
"pfm_get_pmu_info".
/builddir/build/BUILD/libpfm-4.3.0/lib/pfmlib_common.c:1553:51: noescape: 
"pfm_get_pmu_info" does not free or save its pointer parameter "uinfo".
/builddir/build/BUILD/libpfm-4.3.0/python/src/perfmon_int_wrap.c:9953: 
leaked_storage: Variable "arg2" going out of scope leaks the storage it points 
to.

Error: RESOURCE_LEAK (CWE-404):
/builddir/build/BUILD/libpfm-4.3.0/python/src/perfmon_int_wrap.c:10018: 
alloc_fn: Calling allocation function "malloc".
/builddir/build/BUILD/libpfm-4.3.0/python/src/perfmon_int_wrap.c:10018: 
var_assign: Assigning: "arg3" =  storage returned from "malloc(64UL)".
/builddir/build/BUILD/libpfm-4.3.0/python/src/perfmon_int_wrap.c:10019: 
noescape: Variable "arg3" is not freed or pointed-to in function "memset".
/builddir/build/BUILD/libpfm-4.3.0/python/src/perfmon_int_wrap.c:10032: 
noescape: Variable "arg3" is not freed or pointed-to in function 
"pfm_get_event_info".
/builddir/build/BUILD/libpfm-4.3.0/lib/pfmlib_common.c:1428:60: noescape: 
"pfm_get_event_info" does not free or save its pointer parameter "uinfo".
/builddir/build/BUILD/libpfm-4.3.0/python/src/perfmon_int_wrap.c:10055: 
leaked_storage: Variable "arg3" going out of scope leaks the storage it points 
to.

Error: RESOURCE_LEAK (CWE-404):
/builddir/build/BUILD/libpfm-4.3.0/python/src/perfmon_int_wrap.c:10137: 
alloc_fn: Calling allocation function "malloc".
/builddir/build/BUILD/libpfm-4.3.0/python/src/perfmon_int_wrap.c:10137: 
var_assign: Assigning: "arg4" =  storage returned from "malloc(64UL)".
/builddir/build/BUILD/libpfm-4.3.0/python/src/perfmon_int_wrap.c:10138: 
noescape: Variable "arg4" is not freed or pointed-to in function "memset".
/builddir/build/BUILD/libpfm-4.3.0/python/src/perfmon_int_wrap.c:10156: 
noescape: Variable "arg4" is not freed or pointed-to in function 
"pfm_get_event_attr_info".
/builddir/build/BUILD/libpfm-4.3.0/lib/pfmlib_common.c:1486:84: noescape: 
"pfm_get_event_attr_info" does not free or save its pointer parameter "uinfo".
/builddir/build/BUILD/libpfm-4.3.0/python/src/perfmon_int_wrap.c:10179: 
leaked_storage: Variable "arg4" going out of scope leaks the storage it points 
to.

Error: UNUSED_VALUE (CWE-563):
/builddir/build/BUILD/libpfm-4.3.0/python/src/perfmon_int_wrap.c:2774: 
returned_pointer: Pointer "tmp" returned by "SWIG_Python_str_AsChar(old_str)" 
is never used.

Error: UNUSED_VALUE (CWE-563):
/builddir/build/BUILD/libpfm-4.3.0/python/src/perfmon_int_wrap.c:2776: 
returned_pointer: Pointer "tmp" returned by "SWIG_Python_str_AsChar(old_str)" 
is never used.

Error: UNUSED_VALUE (CWE-563):
/builddir/build/BUILD/libpfm-4.3.0/python/src/perfmon_int_wrap.c:11131: 
returned_pointer: Pointer "tmp" returned by "SWIG_Python_str_AsChar(str)" is 
never used.

Error: UNUSED_VALUE (CWE-563):
/builddir/build/BUILD/libpfm-4.3.0/python/src/perfmon_int_wrap.c:1005: 
returned_pointer: Pointer "tmp" returned by "SWIG_Python_str_AsChar(old_str)" 
is never used.
------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
perfmon2-devel mailing list
perfmon2-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/perfmon2-devel

Reply via email to