]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
prlimit: fix compiler warning [-Wmaybe-uninitialized]
authorKarel Zak <kzak@redhat.com>
Mon, 9 Aug 2021 07:45:21 +0000 (09:45 +0200)
committerKarel Zak <kzak@redhat.com>
Mon, 9 Aug 2021 09:54:07 +0000 (11:54 +0200)
sys-utils/prlimit.c:467:16: warning: 'hard' may be used uninitialized in this function [-Wmaybe-uninitialized]
  lim->rlim_max = hard;
  ~~~~~~~~~~~~~~^~~~~~
sys-utils/prlimit.c:456:15: note: 'hard' was declared here
  rlim_t soft, hard;
               ^~~~
sys-utils/prlimit.c:466:16: warning: 'soft' may be used uninitialized in this function [-Wmaybe-uninitialized]
  lim->rlim_cur = soft;
  ~~~~~~~~~~~~~~^~~~~~
sys-utils/prlimit.c:456:9: note: 'soft' was declared here
  rlim_t soft, hard;
         ^~~~

References: https://github.com/karelzak/util-linux/issues/1406
Signed-off-by: Karel Zak <kzak@redhat.com>
sys-utils/prlimit.c

index 1bdb2cb45a93647f833cbf1a229983a84ec9fc2d..eba73c751df4588265cc9ab6766a3086afba25e7 100644 (file)
@@ -453,7 +453,7 @@ static int get_range(char *str, rlim_t *soft, rlim_t *hard, int *found)
 
 static int parse_prlim(struct rlimit *lim, char *ops, size_t id)
 {
-       rlim_t soft, hard;
+       rlim_t soft = 0, hard = 0;
        int found = 0;
 
        if (ops && *ops == '=')