svn commit: r278634 - head/lib/libc/gen
Bruce Evans
brde at optusnet.com.au
Fri Feb 13 14:54:26 UTC 2015
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
More information about the svn-src-head
mailing list