Re: [PATCH 4/5] test_printf: Append '|' more efficiently

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

 



On Wed, Oct 13, 2021 at 2:33 AM Matthew Wilcox (Oracle)
<willy@xxxxxxxxxxxxx> wrote:
>
> Instead of calling snprintf(), just append '|' by hand.
>
> Signed-off-by: Matthew Wilcox (Oracle) <willy@xxxxxxxxxxxxx>
> ---
>  lib/test_printf.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/lib/test_printf.c b/lib/test_printf.c
> index 60cdf4ba991e..662c3785aa57 100644
> --- a/lib/test_printf.c
> +++ b/lib/test_printf.c
> @@ -623,9 +623,9 @@ page_flags_test(int section, int node, int zone, int last_cpupid,
>                 if (!pft[i].width)
>                         continue;
>
> -               if (append) {
> -                       snprintf(cmp_buf + size, BUF_SIZE - size, "|");
> -                       size = strlen(cmp_buf);
> +               if (append && size < BUF_SIZE) {

Should it be:
                    if (append && size < BUF_SIZE - 1)
?


> +                       cmp_buf[size++] = '|';
> +                       cmp_buf[size] = '\0';
>                 }
>
>                 page_flags |= (values[i] & pft[i].mask) << pft[i].shift;
> --
> 2.32.0
>


-- 
Thanks
Yafang




[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Bugtraq]     [Linux OMAP]     [Linux MIPS]     [eCos]     [Asterisk Internet PBX]     [Linux API]

  Powered by Linux