Re: [PATCH 3/3] builtin/apply: tighten (dis)similarity index parsing

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

 



John Keeping <john@xxxxxxxxxxxxx> writes:

> diff --git a/builtin/apply.c b/builtin/apply.c
> index 6c11e8b..4745e75 100644
> --- a/builtin/apply.c
> +++ b/builtin/apply.c
> @@ -1041,15 +1041,17 @@ static int gitdiff_renamedst(const char *line, struct patch *patch)
>  
>  static int gitdiff_similarity(const char *line, struct patch *patch)
>  {
> -	if ((patch->score = strtoul(line, NULL, 10)) == ULONG_MAX)
> -		patch->score = 0;
> +	unsigned long val = strtoul(line, NULL, 10);
> +	if (val <= 100)
> +		patch->score = val;
>  	return 0;
>  }
>  
>  static int gitdiff_dissimilarity(const char *line, struct patch *patch)
>  {
> -	if ((patch->score = strtoul(line, NULL, 10)) == ULONG_MAX)
> -		patch->score = 0;
> +	unsigned long val = strtoul(line, NULL, 10);
> +	if (val <= 100)
> +		patch->score = val;
>  	return 0;
>  }

This makes sort of sense; .score is used only for display and not
for making any decision, so as long as you know it is initialized to
zero when the call to this function is made, it should be OK.

Thanks.
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]