Re: [PATCH 02/12] libfrog: cvt_u64 should use strtoull, not strtoll

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

 



On 6/20/19 11:49 AM, Darrick J. Wong wrote:
> From: Darrick J. Wong <darrick.wong@xxxxxxxxxx>
> 
> cvt_u64 converts a string to an unsigned 64-bit number, so it should use
> strtoull, not strtoll because we don't want negative numbers here.
> 
> Signed-off-by: Darrick J. Wong <darrick.wong@xxxxxxxxxx>

Reviewed-by: Eric Sandeen <sandeen@xxxxxxxxxx>

> ---
>  libfrog/convert.c |   10 +++++-----
>  1 file changed, 5 insertions(+), 5 deletions(-)
> 
> 
> diff --git a/libfrog/convert.c b/libfrog/convert.c
> index 62397507..8d4d4077 100644
> --- a/libfrog/convert.c
> +++ b/libfrog/convert.c
> @@ -105,14 +105,14 @@ cvt_s16(
>   */
>  uint64_t
>  cvt_u64(
> -	char		*s,
> -	int		base)
> +	char			*s,
> +	int			base)
>  {
> -	long long	i;
> -	char		*sp;
> +	unsigned long long	i;
> +	char			*sp;
>  
>  	errno = 0;
> -	i = strtoll(s, &sp, base);
> +	i = strtoull(s, &sp, base);
>  	/*
>  	 * If the input would over or underflow, return the clamped
>  	 * value and let the user check errno.  If we went all the
> 



[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