cvs commit: src/sys/sys _types.h resource.h

Peter Wemm peter at wemm.org
Tue Nov 9 01:34:10 GMT 2004


On Monday 08 November 2004 05:28 pm, Peter Wemm wrote:
> On Monday 08 November 2004 10:05 am, Dag-Erling Smorgrav wrote:
> > des         2004-11-08 18:05:43 UTC
> >
> >   FreeBSD src repository
> >
> >   Modified files:
> >     sys/sys              _types.h resource.h
> >   Log:
> >   Document why rlim_t needs to be a signed type.
> >   Define RLIM_INFINITY as INT64_MAX instead of hand-rolling it.
> >
> >   MFC after:      1 week
>
> Is this yours?
>
> ../../../kern/init_main.c: In function `proc0_init':
> ../../../kern/init_main.c:418: warning: integer overflow in
> expression ../../../kern/init_main.c:427: warning: integer overflow
> in expression for (i = 0; i < RLIM_NLIMITS; i++)
>                 p->p_limit->pl_rlimit[i].rlim_cur =
> 418                p->p_limit->pl_rlimit[i].rlim_max = RLIM_INFINITY;
> 427         p->p_cpulimit = RLIM_INFINITY;
>
> kern_resource.c:
>         newlim->pl_rlimit[RLIMIT_FSIZE].rlim_cur = RLIM_INFINITY;
>
> ../../../kern/kern_resource.c:564: warning: integer overflow in
> expression
> ../../../kern/kern_resource.c:566: warning: integer overflow in
> expression
>
> etc etc etc.

Yes, it is:
1.26         (des      09-Nov-04): #define      RLIM_INFINITY   ((rlim_t)(((int64_t)1 << 63) - 1))

This is impossible.  1<<63 will not fit in an int64_t.  You're shifting into the sign bit.
You probably want uint64_t and then cast it back to the signed type.


-- 
Peter Wemm - peter at wemm.org; peter at FreeBSD.org; peter at yahoo-inc.com
"All of this is for nothing if we don't go to the stars" - JMS/B5


More information about the cvs-src mailing list