From: Alejandro Colomar <colomar.6.4.3@gmail.com>
To: kbukin@gmail.com
Cc: linux-man@vger.kernel.org, mtk.manpages@gmail.com,
"Dmitry V. Levin" <ldv@altlinux.org>
Subject: Re: [PATCH] stat.2: fixed inode printing in example program
Date: Sun, 13 Sep 2020 20:43:50 +0200 [thread overview]
Message-ID: <68e2c613-3ccf-a62d-f2ae-3e33e9450a3a@gmail.com> (raw)
In-Reply-To: <20200913182949.29815-1-kbukin@gmail.com>
> Such erroneous reporting happens for inode values greater than maximum
> value which can be stored in signed long. Casting does not seem to be
> necessary here. Printing inode as unsigned long long fixes the issue.
The cast is necessary.
Relevant standard: C18 §6.5.2.2 6
Details: 'ino_t' may (and will likely) be defined as 'unsigned long'.
If you try to print an 'unsigned long' with "%llu" you will:
- have Undefined Behavior (and a warning) if 'sizeof(long) < sizeof(long
long)'.
- have a warning if 'sizeof(long) == sizeof(long long)'.
So if you want to use 'unsigned long long', you'll need to cast.
Cheers,
Alex
next prev parent reply other threads:[~2020-09-13 18:44 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-09-13 18:29 [PATCH] stat.2: fixed inode printing in example program Konstantin Bukin
2020-09-13 18:43 ` Alejandro Colomar [this message]
2020-09-13 19:32 ` Konstantin Bukin
-- strict thread matches above, loose matches on Subject: below --
2020-09-13 15:04 Konstantin Bukin
2020-09-13 15:16 ` Dmitry V. Levin
2020-09-13 17:24 ` Konstantin Bukin
2020-09-13 17:38 ` Dmitry V. Levin
2020-09-13 18:04 ` Alejandro Colomar
2020-09-13 18:16 ` Konstantin Bukin
2020-09-13 18:30 ` Alejandro Colomar
2020-09-13 18:42 ` Konstantin Bukin
2020-09-13 18:46 ` Alejandro Colomar
2020-09-13 19:12 ` Konstantin Bukin
2020-09-13 19:39 ` Konstantin Bukin
2020-09-13 19:40 ` Konstantin Bukin
2020-09-14 9:30 ` Michael Kerrisk (man-pages)
2020-09-13 18:04 ` Konstantin Bukin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=68e2c613-3ccf-a62d-f2ae-3e33e9450a3a@gmail.com \
--to=colomar.6.4.3@gmail.com \
--cc=kbukin@gmail.com \
--cc=ldv@altlinux.org \
--cc=linux-man@vger.kernel.org \
--cc=mtk.manpages@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox