Resolve Macro Expansion Warning in nx_huge_pages_test.c
PATCH 1/1 Resolve Macro Expansion Warning in nx_huge_pages_test.c
From: angquan yu <[email protected]>
This commit fixes a compiler warning in the file x86_64/nx_huge_pages_test.c, which was caused by improper macro expansion of '__TEST_REQUIRE'.
Warning addressed:
- The warning was triggered by the expansion of the '__TEST_REQUIRE' macro, indicating a potential issue in how the macro was being used or expanded.
Changes made:
- Modified the usage of the '__TEST_REQUIRE' macro to ensure proper expansion. This involved explicitly passing the expected magic token (MAGIC_TOKEN) and a descriptive error message to the macro.
- The fix enhances clarity in the macro usage and ensures that the compiler correctly interprets the intended logic, thereby resolving the warning.
--- tools/testing/selftests/kvm/x86_64/nx_huge_pages_test.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
tools/testing/selftests/kvm/x86_64/nx_huge_pages_test.c +2 -1
@@ -259,7 +259,8 @@ int main(int argc, char **argv)__TEST_REQUIRE (token ==MAGIC_TOKEN ,"This test must be run with the magic token %d.\n" "This is done by nx_huge_pages_test.sh, which\n" -"also handles environment setup for the test." ); +"also handles environment setup for the test." , +MAGIC_TOKEN );run_test (reclaim_period_ms, false, reboot_permissions);run_test (reclaim_period_ms, true, reboot_permissions);
Signature · 1 line
2.39.2
Sean Christopherson
reviewerFor the shortlog, specify the scope/domain/namespace of the patch. For KVM selftests, that's "KVM: selftests:". And ideally, describe the impact of the change in a more conversational way, as opposed to stating the literal effect of the patch. Stating that the patch fixes a warning is obviously accurate, but it doesn't provide any insight as to the severity of the issue, i.e. what's actually broken and being fixed.
E.g.
KVM: selftests: Actually print out magic token in NX hugepages skip message
Quoted 11 lines · angquan yu
From: angquan yu <[email protected]>
This commit fixes a compiler warning in the file
x86_64/nx_huge_pages_test.c, which was caused by improper macro expansion of '__TEST_REQUIRE'.Warning addressed:
- The warning was triggered by the expansion of the '__TEST_REQUIRE' macro, indicating a potential issue in how the macro was being used or expanded.
Quoted 7 lines
Changes made:
- Modified the usage of the '__TEST_REQUIRE' macro to ensure proper expansion. This involved explicitly passing the expected magic token (MAGIC_TOKEN) and a descriptive error message to the macro.
- The fix enhances clarity in the macro usage and ensures that the compiler correctly interprets the intended logic, thereby resolving the warning.
Fixing warnings is nice, but warnings are a means to an end, i.e. they identify things that *might* be actual problems. The real issue is that the test will spit out garbage instead of the magic number.
All that said, applied to kvm-x86 selftests, with a heavily rewritten shortlog and changelog (I had the same fix locally, so more or less just grabbed what I had already written).
Thanks!
[1/1] KVM: selftests: Actually print out magic token in NX hugepages skip message
https://github.com/kvm-x86/linux/commit/3b99d46a1170
Quoted 23 lines
Signed-off-by angquan yu <[email protected]>--- tools/testing/selftests/kvm/x86_64/nx_huge_pages_test.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)tools/testing/selftests/kvm/x86_64/nx_huge_pages_test.c +2
-1@@ -259,7 +259,8 @@ int main(int argc, char **argv)__TEST_REQUIRE (token ==MAGIC_TOKEN ,"This test must be run with the magic token %d.\n" "This is done by nx_huge_pages_test.sh, which\n" -"also handles environment setup for the test." ); +"also handles environment setup for the test." , +MAGIC_TOKEN );run_test (reclaim_period_ms, false, reboot_permissions);run_test (reclaim_period_ms, true, reboot_permissions);Signature · 1 line
2.39.2