[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [patch] Use inttypes macros for size_t format string
[Thread Prev] | [Thread Next]
- Subject: Re: [patch] Use inttypes macros for size_t format string
- From: Andreas Schneider <asn@xxxxxxxxxxxxxx>
- Reply-to: libssh@xxxxxxxxxx
- Date: Wed, 15 Jan 2020 17:25:43 +0100
- To: libssh@xxxxxxxxxx
- Cc: g4-lisz@xxxxxxxxxxxx
On Wednesday, 15 January 2020 16:25:44 CET g4-lisz@xxxxxxxxxxxx wrote: > On 15.01.20 14:35, Jakub Jelen wrote: > > On Wed, 2020-01-15 at 13:01 +0100, g4-lisz@xxxxxxxxxxxx wrote: > >> Hi there, here's a patch for fixing a printf format string issue when > >> compiling with MinGW (and possibly other "architectures"...). > >> > >> A big thanks to Zdenek OGAR Skalak for the hint! > > > > Looks good to me. Grepping through the rest of the code shows that > > there will most probably be more issues like this: > > > > $ git grep "PRIdS" | wc -l > > 10 > > $ git grep "%zu" | wc -l > > 27 > > > > Could you check also the other cases to make sure we can address it in > > the whole codebase? > > Actually, `size_t` is unsigned. So IMHO `PRIuS` should be the format > macro... > > But in priv.h we have only > > #define PRIdS "zd" > > or > > #define PRIdS "Id" > > for WIN32 > > So maybe we should replace this with `PRIuS` and `zu` / `Iu`? > > This would at least solve the situation in dh-gex.c:408 where we have: > > rc = fscanf(moduli, > "%31s %zu %zu %zu %zu %31s %4095s\n", > timestamp, > &type, > &tests, > &tries, > &size, > generator, > modulus); > > and type, tests, tries and size are of size_t. Or we have to change them > to ssize_t, but then also the `best_size` argument of > ssh_retrieve_dhgroup_file() had to be signed. > > What you think? For size_t we should use %zu and for ssize_t %zd which is ANSI C99. See https://en.cppreference.com/w/c/io/fprintf Andreas -- Andreas Schneider asn@xxxxxxxxxxxxxx GPG-ID: 8DFF53E18F2ABC8D8F3C92237EE0FC4DCC014E3D
[patch] Use inttypes macros for size_t format string | g4-lisz@xxxxxxxxxxxx |
Re: [patch] Use inttypes macros for size_t format string | Jakub Jelen <jjelen@xxxxxxxxxx> |
Re: [patch] Use inttypes macros for size_t format string | g4-lisz@xxxxxxxxxxxx |