[PATCH] print format correctness for uid, gid, pid, mode in "util-linux/ipcs.c"
walter harms
WHarms at bfs.de
Thu Mar 6 01:16:37 PST 2008
Joe Krahn wrote:
> In "util-linux/ipcs.c", gid, uid, pid and mode values are all assumed to be default-size ints. I
> have patched the formats to use long ints, and cast all arguments to longs. This seems to be the
> common approach. The one exception is that I cast arguments with (mode&0777) as default-size ints.
>
> In reality, most busybox target platforms have the same size for int and long-int, but there are
> some 64-bit platforms where these values really are larger than default ints. The only way to be
> exact is to use macros as in <inttypes.h>, which gets rather ugly. OTOH, that approach might avoid
> unnecessary casting in some case, and might really be a better fit for the very-light-weight design
> goal.
>
Hi Joe,
your comment is correct: some system have a funny long/int ratio.
the ipcs stuff if only useful in linux context and the current code defines
e.g. uid_t == __kernel_uid32_t == unsigned int
while __kernel_mode_t == unsigned short
long is used only with off_t and time_t
IMHO int is a save bet (what may change in future !). Do you have architecture
where this is a really wrong assumption ?
ntl: we should use %u more often
More information about the busybox
mailing list