libxfs: libxfs_nproc should never return negative numbers
PATCH 1/1 libxfs: libxfs_nproc should never return negative numbers
From: Darrick J. Wong <[email protected]>
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 <[email protected]>
--- libxfs/init.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
libxfs/init.c +6 -1
@@ -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
Quoted 8 lines · Darrick J. Wong
From: Darrick J. Wong <[email protected]>
Prevent
libxfs_nprocfrom returning a negative/zero CPU count ifplatform_nprochappens to error out.Fixes-coverity-id: 1425909
Fixes-coverity-id: 1425910
Fixes-coverity-id: 1425913
3 birds, one stone, probably worth it :)
Reviewed-by Eric Sandeen <[email protected]>
Quoted 24 lines
Signed-off-by Darrick J. Wong <[email protected]>--- libxfs/init.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)libxfs/init.c +6
-1@@ -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