diff options
author | Darrick J. Wong <darrick.wong@oracle.com> | 2017-12-06 21:24:49 -0600 |
---|---|---|
committer | Eric Sandeen <sandeen@redhat.com> | 2017-12-06 21:24:49 -0600 |
commit | 30a757b7ed5a5c71b22377b445ae0aa77fcaeca5 (patch) | |
tree | 1ba61676e675224e3a673576be554bef8c05e09c | |
parent | 4eee66c596363e9f98ec7098dffd320e1bca8076 (diff) | |
download | xfsprogs-dev-30a757b7ed5a5c71b22377b445ae0aa77fcaeca5.tar.gz |
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 <darrick.wong@oracle.com>
Reviewed-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
-rw-r--r-- | libxfs/init.c | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/libxfs/init.c b/libxfs/init.c index a007b3beca..302f088dde 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 |