diff mbox series

[v3,11/19] use the type for predefined_max()

Message ID 20181214001536.6259-12-luc.vanoostenryck@gmail.com (mailing list archive)
State Mainlined, archived
Headers show
Series predefined macros for intmax_t/intptr_t/... | expand

Commit Message

Luc Van Oostenryck Dec. 14, 2018, 12:15 a.m. UTC
---
 lib.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)
diff mbox series

Patch

diff --git a/lib.c b/lib.c
index dde9f7c36..d03bb856e 100644
--- a/lib.c
+++ b/lib.c
@@ -1151,8 +1151,10 @@  static void predefined_width(const char *name, unsigned bits)
 	predefine(buf, 1, "%d", bits);
 }
 
-static void predefined_max(const char *name, const char *suffix, unsigned bits)
+static void predefined_max(const char *name, struct symbol *type)
 {
+	const char *suffix = builtin_type_suffix(type);
+	unsigned bits = type->bit_size - is_signed_type(type);
 	unsigned long long max = bits_mask(bits);
 	char buf[32];
 
@@ -1174,10 +1176,8 @@  static void predefined_ctype(const char *name, struct symbol *type, int flags)
 		const char *suffix = (flags & PTYPE_T) ? "_T" : "";
 		predefined_sizeof(name, suffix, bits);
 	}
-	if (flags & PTYPE_MAX) {
-		const char *suffix = builtin_type_suffix(type);
-		predefined_max(name, suffix, bits - is_signed_type(type));
-	}
+	if (flags & PTYPE_MAX)
+		predefined_max(name, type);
 	if (flags & PTYPE_TYPE)
 		predefined_type(name, type);
 	if (flags & PTYPE_WIDTH)