diff mbox series

[v2,1/2] lib/test_string.c: Make definition less dense

Message ID 20230228184245.1585775-1-bjorn@kernel.org (mailing list archive)
State Superseded
Headers show
Series [v2,1/2] lib/test_string.c: Make definition less dense | expand

Checks

Context Check Description
conchuod/cover_letter success Single patches do not need cover letters
conchuod/tree_selection success Guessed tree name to be for-next
conchuod/fixes_present success Fixes tag not required for -next series
conchuod/maintainers_pattern success MAINTAINERS pattern errors before the patch: 1 and now 1
conchuod/verify_signedoff success Signed-off-by tag matches author and committer
conchuod/kdoc success Errors and warnings before: 0 this patch: 0
conchuod/build_rv64_clang_allmodconfig success Errors and warnings before: 0 this patch: 0
conchuod/module_param success Was 0 now: 0
conchuod/build_rv64_gcc_allmodconfig success Errors and warnings before: 0 this patch: 0
conchuod/alphanumeric_selects success Out of order selects before the patch: 728 and now 728
conchuod/build_rv32_defconfig success Build OK
conchuod/dtb_warn_rv64 success Errors and warnings before: 11 this patch: 11
conchuod/header_inline success No static functions without inline keyword in header files
conchuod/checkpatch success total: 0 errors, 0 warnings, 0 checks, 24 lines checked
conchuod/source_inline success Was 0 now: 0
conchuod/build_rv64_nommu_k210_defconfig success Build OK
conchuod/verify_fixes success No Fixes tag
conchuod/build_rv64_nommu_virt_defconfig success Build OK

Commit Message

Björn Töpel Feb. 28, 2023, 6:42 p.m. UTC
From: Björn Töpel <bjorn@rivosinc.com>

Checkpatch seems to have trouble making sense of the situation when
struct definitions, variable definitions, and __initconst marking is
done in one go.

Let's be nicer to checkpatch, and move the struct definition out,
which removes the error.

Signed-off-by: Björn Töpel <bjorn@rivosinc.com>
---
 lib/test_string.c | 16 +++++++++-------
 1 file changed, 9 insertions(+), 7 deletions(-)


base-commit: ae3419fbac845b4d3f3a9fae4cc80c68d82cdf6e

Comments

Andy Shevchenko Feb. 28, 2023, 7:03 p.m. UTC | #1
On Tue, Feb 28, 2023 at 8:42 PM Björn Töpel <bjorn@kernel.org> wrote:
>
> From: Björn Töpel <bjorn@rivosinc.com>
>
> Checkpatch seems to have trouble making sense of the situation when
> struct definitions, variable definitions, and __initconst marking is
> done in one go.
>
> Let's be nicer to checkpatch, and move the struct definition out,
> which removes the error.

Not that I'm against the patch, but how hard is it to fix the checkpatch?

In case you go this way with a patch, it probably makes sense to move
test data out of the function as well with something like
strspn_test_data name.
Björn Töpel Feb. 28, 2023, 7:41 p.m. UTC | #2
Andy Shevchenko <andy.shevchenko@gmail.com> writes:

> On Tue, Feb 28, 2023 at 8:42 PM Björn Töpel <bjorn@kernel.org> wrote:
>>
>> From: Björn Töpel <bjorn@rivosinc.com>
>>
>> Checkpatch seems to have trouble making sense of the situation when
>> struct definitions, variable definitions, and __initconst marking is
>> done in one go.
>>
>> Let's be nicer to checkpatch, and move the struct definition out,
>> which removes the error.
>
> Not that I'm against the patch, but how hard is it to fix the checkpatch?

Uhm, good one. I'll have a look (the .pl scared me off).
diff mbox series

Patch

diff --git a/lib/test_string.c b/lib/test_string.c
index c5cb92fb710e..550229084c41 100644
--- a/lib/test_string.c
+++ b/lib/test_string.c
@@ -179,15 +179,17 @@  static __init int strnchr_selftest(void)
 	return 0;
 }
 
+struct strspn_test {
+	const char str[16];
+	const char accept[16];
+	const char reject[16];
+	unsigned int a;
+	unsigned int r;
+};
+
 static __init int strspn_selftest(void)
 {
-	static const struct strspn_test {
-		const char str[16];
-		const char accept[16];
-		const char reject[16];
-		unsigned a;
-		unsigned r;
-	} tests[] __initconst = {
+	static const struct strspn_test tests[] __initconst = {
 		{ "foobar", "", "", 0, 6 },
 		{ "abba", "abc", "ABBA", 4, 4 },
 		{ "abba", "a", "b", 1, 1 },