Skip to content

Commit

Permalink
fmt/pl: use unsigned type before negation (#312)
Browse files Browse the repository at this point in the history
fixes "-fsanitize=undefined"
src/fmt/pl.c:94:15: runtime error: negation of -2147483648 cannot be
represented in type 'int32_t' (aka 'int'); cast to an unsigned type to
negate this value to itself
  • Loading branch information
sreimers authored Apr 11, 2022
1 parent 60fe727 commit 33763b0
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/fmt/pl.c
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ void pl_set_mbuf(struct pl *pl, const struct mbuf *mb)
*/
int32_t pl_i32(const struct pl *pl)
{
int32_t v = 0;
uint32_t v = 0;
uint32_t mul = 1;
const char *p;
bool neg = false;
Expand Down Expand Up @@ -104,7 +104,7 @@ int32_t pl_i32(const struct pl *pl)
*/
int64_t pl_i64(const struct pl *pl)
{
int64_t v = 0;
uint64_t v = 0;
uint64_t mul = 1;
const char *p;
bool neg = false;
Expand Down

0 comments on commit 33763b0

Please sign in to comment.