Damien Lespiau wrote:
> Fix: format '%d' expects type 'int', but argument 2 has type 'long int'
[...]
> @@ -461,7 +461,7 @@ const char *show_instruction(struct instruction *insn)
> }
>
> if (buf >= buffer + sizeof(buffer))
> - die("instruction buffer overflowed %d\n", buf - buffer);
> + die("instruction buffer overflowed %d\n", (int)(buf - buffer));A cast doesn't seem like the right fix. The difference between two pointers has type ptrdiff_t. sizeof(ptrdiff_t) == 8 on 64-bit platforms, leading to the legitimate warning you saw. This cast would truncate the difference to 32 bits. glibc supplies a "t" length modifier for ptrdiff_t, but I don't think sparse can't portably use that. I don't think we can portably use %llu either, even though we use long long. On the other hand, sparse already seems to use %llu. Obviously 32-bit overflow seems unlikely here, but I don't like using a cast to shut GCC up when it has a legitimate complaint; I'd prefer to have the right fix. The ideal fix, so we don't have to worry about printf format-string portability: change this function to cleanly *prevent* instruction buffer overflows rather than detecting them after the fact. :) - Josh Triplett
signature.asc
Description: OpenPGP digital signature
