lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <dffe0854-b242-472f-aaa6-6281721d95d5@collabora.com>
Date: Tue, 16 Apr 2024 20:24:29 +0500
From: Muhammad Usama Anjum <usama.anjum@...labora.com>
To: Jakub Kicinski <kuba@...nel.org>, davem@...emloft.net
Cc: Muhammad Usama Anjum <usama.anjum@...labora.com>, netdev@...r.kernel.org,
 edumazet@...gle.com, pabeni@...hat.com,
 Sean Christopherson <seanjc@...gle.com>, shuah@...nel.org,
 keescook@...omium.org, linux-kselftest@...r.kernel.org, llvm@...ts.linux.dev
Subject: Re: [PATCH net] selftests: kselftest_harness: fix Clang warning about
 zero-length format

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@...gle.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@...nel.org>
Reviewed-by: Muhammad Usama Anjum <usama.anjum@...labora.com>

> ---
> ---
> CC: shuah@...nel.org
> CC: keescook@...omium.org
> CC: usama.anjum@...labora.com
> CC: linux-kselftest@...r.kernel.org
> CC: llvm@...ts.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

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ