[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
examples/loadables/finfo.c type problems
From: |
Christian Weisgerber |
Subject: |
examples/loadables/finfo.c type problems |
Date: |
Fri, 7 Sep 2018 23:28:04 +0200 |
User-agent: |
Mutt/1.10.1 (2018-07-13) |
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
- examples/loadables/finfo.c type problems,
Christian Weisgerber <=