[Privoxy-devel] warning: unknown conversion type character 'l' in format
Fabian Keil
fk at fabiankeil.de
Wed Jun 7 11:13:42 UTC 2017
Lee <ler762 at gmail.com> wrote:
> GCC fusses about an %llu format and seems to translate it into %lu
What do you mean by "translate"?
Does the %llu not end up in the binary?
> Other than the compiler warning, I haven't noticed any problems with
> %llu but it would be nice to get rid of another compiler warning
> message.
>
> in parsers.c add another #ifdef _WIN32 section to use %I64u instead of %llu:
>
> static void create_content_length_header(unsigned long long content_length,
> char *header, size_t buffer_length)
> {
> #ifdef _WIN32
> assert(sizeof(unsigned long long) > 4);
> snprintf(header, buffer_length, "Content-Length: %I64u", content_length);
> log_error(LOG_LEVEL_INFO, "create_content_length_header:
> Content-Length: %llu", content_length);
[...]
> ------- with %I64u
> 2017-06-05 14:05:40.360 00000d9c Request: www.installsite.org/
> 2017-06-05 14:05:40.578 00000d9c Info: buffer_and_filter_content set to 1
> 2017-06-05 14:05:40.578 00000d9c Info: create_content_length_header:
> Content-Length: 9855
If there was a problem with the %I64u it would be unlikely to
affect the log message as it doesn't print the "header" string.
Errors are probably also more likely to show up with values
that can't be represented with 32 bit.
> Can anyone think of a reason _not_ to add the
>
> #ifdef _WIN32
> assert(sizeof(unsigned long long) > 4);
> snprintf(header, buffer_length, "Content-Length: %I64u", content_length);
> #else
>
> bit to parsers.c::create_content_length_header ?
I have no objections to the snprint() with the modified
format specifier but one reason not to add the assertion
is that the condition can be checked at compile time.
Probably we should replace the assertion I added in r1.209
with something like:
commit bea35441b9f8e2bf78109544ebc54a17b8373cdd
Author: Fabian Keil <fk at fabiankeil.de>
Date: Wed Jun 7 12:57:44 2017 +0200
get_content_length(): Replace an assertion with a compile-time check
diff --git a/parsers.c b/parsers.c
index 97528dba..011641d7 100644
--- a/parsers.c
+++ b/parsers.c
@@ -1816,7 +1816,9 @@ static jb_err client_keep_alive(struct client_state *csp, char **header)
static jb_err get_content_length(const char *header_value, unsigned long long *length)
{
#ifdef _WIN32
- assert(sizeof(unsigned long long) > 4);
+#if SIZEOF_LONG_LONG < 8
+#error sizeof(unsigned long long) too small
+#endif
if (1 != sscanf(header_value, "%I64u", length))
#else
if (1 != sscanf(header_value, "%llu", length))
instead of adding more of them.
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/20170607/efa8401b/attachment.bin>
More information about the Privoxy-devel
mailing list