From 25454fa34dc6d27239f8ad0b1dda6e2270eece62 Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Sat, 28 Jun 2025 20:57:00 -0700 Subject: [PATCH] od: be more consistent re sizeof MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit * 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. --- src/od.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) 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 -- 2.47.3