Message ID | 20171206234917.GM4910@magnolia (mailing list archive) |
---|---|
State | Accepted |
Headers | show |
On 12/6/17 5:49 PM, Darrick J. Wong wrote: > From: Darrick J. Wong <darrick.wong@oracle.com> > > 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 3 birds, one stone, probably worth it :) Reviewed-by: Eric Sandeen <sandeen@redhat.com> > Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com> > --- > libxfs/init.c | 7 ++++++- > 1 file changed, 6 insertions(+), 1 deletion(-) > > diff --git a/libxfs/init.c b/libxfs/init.c > index a007b3b..302f088 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 > -- To unsubscribe from this list: send the line "unsubscribe linux-xfs" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
diff --git a/libxfs/init.c b/libxfs/init.c index a007b3b..302f088 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