[PATCH v2 32/65] MMIX: use is_whitespace()
Jan Beulich
jbeulich@suse.com
Fri Jan 31 06:54:43 GMT 2025
On 31.01.2025 07:33, Hans-Peter Nilsson wrote:
> On Mon, 27 Jan 2025, Jan Beulich wrote:
>> Convert open-coded checks as well as ISSPACE() uses. At the same time
>> use is_end_of_stmt() instead of open-coded checks; do the conversion
>> even when not adjacent to code being modified anyway to cover all cases
>> where the is_end_of_line[] index was wrongly cast from plain char (which
>> can be signed) to unsigned int.
>
> Where is the "wrongly cast" to which you refer?
>
> I see no more "wrongly casts" before the patch than after,
> considering that is_whitespace is doing such a cast. But, I
> could easily have missed a spot.
Take this example:
while (*s && ISSPACE (*s) && ! is_end_of_line[(unsigned int) *s])
s++;
If plain char is signed, negative values will convert to huge positive
unsigned int ones. As opposed to when casting to unsigned char (as all
the IS*() and is*() helper macros effectively[1] do, not just
is_end_of_stmt()).
Jan
[1] safe-ctype.h actually ANDs by 0xff, apparently in an attempt to
deal with CHAR_BITS != 8 cases. That's not really correct though imo;
that case needs dealing with by growing the array dimensions, to
cover all values representable in a char.
Jan
More information about the Binutils
mailing list