From 52338171220af1ff009ea30114a290c80847b2dd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20G=C3=B6ttsche?= Date: Thu, 24 Sep 2020 12:01:59 +0200 Subject: Avoid unsigned integer overflow unsigned integer overflows are well-defined, but they might point to a counting issue. Having the code free of unsigned overflows makes it easier to spot potential bugs. Action.c:332:27: runtime error: implicit conversion from type 'int' of value -1 (32-bit, signed) to type 'uid_t' (aka 'unsigned int') changed the value to 4294967295 (32-bit, unsigned) SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior Action.c:332:27 in --- Action.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Action.c') diff --git a/Action.c b/Action.c index 79a4225d..eac7f1f6 100644 --- a/Action.c +++ b/Action.c @@ -329,7 +329,7 @@ static Htop_Reaction actionFilterByUser(State* st) { ListItem* picked = (ListItem*) Action_pickFromVector(st, usersPanel, 20, false); if (picked) { if (picked == allUsers) { - st->pl->userId = -1; + st->pl->userId = (uid_t)-1; } else { Action_setUserOnly(ListItem_getRef(picked), &(st->pl->userId)); } -- cgit v1.2.3