GNU bug report logs - #48960
stat v8.30 - device number in decimal shown as 16bit number instead of to converted 8bit

Previous Next

Package: coreutils;

Reported by: wolfgang.rohm <at> arcor.de

Date: Fri, 11 Jun 2021 14:58:03 UTC

Severity: normal

Done: Pádraig Brady <P <at> draigBrady.com>

Bug is archived. No further changes may be made.

Full log


Message #20 received at 48960 <at> debbugs.gnu.org (full text, mbox):

From: Paul Eggert <eggert <at> cs.ucla.edu>
To: Pádraig Brady <P <at> draigBrady.com>,
 wolfgang.rohm <at> arcor.de, 48960 <at> debbugs.gnu.org
Subject: Re: bug#48960: stat v8.30 - device number in decimal shown as 16bit
 number instead of to converted 8bit
Date: Sun, 20 Jun 2021 14:38:01 -0700
Thanks for writing that patch. One minor note:

On 6/20/21 7:21 AM, Pádraig Brady wrote:

> +                                    (to_uchar (mod_char) << CHAR_BIT)
> +                                     + to_uchar (fmt_char),

Neither mod_char nor fmt_char can be negative (this is guaranteed by the 
C standard since all the relevant constants are in the basic character 
set) so the to_uchar calls are unnecessary.

Also, this code assumes that 2 * CHAR_BIT <= MIN (INT_WIDTH, 
UINT_WIDTH), something that POSIX requires but the C standard does not; 
it'd be a bit safer (if pedantic) to add 'verify (2 * CHAR_BIT <= MIN 
(INT_WIDTH, UINT_WIDTH));'.

I'd also change print_stat's arg from unsigned int to int; if you did 
that, you could change the above 'MIN (INT_WIDTH, UINT_WIDTH)' to plain 
'INT_WIDTH'. (These days we're negative on unsigned types anyway, for 
all the usual reasons....)

Better yet, pass two char args to print_stat instead of a single int 
portmanteau.




This bug report was last modified 3 years and 340 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.