compiler warnings about format strings

Wayne Davison wayne at blorf.net
Thu Apr 5 04:47:46 EST 2001


On Wed, 4 Apr 2001 mouring at etoh.eviladmin.org wrote:
> What platform is this for?  Majority of the platforms I'm on pid is
> defined as u_int/int  not u_long/long  so I don't personally see
> such mismatch errors.

I'm compiling on Solaris x86 v2.6.  Pids, uids, & gids are all longs
here (which just happens to be the same physical size as an int, but
that's beside the point).

For maximum portability, the code should always cast a system-defined
type (such as pid_t) when combining it with a fixed-size type format
string (such as %d or %ld).  Casting it up to "long" ensures that no
data is lost (at least until "long long" pids come about :-) ).

..wayne..




More information about the openssh-unix-dev mailing list