exec-util: use unsigned shift for ExecCommandFlags

Using signed int literal '1' in left shift operations can
theoretically lead to undefined behavior. Use 1U to be explicit
about unsigned arithmetic.

CID#1548018

Follow-up for b3d593673c
This commit is contained in:
Luca Boccassi
2026-03-28 20:13:40 +00:00
parent cda2962daf
commit 3e38052f1d
+2 -2
View File
@@ -500,7 +500,7 @@ assert_cc((1 << ELEMENTSOF(exec_command_strings)) - 1 == _EXEC_COMMAND_FLAGS_ALL
const char* exec_command_flags_to_string(ExecCommandFlags i) {
for (size_t idx = 0; idx < ELEMENTSOF(exec_command_strings); idx++)
if (i == (1 << idx))
if (i == (ExecCommandFlags) (1U << idx))
return exec_command_strings[idx];
return NULL;
@@ -516,7 +516,7 @@ ExecCommandFlags exec_command_flags_from_string(const char *s) {
if (idx < 0)
return _EXEC_COMMAND_FLAGS_INVALID;
return 1 << idx;
return 1U << idx;
}
int fexecve_or_execve(int executable_fd, const char *executable, char *const argv[], char *const envp[]) {