[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20251120155816.GB13687@macsyma-3.local>
Date: Thu, 20 Nov 2025 10:58:16 -0500
From: "Theodore Tso" <tytso@....edu>
To: David Laight <david.laight.linux@...il.com>
Cc: Guan-Chun Wu <409411716@....tku.edu.tw>,
Andreas Dilger <adilger.kernel@...ger.ca>, linux-ext4@...r.kernel.org,
linux-kernel@...r.kernel.org, visitorckw@...il.com
Subject: Re: [PATCH] ext4: improve str2hashbuf by processing 4-byte chunks
On Sun, Nov 16, 2025 at 07:35:13PM +0000, David Laight wrote:
>
> The (int) casts are unnecessary (throughout), 'char' is always promoted to
> 'signed int' before any arithmetic.
nit: in this case the casts aren't necessary, but your comment is not
correct in general, so I just wanted to make sure it's corrected in
case someone later looks at the mail archive.
"char" is not always signed. It can be signed or unsigned; the C
specification allows either. In this particular case, scp is a
"signed char", not "char".
Secondly, it's not that a promotion happens before "any" arithmetic.
If we add two 8-bit values together, promotion doesn't happen. In
this case, we are adding a signed char to an int, so the promotion
will happen.
Cheers,
- Ted
Powered by blists - more mailing lists