httpd-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Marc Slemko <ma...@worldgate.com>
Subject Re: cvs commit: apache-1.3/src/main http_main.c
Date Wed, 18 Mar 1998 00:33:39 GMT
On Tue, 17 Mar 1998, Ben Laurie wrote:

> Jim Jagielski wrote:
> > 
> > marc@hyperreal.org wrote:
> > >
> > > marc        98/03/17 15:24:16
> > >
> > >   Modified:    src/main http_main.c
> > >   Log:
> > >   Fix warning on Solaris.  Using a long format should be safer for
> > >   everything.  I think.
> > >
> > >        char buf[20];
> > >
> > >   -    ap_snprintf(buf, sizeof(buf), ".%u", getpid());
> > >   +    ap_snprintf(buf, sizeof(buf), ".%lu", getpid());
> > >        lock_fname = pstrcat(p, server_root_relative(p, lock_fname), buf, NULL);
> > >    }
> > 
> > Wouldn't it make even more sense to cast it?
> > 
> >     ap_snprintf(buf, sizeof(buf), ".%lu", (unsigned long)getpid());
> 
> Whilst I think it unlikely that we'll ever run on DOS (16) the latter
> would work there and the former wouldn't :-)

Grumble.

But what if we have 32 bit longs and 64 bit PIDs?  Guess that isn't too
likely on most systems; 64 bits for moth would be more likely.

I don't like casting it because that hides loss of data.  We could...
erm... make it a function that took an unsigned long, then as long as
getpid's return type was smaller than or equal to a u_long we would be ok,
otherwise we should get a warning.  But that is lame.


Mime
View raw message