]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/commitdiff
libxfs: libxfs_nproc should never return negative numbers
authorDarrick J. Wong <darrick.wong@oracle.com>
Thu, 7 Dec 2017 03:24:49 +0000 (21:24 -0600)
committerEric Sandeen <sandeen@redhat.com>
Thu, 7 Dec 2017 03:24:49 +0000 (21:24 -0600)
Prevent libxfs_nproc from returning a negative/zero CPU count if
platform_nproc happens to error out.

Fixes-coverity-id: 1425909
Fixes-coverity-id: 1425910
Fixes-coverity-id: 1425913
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
libxfs/init.c

index a007b3beca53cf985a664f1e96923c4ef1335638..302f088dde2ce5597e153ef343fbcb7cfef7d241 100644 (file)
@@ -910,7 +910,12 @@ libxfs_report(FILE *fp)
 int
 libxfs_nproc(void)
 {
-       return platform_nproc();
+       int     nr;
+
+       nr = platform_nproc();
+       if (nr < 1)
+               nr = 1;
+       return nr;
 }
 
 unsigned long