diff --git a/libc3/buf_parse_u.c.in b/libc3/buf_parse_u.c.in
index e285c21..d4c3a24 100644
--- a/libc3/buf_parse_u.c.in
+++ b/libc3/buf_parse_u.c.in
@@ -95,6 +95,7 @@ sw buf_parse_u_bits$_base (s_buf *buf, const s_str *base,
sw result = 0;
s_buf_save save;
u_bits$ u = 0;
+ u_bits$ u2 = 0;
assert(buf);
assert(base);
assert(dest);
@@ -126,7 +127,8 @@ sw buf_parse_u_bits$_base (s_buf *buf, const s_str *base,
goto restore;
}
u *= radix;
- if (u > ((u_bits$) (U_BITS$_MAX - digit))) {
+ u2 = U_BITS$_MAX - digit;
+ if (u > u2) {
warnx("buf_parse_u_bits$_base: +: integer overflow");
r = -1;
goto restore;
diff --git a/libc3/buf_parse_u16.c b/libc3/buf_parse_u16.c
index 3c2f497..802890a 100644
--- a/libc3/buf_parse_u16.c
+++ b/libc3/buf_parse_u16.c
@@ -95,6 +95,7 @@ sw buf_parse_u16_base (s_buf *buf, const s_str *base,
sw result = 0;
s_buf_save save;
u16 u = 0;
+ u16 u2 = 0;
assert(buf);
assert(base);
assert(dest);
@@ -126,7 +127,8 @@ sw buf_parse_u16_base (s_buf *buf, const s_str *base,
goto restore;
}
u *= radix;
- if (u > ((u16) (U16_MAX - digit))) {
+ u2 = U16_MAX - digit;
+ if (u > u2) {
warnx("buf_parse_u16_base: +: integer overflow");
r = -1;
goto restore;
diff --git a/libc3/buf_parse_u32.c b/libc3/buf_parse_u32.c
index cf49de9..94992be 100644
--- a/libc3/buf_parse_u32.c
+++ b/libc3/buf_parse_u32.c
@@ -95,6 +95,7 @@ sw buf_parse_u32_base (s_buf *buf, const s_str *base,
sw result = 0;
s_buf_save save;
u32 u = 0;
+ u32 u2 = 0;
assert(buf);
assert(base);
assert(dest);
@@ -126,7 +127,8 @@ sw buf_parse_u32_base (s_buf *buf, const s_str *base,
goto restore;
}
u *= radix;
- if (u > ((u32) (U32_MAX - digit))) {
+ u2 = U32_MAX - digit;
+ if (u > u2) {
warnx("buf_parse_u32_base: +: integer overflow");
r = -1;
goto restore;
diff --git a/libc3/buf_parse_u64.c b/libc3/buf_parse_u64.c
index e648831..74da608 100644
--- a/libc3/buf_parse_u64.c
+++ b/libc3/buf_parse_u64.c
@@ -95,6 +95,7 @@ sw buf_parse_u64_base (s_buf *buf, const s_str *base,
sw result = 0;
s_buf_save save;
u64 u = 0;
+ u64 u2 = 0;
assert(buf);
assert(base);
assert(dest);
@@ -126,7 +127,8 @@ sw buf_parse_u64_base (s_buf *buf, const s_str *base,
goto restore;
}
u *= radix;
- if (u > ((u64) (U64_MAX - digit))) {
+ u2 = U64_MAX - digit;
+ if (u > u2) {
warnx("buf_parse_u64_base: +: integer overflow");
r = -1;
goto restore;
diff --git a/libc3/buf_parse_u8.c b/libc3/buf_parse_u8.c
index c71ef80..7284f5d 100644
--- a/libc3/buf_parse_u8.c
+++ b/libc3/buf_parse_u8.c
@@ -95,6 +95,7 @@ sw buf_parse_u8_base (s_buf *buf, const s_str *base,
sw result = 0;
s_buf_save save;
u8 u = 0;
+ u8 u2 = 0;
assert(buf);
assert(base);
assert(dest);
@@ -126,7 +127,8 @@ sw buf_parse_u8_base (s_buf *buf, const s_str *base,
goto restore;
}
u *= radix;
- if (u > ((u8) (U8_MAX - digit))) {
+ u2 = U8_MAX - digit;
+ if (u > u2) {
warnx("buf_parse_u8_base: +: integer overflow");
r = -1;
goto restore;
diff --git a/libc3/buf_parse_uw.c b/libc3/buf_parse_uw.c
index 4410d89..55d03d0 100644
--- a/libc3/buf_parse_uw.c
+++ b/libc3/buf_parse_uw.c
@@ -95,6 +95,7 @@ sw buf_parse_uw_base (s_buf *buf, const s_str *base,
sw result = 0;
s_buf_save save;
uw u = 0;
+ uw u2 = 0;
assert(buf);
assert(base);
assert(dest);
@@ -126,7 +127,8 @@ sw buf_parse_uw_base (s_buf *buf, const s_str *base,
goto restore;
}
u *= radix;
- if (u > ((uw) (UW_MAX - digit))) {
+ u2 = UW_MAX - digit;
+ if (u > u2) {
warnx("buf_parse_uw_base: +: integer overflow");
r = -1;
goto restore;