cmdline: better errors for setting rlimits
authorRobert Swiecki <robert@swiecki.net>
Sat, 7 Oct 2017 10:37:26 +0000 (12:37 +0200)
committerRobert Swiecki <robert@swiecki.net>
Sat, 7 Oct 2017 10:37:26 +0000 (12:37 +0200)
cmdline.c

index ac84809d8f85e96b31d2b79b0fec3984b7c7592c..f439b461f312faeb2b66a28c1c37ff74414e9990 100644 (file)
--- a/cmdline.c
+++ b/cmdline.c
@@ -254,6 +254,9 @@ void cmdlineLogParams(struct nsjconf_t *nsjconf)
 
 __rlim64_t cmdlineParseRLimit(int res, const char *optarg, unsigned long mul)
 {
+       if (strcasecmp(optarg, "inf") == 0) {
+               return RLIM64_INFINITY;
+       }
        struct rlimit64 cur;
        if (getrlimit64(res, &cur) == -1) {
                PLOG_F("getrlimit(%d)", res);
@@ -264,11 +267,8 @@ __rlim64_t cmdlineParseRLimit(int res, const char *optarg, unsigned long mul)
        if (strcasecmp(optarg, "max") == 0 || strcasecmp(optarg, "hard")) {
                return cur.rlim_max;
        }
-       if (strcasecmp(optarg, "inf") == 0) {
-               return RLIM64_INFINITY;
-       }
        if (utilIsANumber(optarg) == false) {
-               LOG_F("RLIMIT %d needs a numeric or 'max'/'def' value ('%s' provided)", res,
+               LOG_F("RLIMIT %d needs a numeric or 'max'/'hard'/'def'/'soft'/'inf' value ('%s' provided)", res,
                      optarg);
        }
        __rlim64_t val = strtoull(optarg, NULL, 0) * mul;