John Keeping <j...@keeping.me.uk> 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 majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to