Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 8 Nov 2004 17:34:09 -0800
From:      Peter Wemm <peter@wemm.org>
To:        Dag-Erling Smorgrav <des@freebsd.org>
Cc:        cvs-all@freebsd.org
Subject:   Re: cvs commit: src/sys/sys _types.h resource.h
Message-ID:  <200411081734.10062.peter@wemm.org>
In-Reply-To: <200411081728.10575.peter@wemm.org>
References:  <200411081805.iA8I5hVK038813@repoman.freebsd.org> <200411081728.10575.peter@wemm.org>

next in thread | previous in thread | raw e-mail | index | archive | help
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@wemm.org; peter@FreeBSD.org; peter@yahoo-inc.com
"All of this is for nothing if we don't go to the stars" - JMS/B5



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200411081734.10062.peter>