diff options
author | Samuel Thibault <samuel.thibault@ens-lyon.org> | 2023-02-15 18:17:33 +0100 |
---|---|---|
committer | Samuel Thibault <samuel.thibault@ens-lyon.org> | 2023-02-15 18:18:08 +0100 |
commit | f6c29f62283b05ca12bc032870b5e69bd50d82ba (patch) | |
tree | 6c7f2633466d77838503824d6db577f9ce3a0bb4 /procfs | |
parent | 56d065041793509a6f60671f6ae3400698bd5639 (diff) | |
download | hurd-f6c29f62283b05ca12bc032870b5e69bd50d82ba.tar.gz hurd-f6c29f62283b05ca12bc032870b5e69bd50d82ba.tar.bz2 hurd-f6c29f62283b05ca12bc032870b5e69bd50d82ba.zip |
Fix accessing bit 31
Shifting (signed) 1 to left 31 positions is undefined behavior. So make
this an unsigned so it becomes defined behavior.
Diffstat (limited to 'procfs')
-rw-r--r-- | procfs/process.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/procfs/process.c b/procfs/process.c index f608bed6..a9ba51ab 100644 --- a/procfs/process.c +++ b/procfs/process.c @@ -47,8 +47,8 @@ static char state_char (struct proc_stat *ps) { int i; - for (i = 0; (1 << i) & (PSTAT_STATE_P_STATES | PSTAT_STATE_T_STATES); i++) - if (proc_stat_state (ps) & (1 << i)) + for (i = 0; (1U << i) & (PSTAT_STATE_P_STATES | PSTAT_STATE_T_STATES); i++) + if (proc_stat_state (ps) & (1U << i)) return proc_stat_state_tags[i]; return '?'; @@ -69,7 +69,7 @@ static const char *state_string (struct proc_stat *ps) int i; for (i = 0; state_strings[i]; i++) - if (proc_stat_state (ps) & (1 << i)) + if (proc_stat_state (ps) & (1U << i)) return state_strings[i]; return "? (unknown)"; |