public inbox for llvm@lists.linux.dev
 help / color / mirror / Atom feed
From: Muhammad Usama Anjum <usama.anjum@collabora.com>
To: Jakub Kicinski <kuba@kernel.org>, davem@davemloft.net
Cc: Muhammad Usama Anjum <usama.anjum@collabora.com>,
	netdev@vger.kernel.org, edumazet@google.com, pabeni@redhat.com,
	Sean Christopherson <seanjc@google.com>,
	shuah@kernel.org, keescook@chromium.org,
	linux-kselftest@vger.kernel.org, llvm@lists.linux.dev
Subject: Re: [PATCH net] selftests: kselftest_harness: fix Clang warning about zero-length format
Date: Tue, 16 Apr 2024 20:24:29 +0500	[thread overview]
Message-ID: <dffe0854-b242-472f-aaa6-6281721d95d5@collabora.com> (raw)
In-Reply-To: <20240416151048.1682352-1-kuba@kernel.org>

On 4/16/24 8:10 PM, Jakub Kicinski wrote:
> Apparently it's more legal to pass the format as NULL, than
> it is to use an empty string. Clang complains about empty
> formats:
> 
> ./../kselftest_harness.h:1207:30: warning: format string is empty
> [-Wformat-zero-length]
>  1207 |            diagnostic ? "%s" : "", diagnostic);
>       |                                 ^~
> 1 warning generated.
> 
> Reported-by: Sean Christopherson <seanjc@google.com>
> Link: https://lore.kernel.org/all/20240409224256.1581292-1-seanjc@google.com
> Fixes: 378193eff339 ("selftests: kselftest_harness: let PASS / FAIL provide diagnostic")
> Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Reviewed-by: Muhammad Usama Anjum <usama.anjum@collabora.com>

> ---
> ---
> CC: shuah@kernel.org
> CC: keescook@chromium.org
> CC: usama.anjum@collabora.com
> CC: linux-kselftest@vger.kernel.org
> CC: llvm@lists.linux.dev
> ---
>  tools/testing/selftests/kselftest.h         | 10 ++++++----
>  tools/testing/selftests/kselftest_harness.h |  2 +-
>  2 files changed, 7 insertions(+), 5 deletions(-)
> 
> diff --git a/tools/testing/selftests/kselftest.h b/tools/testing/selftests/kselftest.h
> index 541bf192e30e..4eca3fd1292c 100644
> --- a/tools/testing/selftests/kselftest.h
> +++ b/tools/testing/selftests/kselftest.h
> @@ -288,15 +288,17 @@ void ksft_test_result_code(int exit_code, const char *test_name,
>  	}
>  
>  	/* Docs seem to call for double space if directive is absent */
> -	if (!directive[0] && msg[0])
> +	if (!directive[0] && msg)
>  		directive = " #  ";
>  
> -	va_start(args, msg);
>  	printf("%s %u %s%s", tap_code, ksft_test_num(), test_name, directive);
>  	errno = saved_errno;
> -	vprintf(msg, args);
> +	if (msg) {
> +		va_start(args, msg);
> +		vprintf(msg, args);
> +		va_end(args);
> +	}
>  	printf("\n");
> -	va_end(args);
>  }
>  
>  static inline int ksft_exit_pass(void)
> diff --git a/tools/testing/selftests/kselftest_harness.h b/tools/testing/selftests/kselftest_harness.h
> index 4fd735e48ee7..adb15cae79ab 100644
> --- a/tools/testing/selftests/kselftest_harness.h
> +++ b/tools/testing/selftests/kselftest_harness.h
> @@ -1202,7 +1202,7 @@ void __run_test(struct __fixture_metadata *f,
>  		diagnostic = "unknown";
>  
>  	ksft_test_result_code(t->exit_code, test_name,
> -			      diagnostic ? "%s" : "", diagnostic);
> +			      diagnostic ? "%s" : NULL, diagnostic);
>  }
>  
>  static int test_harness_run(int argc, char **argv)

-- 
BR,
Muhammad Usama Anjum

  parent reply	other threads:[~2024-04-16 15:24 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-04-16 15:10 [PATCH net] selftests: kselftest_harness: fix Clang warning about zero-length format Jakub Kicinski
2024-04-16 15:23 ` Sean Christopherson
2024-04-16 15:24 ` Muhammad Usama Anjum [this message]
2024-04-18  2:10 ` patchwork-bot+netdevbpf

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=dffe0854-b242-472f-aaa6-6281721d95d5@collabora.com \
    --to=usama.anjum@collabora.com \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=keescook@chromium.org \
    --cc=kuba@kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=llvm@lists.linux.dev \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=seanjc@google.com \
    --cc=shuah@kernel.org \
    /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