Linux Kernel Selftest development
 help / color / mirror / Atom feed
From: Shuah Khan <skhan@linuxfoundation.org>
To: Yan Zhen <yanzhen@vivo.com>, shuah@kernel.org
Cc: linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org,
	opensource.kernel@vivo.com,
	Shuah Khan <skhan@linuxfoundation.org>
Subject: Re: [PATCH v1] selftests:tdx:Use min macro
Date: Thu, 22 Aug 2024 00:35:35 -0600	[thread overview]
Message-ID: <875a6d1b-31ba-497f-90bd-a36c18f015a7@linuxfoundation.org> (raw)
In-Reply-To: <20240822044630.1267500-1-yanzhen@vivo.com>

On 8/21/24 22:46, Yan Zhen wrote:
> Using the min macro is usually more intuitive and readable.

How did you find this problem?

> 
> Signed-off-by: Yan Zhen <yanzhen@vivo.com>
> ---
>   tools/testing/selftests/tdx/tdx_guest_test.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/tools/testing/selftests/tdx/tdx_guest_test.c b/tools/testing/selftests/tdx/tdx_guest_test.c
> index 81d8cb88e..d7ddf5307 100644
> --- a/tools/testing/selftests/tdx/tdx_guest_test.c
> +++ b/tools/testing/selftests/tdx/tdx_guest_test.c
> @@ -118,7 +118,7 @@ static void print_array_hex(const char *title, const char *prefix_str,
>   	printf("\t\t%s", title);
>   
>   	for (j = 0; j < len; j += rowsize) {
> -		line_len = rowsize < (len - j) ? rowsize : (len - j);
> +		line_len = min((len - j), rowsize);
>   		printf("%s%.8x:", prefix_str, j);
>   		for (i = 0; i < line_len; i++)
>   			printf(" %.2x", ptr[j + i]);

Did you compile this patch and test it? I am seeing warnings during
build.

tdx_guest_test.c:121:28: warning: implicit declaration of function ‘min’ [-Wimplicit-function-declaration]
   121 |                 line_len = min((len - j), rowsize);
       |                            ^~~

thanks,
-- Shuah

  reply	other threads:[~2024-08-22  6:35 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-08-22  4:46 [PATCH v1] selftests:tdx:Use min macro Yan Zhen
2024-08-22  6:35 ` Shuah Khan [this message]
2024-08-27 12:34 ` kernel test robot

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=875a6d1b-31ba-497f-90bd-a36c18f015a7@linuxfoundation.org \
    --to=skhan@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=opensource.kernel@vivo.com \
    --cc=shuah@kernel.org \
    --cc=yanzhen@vivo.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox