Re: [PATCH] libxfs: libxfs_nproc should never return negative numbers

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 12/6/17 5:49 PM, Darrick J. Wong wrote:
> From: Darrick J. Wong <darrick.wong@xxxxxxxxxx>
> 
> 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@xxxxxxxxxx>

> Signed-off-by: Darrick J. Wong <darrick.wong@xxxxxxxxxx>
> ---
>  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@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [XFS Filesystem Development (older mail)]     [Linux Filesystem Development]     [Linux Audio Users]     [Yosemite Trails]     [Linux Kernel]     [Linux RAID]     [Linux SCSI]


  Powered by Linux