trc: use proper type for storing ulimit values rc on amd64 stores ulimit values as 32-bit int, but the limits on OpenBSD amd64 can exceed 2^31, so "ulimit -a" shows some values as negative. This is a problem when I want to increase my ulimit but the hard ulimit values are printed as negative. - plan9port - [fork] Plan 9 from user space
 (HTM) git clone git://src.adamsgaard.dk/plan9port
 (DIR) Log
 (DIR) Files
 (DIR) Refs
 (DIR) README
 (DIR) LICENSE
       ---
 (DIR) commit 019be4481fee53a999ccb73c78e40df5f408b24e
 (DIR) parent 60f06594cc4d8c17a5148026132b890856d2fe1f
 (HTM) Author: Ray Lai <ray@raylai.com>
       Date:   Tue, 16 Jan 2018 15:41:56 +0800
       
       rc: use proper type for storing ulimit values
       rc on amd64 stores ulimit values as 32-bit int, but the limits on
       OpenBSD amd64 can exceed 2^31, so "ulimit -a" shows some values as
       negative. This is a problem when I want to increase my ulimit but
       tthe hard ulimit values are printed as negative.
       
       Diffstat:
         M src/cmd/rc/unixcrap.c               |      13 +++++++------
       
       1 file changed, 7 insertions(+), 6 deletions(-)
       ---
 (DIR) diff --git a/src/cmd/rc/unixcrap.c b/src/cmd/rc/unixcrap.c
       t@@ -58,7 +58,8 @@ eusage(void)
        void
        execulimit(void)
        {
       -        int fd, n, argc, sethard, setsoft, limit;
       +        rlim_t n;
       +        int fd, argc, sethard, setsoft, limit;
                int flag[256];
                char **argv, **oargv, *p;
                char *argv0;
       t@@ -118,10 +119,10 @@ execulimit(void)
                        for(p=eargs; *p; p++){
                                getrlimit(rlx[p-eargs], &rl);
                                n = flag['H'] ? rl.rlim_max : rl.rlim_cur;
       -                        if(n == -1)
       +                        if(n == RLIM_INFINITY)
                                        fprint(fd, "ulimit -%c unlimited\n", *p);
                                else
       -                                fprint(fd, "ulimit -%c %d\n", *p, n);
       +                                fprint(fd, "ulimit -%c %llud\n", *p, (uvlong)n);
                        }
                        goto out;
                }
       t@@ -132,10 +133,10 @@ execulimit(void)
                                switch(limit){
                                case Notset:
                                        n = flag['H'] ? rl.rlim_max : rl.rlim_cur;
       -                                if(n == -1)
       +                                if(n == RLIM_INFINITY)
                                                fprint(fd, "ulimit -%c unlimited\n", *p);
                                        else
       -                                        fprint(fd, "ulimit -%c %d\n", *p, n);
       +                                        fprint(fd, "ulimit -%c %llud\n", *p, (uvlong)n);
                                        break;
                                case Hard:
                                        n = rl.rlim_max;
       t@@ -144,7 +145,7 @@ execulimit(void)
                                        n = rl.rlim_cur;
                                        goto set;
                                case Unlimited:
       -                                n = -1;
       +                                n = RLIM_INFINITY;
                                        goto set;
                                default:
                                        n = limit;