Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > gnu.bash.bug > #14560

examples/loadables/finfo.c type problems

Path csiph.com!goblin1!goblin.stu.neva.ru!usenet.stanford.edu!not-for-mail
From Christian Weisgerber <naddy@mips.inka.de>
Newsgroups gnu.bash.bug
Subject examples/loadables/finfo.c type problems
Date Fri, 7 Sep 2018 23:28:04 +0200
Lines 41
Approved bug-bash@gnu.org
Message-ID <mailman.509.1536355941.1284.bug-bash@gnu.org> (permalink)
NNTP-Posting-Host lists.gnu.org
Mime-Version 1.0
Content-Type text/plain; charset=us-ascii
X-Trace usenet.stanford.edu 1536355941 13762 208.118.235.17 (7 Sep 2018 21:32:21 GMT)
X-Complaints-To action@cs.stanford.edu
To bug-bash@gnu.org
Envelope-to bug-bash@gnu.org
Content-Disposition inline
User-Agent Mutt/1.10.1 (2018-07-13)
X-detected-operating-system by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic]
X-Received-From 193.197.184.2
X-BeenThere bug-bash@gnu.org
X-Mailman-Version 2.1.21
Precedence list
List-Id Bug reports for the GNU Bourne Again SHell <bug-bash.gnu.org>
List-Unsubscribe <https://lists.gnu.org/mailman/options/bug-bash>, <mailto:bug-bash-request@gnu.org?subject=unsubscribe>
List-Archive <http://lists.gnu.org/archive/html/bug-bash/>
List-Post <mailto:bug-bash@gnu.org>
List-Help <mailto:bug-bash-request@gnu.org?subject=help>
List-Subscribe <https://lists.gnu.org/mailman/listinfo/bug-bash>, <mailto:bug-bash-request@gnu.org?subject=subscribe>
Xref csiph.com gnu.bash.bug:14560

Show key headers only | View raw


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


Thread

examples/loadables/finfo.c type problems Christian Weisgerber <naddy@mips.inka.de> - 2018-09-07 23:28 +0200

csiph-web