Hello,
While going through the warnings in the Hurd repo I found
the following:
../../utils/w.c:95:42: warning: result of '536870912 << 3' requires 34 bits
to represent, but 'int' only has 32 bits [-Wshift-overflow=]
95 | #define W_PSTAT_LOGIN (PSTAT_USER_BASE << 3)
| ^~
../../utils/w.c:169:19: note: in expansion of macro 'W_PSTAT_LOGIN'
169 | have |= (need & W_PSTAT_LOGIN);
| ^~~~~~~~~~~~~
PSTAT_USER_BASE is defined as
libps/ps.h:#define PSTAT_USER_BASE 0x20000000
'have' and 'need' are ps_flags_t which is defined as:
libps/ps.h:typedef unsigned ps_flags_t;
I'm not sure how to fix it in a portable way. It looks like ps_flags_t should
be a 64-bit integer and probably PSTAT_USER_BASE get an 'l' suffix.
Something like below works, but I'm not sure about portability and whether
other constants should also get the l prefix.
Thanks,
Diego
-- >8 -- >8 --
libps: make ps_flags_t 64-bit long.
diff --git a/libps/ps.h b/libps/ps.h
index 3e59c66a..b89e5c14 100644
--- a/libps/ps.h
+++ b/libps/ps.h
@@ -174,7 +174,7 @@ error_t ps_context_find_user (struct ps_context *pc, uid_t
uid,
/* A PROC_STAT holds lots of info about the process PID at SERVER; exactly
which info is dependent on its FLAGS field. */
-typedef unsigned ps_flags_t;
+typedef unsigned long ps_flags_t;
typedef unsigned ps_state_t;
struct proc_stat
@@ -356,7 +356,7 @@ struct proc_stat
#define PSTAT_NO_MSGPORT 0x1000000 /* Don't use the msgport at all */
/* Bits from PSTAT_USER_BASE on up are available for user-use. */
-#define PSTAT_USER_BASE 0x20000000
+#define PSTAT_USER_BASE 0x20000000l
#define PSTAT_USER_MASK ~(PSTAT_USER_BASE - 1)
^L
/* If the PSTAT_STATE flag is set, then the proc_stats state field holds a