Commit caed8eba authored by Jakub Kicinski's avatar Jakub Kicinski
Browse files

selftests: kselftest_harness: fix Clang warning about zero-length format



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: default avatarSean Christopherson <seanjc@google.com>
Link: https://lore.kernel.org/all/20240409224256.1581292-1-seanjc@google.com


Fixes: 378193ef ("selftests: kselftest_harness: let PASS / FAIL provide diagnostic")
Tested-by: default avatarSean Christopherson <seanjc@google.com>
Reviewed-by: default avatarMuhammad Usama Anjum <usama.anjum@collabora.com>
Link: https://lore.kernel.org/r/20240416151048.1682352-1-kuba@kernel.org


Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parent 0f022d32
Loading
Loading
Loading
Loading
+6 −4
Original line number Diff line number Diff line
@@ -288,16 +288,18 @@ 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;
	if (msg) {
		va_start(args, msg);
		vprintf(msg, args);
	printf("\n");
		va_end(args);
	}
	printf("\n");
}

static inline int ksft_exit_pass(void)
{
+1 −1
Original line number Diff line number Diff line
@@ -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)