lsb

suspicious pointer arithmetic in libchk

Bug #1327645 reported by Jeff Johnson
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
lsb
In Progress
Medium
Unassigned
Mandriva
In Progress
Medium

Bug Description

The following is reported by Coverity about misc-test/libchk/classchk.c:

CID 1099432 (#1 of 1): Extra sizeof expression (SIZEOF_MISMATCH)

suspicious_pointer_arithmetic: Adding "vmi_rttip->base_count * 16UL /* sizeof
(struct base_type_info_mem) */" to pointer "(void **)(char
*)vmi_rttip->base_info" of type "void **" is suspicious because adding an
integral value to this pointer automatically scales that value by the size, 8
bytes, of the pointed-to type, "void *". Most likely, the multiplication by
"sizeof (struct base_type_info_mem)" in this expression is extraneous and
should be eliminated.

 977 basetypes = (void **) ((char *) vmi_rttip->base_info) +
 978 (vmi_rttip->base_count * sizeof(struct base_type_info_mem));

I'm not sure it's wrong, but perhaps unnecessarily convoluted given it has
confused the checker. We've cast it to char * to enable the multiply to make
sense, when vmi_rttip->base_info is already type struct base_type_info_mem and
so would scale...

Tags: vip
Changed in mandriva:
importance: Unknown → Medium
status: Unknown → In Progress
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.