diff options
author | Pedro F. Giffuni <pfg@FreeBSD.org> | 2015-02-17 16:01:00 +0000 |
---|---|---|
committer | Pedro F. Giffuni <pfg@FreeBSD.org> | 2015-02-17 16:01:00 +0000 |
commit | d2f783303b3f16a7b930190f8cd417df16312d94 (patch) | |
tree | b858b79a33463473934bb087ccc907a5fce104ab | |
parent | 71a0c925ce76a304c25bf6d8d8035720f82941bd (diff) |
Notes
-rw-r--r-- | lib/libc/gen/ulimit.c | 18 |
1 files changed, 8 insertions, 10 deletions
diff --git a/lib/libc/gen/ulimit.c b/lib/libc/gen/ulimit.c index db1d4988b717..2c090c0a7ef3 100644 --- a/lib/libc/gen/ulimit.c +++ b/lib/libc/gen/ulimit.c @@ -33,7 +33,6 @@ #include <errno.h> #include <limits.h> #include <stdarg.h> -#include <stdint.h> #include <ulimit.h> long @@ -41,8 +40,7 @@ ulimit(int cmd, ...) { struct rlimit limit; va_list ap; - volatile intmax_t targ; - long arg; + rlim_t arg; if (cmd == UL_GETFSIZE) { if (getrlimit(RLIMIT_FSIZE, &limit) == -1) @@ -53,18 +51,18 @@ ulimit(int cmd, ...) return ((long)limit.rlim_cur); } else if (cmd == UL_SETFSIZE) { va_start(ap, cmd); - targ = arg = va_arg(ap, long); + arg = va_arg(ap, long); va_end(ap); - if (targ < 0) - targ = LONG_MAX; - if (targ > RLIM_INFINITY / 512) - targ = RLIM_INFINITY / 512; - limit.rlim_max = limit.rlim_cur = targ * 512; + if (arg < 0) + arg = LONG_MAX; + if (arg > RLIM_INFINITY / 512) + arg = RLIM_INFINITY / 512; + limit.rlim_max = limit.rlim_cur = arg * 512; /* The setrlimit() function sets errno to EPERM if needed. */ if (setrlimit(RLIMIT_FSIZE, &limit) == -1) return (-1); - return ((long)targ); + return ((long)arg); } else { errno = EINVAL; return (-1); |