This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: [PATCH] Small fix to HP timing printing
- From: Adhemerval Zanella <adhemerval dot zanella at linaro dot org>
- To: libc-alpha at sourceware dot org
- Date: Tue, 3 Sep 2019 10:41:09 -0300
- Subject: Re: [PATCH] Small fix to HP timing printing
- References: <bcb6fbc7-a6a1-234e-fce4-0400e7542ebf@mentor.com>
On 03/09/2019 09:55, Chung-Lin Tang wrote:
> Hi, when developing my dynamic linker DSO sorting patch [1], and measuring its
> cycle performance, I found a small error in the HP_TIMING_PRINT trailing zero
> setting; the '\0' should be set at MIN(Len,string length), instead of always
> at the 'Len' position. Encountered some weirdness in printing counter results
> because of this.
>
> Okay for master?
>
> [1] https://sourceware.org/ml/libc-alpha/2019-07/msg00472.html
> https://sourceware.org/ml/libc-alpha/2019-07/msg00473.html
>
> Thanks,
> Chung-Lin
>
> * sysdeps/generic/hp-timing-common.h (HP_TIMING_PRINT): Correct position
> of string null termination.
LGTM, thanks.
Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
>
> hp-timing-common.h.patch
>
> diff --git a/sysdeps/generic/hp-timing-common.h b/sysdeps/generic/hp-timing-common.h
> index 8749d25647..1fc92d1bd7 100644
> --- a/sysdeps/generic/hp-timing-common.h
> +++ b/sysdeps/generic/hp-timing-common.h
> @@ -56,5 +56,5 @@
> char *__cp = _itoa ((Val), __buf + sizeof (__buf), 10, 0); \
> size_t __cp_len = MIN (__buf + sizeof (__buf) - __cp, __len); \
> memcpy (__dest, __cp, __cp_len); \
> - __dest[__len - 1] = '\0'; \
> + __dest[__cp_len - 1] = '\0'; \
> } while (0)
>