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

Re: [Xen-devel] [RFC XEN PATCH v4 03/41] hvmloader/util: do not compare characters after '\0' in strncmp



On Thu, 2017-12-07 at 18:09 +0800, Haozhong Zhang wrote:
> ... to make its behavior the same as C standard (e.g., C99 and C11).
> 
> Signed-off-by: Haozhong Zhang <haozhong.zhang@xxxxxxxxx>
> ---
> Cc: Jan Beulich <jbeulich@xxxxxxxx>
> Cc: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
> Cc: Ian Jackson <ian.jackson@xxxxxxxxxxxxx>
> Cc: Wei Liu <wei.liu2@xxxxxxxxxx>
> ---
>  tools/firmware/hvmloader/util.c | 7 +++++++
>  1 file changed, 7 insertions(+)
> 
> diff --git a/tools/firmware/hvmloader/util.c
> b/tools/firmware/hvmloader/util.c
> index 0c3f2d24cd..76a61ee052 100644
> --- a/tools/firmware/hvmloader/util.c
> +++ b/tools/firmware/hvmloader/util.c
> @@ -141,9 +141,16 @@ int strcmp(const char *cs, const char *ct)
>  int strncmp(const char *s1, const char *s2, uint32_t n)
>  {
>      uint32_t ctr;
> +
>      for (ctr = 0; ctr < n; ctr++)
> +    {
>          if (s1[ctr] != s2[ctr])
>              return (int)(s1[ctr] - s2[ctr]);
> +
> +        if (!s1[ctr])

Coding style, but, the original code above has issue too.
Besides this, Reviewed-by: Chao Peng <chao.p.peng@xxxxxxxxxxxxxxx>

> +            break;
> +    }
> +
>      return 0;
>  }
>  

_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxxx
https://lists.xenproject.org/mailman/listinfo/xen-devel

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.