[Privoxy-devel] cppcheck warnings in cgiedit.c

Fabian Keil fk at fabiankeil.de
Fri Jan 4 14:08:12 UTC 2019


Lee <ler762 at gmail.com> wrote:

> cppcheck spits out a bunch of warnings for cgiedit.c:
> 
> [cgiedit.c:3196]: (warning) %lu in format string (no. 1) requires
> 'unsigned long' but the argument type is 'signed long'.
> [cgiedit.c:3317]: (warning) %lu in format string (no. 1) requires
> 'unsigned long' but the argument type is 'signed long'.
> [cgiedit.c:3440]: (warning) %lu in format string (no. 1) requires
> 'unsigned long' but the argument type is 'signed long'.
> [cgiedit.c:3551]: (warning) %lu in format string (no. 1) requires
> 'unsigned long' but the argument type is 'signed long'.
> [cgiedit.c:3673]: (warning) %lu in format string (no. 1) requires
> 'unsigned long' but the argument type is 'signed long'.
> [cgiedit.c:3836]: (warning) %lu in format string (no. 1) requires
> 'unsigned long' but the argument type is 'signed long'.
> [cgiedit.c:4025]: (warning) %lu in format string (no. 1) requires
> 'unsigned long' but the argument type is 'signed long'.
> 
> All the warnings are for '(long) time(NULL)' in snprintf using a '%lu'
> format - eg:
>    snprintf(target, sizeof(target), CGI_PREFIX
> "edit-actions-list?foo=%lu&f=%u#l%u",
>             (long) time(NULL), file->identifier, sectionid);
> 
> If you wanted to get rid of the warnings, would it be better to change
> for format to "%ld" or the type cast to "(unsigned long)"?

I'd prefer a changed cast as the time can't be negative.

Fabian
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 833 bytes
Desc: OpenPGP digital signature
URL: <https://lists.privoxy.org/pipermail/privoxy-devel/attachments/20190104/8c945389/attachment.bin>


More information about the Privoxy-devel mailing list