On Thu, Dec 11, 2008 at 01:15:05PM -0800, [email protected] wrote:
> Author: cotto
> Date: Thu Dec 11 13:15:04 2008
> New Revision: 33810
>
> Modified:
> trunk/src/packfile/pf_items.c
>
> Log:
> [packfile] fix CID #160, since sizeof (opcode_t) is not likely to be 0
What the heck did Coverity's scanner find objectionable about return s ? s : 1;
?
> size_t
> PF_size_integer(void)
> {
> - const size_t s = sizeof (INTVAL) / sizeof (opcode_t);
> - return s ? s : 1;
> + return sizeof (INTVAL) / sizeof (opcode_t);
> }
Specifically, the ternary is valid and useful if sizeof (opcode_t) is
greater than twice sizeof (INTVAL). Are the types of both fixed in C code
that Coverity's scanner can see, or are they determined by Configure.pl?
If the latter, then I believe that Coverity's scanner is in error here, as it
can't know whether (say) it's dealing with 4/16, or 2/8, which is 0 in C.
Nicholas Clark