From: Paul Eggert Date: Sun, 29 Jun 2025 03:57:00 +0000 (-0700) Subject: od: be more consistent re sizeof X-Git-Tag: v9.8~265 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=25454fa34dc6d27239f8ad0b1dda6e2270eece62;p=thirdparty%2Fcoreutils.git od: be more consistent re sizeof * src/od.c (width_bytes, decode_one_format): Don’t assume a signed type has the same size as the corresponding unsigned type. This has no effect on practical platforms; it’s just for consistency there. --- diff --git a/src/od.c b/src/od.c index c3c76cc866..50319aa834 100644 --- a/src/od.c +++ b/src/od.c @@ -131,15 +131,15 @@ struct tspec static const int width_bytes[] = { -1, - sizeof (char), + sizeof (unsigned char), #if UCHAR_MAX < USHRT_MAX - sizeof (short int), + sizeof (unsigned short int), #endif #if USHRT_MAX < UINT_MAX - sizeof (int), + sizeof (unsigned int), #endif #if UINT_MAX < ULONG_MAX - sizeof (long int), + sizeof (unsigned long int), #endif #if ULONG_MAX < ULLONG_MAX sizeof (unsigned long long int), @@ -712,22 +712,22 @@ decode_one_format (char const *s_orig, char const *s, char const **next, { case 'C': ++s; - size = sizeof (char); + size = sizeof (unsigned char); break; case 'S': ++s; - size = sizeof (short int); + size = sizeof (unsigned short int); break; case 'I': ++s; - size = sizeof (int); + size = sizeof (unsigned int); break; case 'L': ++s; - size = sizeof (long int); + size = sizeof (unsigned long int); break; default: @@ -740,7 +740,7 @@ decode_one_format (char const *s_orig, char const *s, char const **next, return false; } if (p == s) - size = sizeof (int); + size = sizeof (unsigned int); else { if (ARRAY_CARDINALITY (integral_type_size) <= size