Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > gnu.bash.bug > #14560
| From | Christian Weisgerber <naddy@mips.inka.de> |
|---|---|
| Newsgroups | gnu.bash.bug |
| Subject | examples/loadables/finfo.c type problems |
| Date | 2018-09-07 23:28 +0200 |
| Message-ID | <mailman.509.1536355941.1284.bug-bash@gnu.org> (permalink) |
Compiling examples/loadables/finfo.c (bash 4.4.23, 5.0-alpha) on
OpenBSD produces various warnings about ill-matched types:
------------------->
finfo.c:325:20: warning: format specifies type 'long' but the argument has type 'time_t' (aka 'long long') [-Wformat]
printf("%ld\n", st->st_atime);
~~~ ^~~~~~~~~~~~
%lld
finfo.c:330:20: warning: format specifies type 'long' but the argument has type 'time_t' (aka 'long long') [-Wformat]
printf("%ld\n", st->st_mtime);
~~~ ^~~~~~~~~~~~
%lld
finfo.c:335:20: warning: format specifies type 'long' but the argument has type 'time_t' (aka 'long long') [-Wformat]
printf("%ld\n", st->st_ctime);
~~~ ^~~~~~~~~~~~
%lld
finfo.c:339:18: warning: format specifies type 'int' but the argument has type 'ino_t' (aka 'unsigned long long') [-Wformat]
printf("%d\n", st->st_ino);
~~ ^~~~~~~~~~
%llu
finfo.c:341:34: warning: format specifies type 'long' but the argument has type 'ino_t' (aka 'unsigned long long') [-Wformat]
printf("%d:%ld\n", st->st_dev, st->st_ino);
~~~ ^~~~~~~~~~
%llu
5 warnings generated.
<-------------------
I was thinking about how to fix those, but then I noticed existing bad
casts in the code, e.g.,
printf("%ld\n", (long) st->st_size);
which potentially truncate values.
I don't know if the example loadables are considered to be more
than, well, rough examples, so I'm uncertain if this should even
be considered a problem.
--
Christian "naddy" Weisgerber naddy@mips.inka.de
Back to gnu.bash.bug | Previous | Next | Find similar | Unroll thread
examples/loadables/finfo.c type problems Christian Weisgerber <naddy@mips.inka.de> - 2018-09-07 23:28 +0200
csiph-web