⛏️ index : haiku.git

author PulkoMandy <pulkomandy@pulkomandy.tk> 2022-11-07 18:18:40.0 +01:00:00
committer waddlesplash <waddlesplash@gmail.com> 2022-11-08 16:12:07.0 +00:00:00
commit
9afd6079ee4f4aebd8ce02fadf59c8177e8ab183 [patch]
tree
120c8d925a54b9a3b33d37a8566846a5d7b7a9a8
parent
957adb99522505c830892ed9b5c02a5d1f2b4579
download
9afd6079ee4f4aebd8ce02fadf59c8177e8ab183.tar.gz

stdint.h: fix definition of UINT8_MAX, UINT16_MAX, UINT8_C and UINT16_C

C99 chapter 7.18.2, Limits of specified-width integer types:

"This expression shall have the same type as would an expression that is
an object of the corresponding type according to the integer promotions."

C99 chapter 6.3.1.1:

"If an int can represent all values of the original type, the value is
converted to an int; otherwise, it is converted to an unsigned int.
These are called the integer promotions."

Therefore, UINT8_MAX, UINT16_MAX, UINT8_C and UINT16_C should be signed.

This prevents building WebKit with -Werror.

Change-Id: Ib2a2c15acc2c761cccf8caa016c7ff163e3fdc0d
Reviewed-on: https://review.haiku-os.org/c/haiku/+/5806
Tested-by: Commit checker robot <no-reply+buildbot@haiku-os.org>
Reviewed-by: waddlesplash <waddlesplash@gmail.com>
(cherry picked from commit 32a71a00aab29e272bd85e29061e1cf6431cdc77)
Reviewed-on: https://review.haiku-os.org/c/haiku/+/5779

Diff

 headers/posix/stdint.h | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/headers/posix/stdint.h b/headers/posix/stdint.h
index 7bb6999..45832ce 100644
--- a/headers/posix/stdint.h
+++ b/headers/posix/stdint.h
@@ -59,11 +59,11 @@
/* Limits of exact-width integer types */
#define INT8_MIN 	(-128)
#define INT8_MAX 	(127)
#define UINT8_MAX	(255U)
#define UINT8_MAX	(255)

#define INT16_MIN 	(-32768)
#define INT16_MAX 	(32767)
#define UINT16_MAX	(65535U)
#define UINT16_MAX	(65535)

#define INT32_MAX	(2147483647)
#define INT32_MIN 	(-INT32_MAX-1)
@@ -140,8 +140,8 @@
#define INT16_C(value) 	value
#define INT32_C(value) 	value

#define UINT8_C(value) 	value ## U
#define UINT16_C(value) value ## U
#define UINT8_C(value) 	value
#define UINT16_C(value) value
#define UINT32_C(value) value ## U

#if defined(__SIZEOF_LONG__) && __SIZEOF_LONG__ > 4