Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 14 Feb 2015 01:54:17 +1100 (EST)
From:      Bruce Evans <brde@optusnet.com.au>
To:        Bruce Evans <brde@optusnet.com.au>
Cc:        "Bjoern A. Zeeb" <bz@freebsd.org>, src-committers@freebsd.org, Andrey Chernov <ache@freebsd.org>, svn-src-all@freebsd.org, Pedro Giffuni <pfg@freebsd.org>, svn-src-head@freebsd.org
Subject:   Re: svn commit: r278634 - head/lib/libc/gen
Message-ID:  <20150214015036.Y2552@besplex.bde.org>
In-Reply-To: <20150214005543.X2210@besplex.bde.org>
References:  <201502122107.t1CL7gaO004041@svn.freebsd.org> <BF5F2941-52F5-41A4-8723-E316919718EE@FreeBSD.org> <54DD2A87.2050008@FreeBSD.org> <9A683D99-C1E9-4736-982C-69F583D3A40D@FreeBSD.org> <20150213172738.C1007@besplex.bde.org> <54DDABF2.9000201@freebsd.org> <54DDAEF6.3060900@freebsd.org> <20150214005543.X2210@besplex.bde.org>

next in thread | previous in thread | raw e-mail | index | archive | help
On Sat, 14 Feb 2015, Bruce Evans wrote:

> ...
> However, I don't like using rlim_t for the scaled value that is not
> an rlimit.
>
> An incomplete fix with handling of negative values restored is something
> like:
>
> 	intmax_t targ;
>
> 	targ = arg;
> 	if (targ > RLIM_INFINITY / 512)
> 		targ = RLIM_INFINITY / 512;
> 	limit.rlim_max = limit.rlim_cur = targ * 512
>
> This is still incomplete.  The comparison is still obviously tautologous
> when intmax_t == rlim_t (the amd64 case).  If intmax_t is larger than
> long (the i386 case) or even rlim_t (the notyet case), then it is slightly
> less obviously tautologous.  This can be fixed by sprinkling volatiles,
> e.g. for targ.

Oops, I forgot to restore handling of negatives.  Also with volatile:

 	volatile intmax_t targ;

 	targ = arg;
 	if (targ > RLIM_INFINITY / 512 || targ < 0)
 		targ = RLIM_INFINITY / 512;
 	limit.rlim_max = limit.rlim_cur = targ * 512;

This has not been tested.

Bruce



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