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
_______________________________________________
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"

Reply via email to