From: Darrick J. Wong Date: Thu, 7 Dec 2017 03:24:49 +0000 (-0600) Subject: libxfs: libxfs_nproc should never return negative numbers X-Git-Tag: v4.15.0-rc1~80 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=30a757b7ed5a5c71b22377b445ae0aa77fcaeca5;p=thirdparty%2Fxfsprogs-dev.git libxfs: libxfs_nproc should never return negative numbers 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 Reviewed-by: Eric Sandeen Signed-off-by: Eric Sandeen --- diff --git a/libxfs/init.c b/libxfs/init.c index a007b3bec..302f088dd 100644 --- a/libxfs/init.c +++ b/libxfs/init.c @@ -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