Skip to contentSkip to conversation

RFC: Add clang-format and kerneldoc check

PATCH In review Nico Boehr 3 participants 24 messages Nov 6, 2023 – Nov 22, 2023

Subsystems (4)
lore
Share & tools
lore

Nico Boehr

author
#0 lore raw

cover RFC: Add clang-format and kerneldoc check

It is important that we have a consistent formatting of our source code and comments in kvm-unit-tests.

Yet, it's not always easy since tiny formatting mistakes are hard to spot for reviewers. Respinning patches because of these issues can also be frustrating for contributors.

This series is a RFC suggestion on how the situation could be improved for kvm-unit-tests.

It adds a clang-format file, mostly based on the one already present in the kernel. A new "make format" target makes it easy to properly format the source. If maintainers want, they could even re-format the source code of ther arch to ensure a consistent code formatting, but this is entirely optional. I am also happy to move the "make format" into arch-specific code if requested.

Additionally, I noticed that there is quite inconsistent use of kernel-doc comments in the code. Add a respective check command and fix the existing issues.

Nico Boehr (10):
make: add target to check kernel-doc comments
powerpc: properly format non-kernel-doc comments
lib: s390x: cpacf: move kernel-doc comment to correct function
s390x: properly format non-kernel-doc comments
s390x: ensure kernel-doc parameters are properly formated
x86: properly format non-kernel-doc comments
s390x: cpumodel: list tcg_fail explicitly
s390x: gs: turn off formatter for inline assembly add clang-format configuration file
add make format

 .clang-format         |  689 +++++++++++
 Makefile              |    6 +
 lib/s390x/asm/cpacf.h |   20 +-
 lib/s390x/interrupt.c |    6 +-
 powerpc/emulator.c    |    2 +-
 powerpc/spapr_hcall.c |    6 +-
 powerpc/spapr_vpa.c   |    4 +-
 s390x/cpumodel.c      |   38 +-
 s390x/gs.c            |   44 +-
 s390x/sclp.c          |   32 +-
 scripts/kernel-doc    | 2526 +++++++++++++++++++++++++++++++++++++++++
 x86/msr.c             |    2 +-
 12 files changed, 3299 insertions(+), 76 deletions(-)
 create mode 100644 .clang-format
 create mode 100755 scripts/kernel-doc
Signature · 1 line
2.41.0
author
#1 lore raw

PATCH 1/10 make: add target to check kernel-doc comments

When we have a kernel-doc comment, it should be properly formatted. Since this is a task that can be easily automated, add a new target which checks all comments for proper kernel-doc formatting.

The kernel-doc script is copied as-is from the Linux kernel.

---
 Makefile           |    3 +
 scripts/kernel-doc | 2526 ++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 2529 insertions(+)
 create mode 100755 scripts/kernel-doc
Makefile +3 -0
index 101c02803228..602910dda11b 100644
@@ -144,3 +144,6 @@ cscope:
 .PHONY: tags
 tags:
 	ctags -R
+
+check-kerneldoc:
+	find . -name '*.[ch]' -exec scripts/kernel-doc -none {} +
scripts/kernel-doc new file +2526 -0

2,526 lines not on this page · raw message

Signature · 1 line
2.41.0
Reviewed-by on v1 1/10
#2 lore raw

Re: [kvm-unit-tests PATCH v1 01/10] make: add target to check kernel-doc comments

Quoted 4 lines · Nico Boehr

When we have a kernel-doc comment, it should be properly formatted. Since this is a task that can be easily automated, add a new target which checks all comments for proper kernel-doc formatting.

Quoted 8 lines

The kernel-doc script is copied as-is from the Linux kernel.

---
  Makefile           |    3 +
  scripts/kernel-doc | 2526 ++++++++++++++++++++++++++++++++++++++++++++
  2 files changed, 2529 insertions(+)

create mode 100755 scripts/kernel-doc

author
#3 lore raw

PATCH 2/10 powerpc: properly format non-kernel-doc comments

In reply to Nico Boehr

These comments do not follow the kernel-doc style, hence they should not start with /**.

---
 powerpc/emulator.c    | 2 +-
 powerpc/spapr_hcall.c | 6 +++---
 powerpc/spapr_vpa.c   | 4 ++--
 3 files changed, 6 insertions(+), 6 deletions(-)
powerpc/emulator.c +1 -1
index 65ae4b65e655..39dd59645368 100644
@@ -71,7 +71,7 @@ static void test_64bit(void)
 	report_prefix_pop();
 }
 
-/**
+/*
  * Test 'Load String Word Immediate' instruction
  */
 static void test_lswi(void)
powerpc/spapr_hcall.c +3 -3
index 0d0f25afe9f6..e9b5300a3912 100644
@@ -16,7 +16,7 @@
 #define H_ZERO_PAGE	(1UL << (63-48))
 #define H_COPY_PAGE	(1UL << (63-49))
 
-/**
+/*
  * Test the H_SET_SPRG0 h-call by setting some values and checking whether
  * the SPRG0 register contains the correct values afterwards
  */
@@ -46,7 +46,7 @@ static void test_h_set_sprg0(int argc, char **argv)
 	       sprg0_orig);
 }
 
-/**
+/*
  * Test the H_PAGE_INIT h-call by using it to clear and to copy a page, and
  * by checking for the correct values in the destination page afterwards
  */
@@ -97,7 +97,7 @@ static int h_random(uint64_t *val)
 	return r3;
 }
 
-/**
+/*
  * Test H_RANDOM by calling it a couple of times to check whether all bit
  * positions really toggle (there should be no "stuck" bits in the output)
  */
powerpc/spapr_vpa.c +2 -2
index 5586eb8d3341..6a3fe5e3f974 100644
@@ -53,7 +53,7 @@ static void print_vpa(struct vpa *vpa)
 #define SUBFUNC_REGISTER	(1ULL << 45)
 #define SUBFUNC_DEREGISTER	(5ULL << 45)
 
-/**
+/*
  * Test the H_REGISTER_VPA h-call register/deregister calls.
  */
 static void test_register_vpa(void)
@@ -111,7 +111,7 @@ static void test_register_vpa(void)
 	report_prefix_pop();
 }
 
-/**
+/*
  * Test some VPA fields.
  */
 static void test_vpa(void)
Signature · 1 line
2.41.0
#4 lore raw

Re: [kvm-unit-tests PATCH v1 02/10] powerpc: properly format non-kernel-doc comments

Quoted 15 lines · On Mon, 6 Nov 2023 13:50:58 +0100 Nico Boehr <[email protected]> wrote:

These comments do not follow the kernel-doc style, hence they should not start with /**.

---
 powerpc/emulator.c    | 2 +-
 powerpc/spapr_hcall.c | 6 +++---
 powerpc/spapr_vpa.c   | 4 ++--
 3 files changed, 6 insertions(+), 6 deletions(-)
powerpc/emulator.c +0 -0
index 65ae4b65e655..39dd59645368 100644

powerpc/emulator.c static void test_64bit(void) · line 76

Quoted 7 lines
powerpc/emulator.c +1 -1
@@ -71,7 +71,7 @@ static void test_64bit(void)
 	report_prefix_pop();
 }
 
-/**
+/*
  * Test 'Load String Word Immediate' instruction
  */

this should have the name of the function first:
* test_lswi() - Test 'Load String ...

(same for all the other functions here)

Quoted 54 lines
powerpc/emulator.c +0 -0
 static void test_lswi(void)
powerpc/spapr_hcall.c +3 -3
index 0d0f25afe9f6..e9b5300a3912 100644
@@ -16,7 +16,7 @@
 #define H_ZERO_PAGE	(1UL << (63-48))
 #define H_COPY_PAGE	(1UL << (63-49))
 
-/**
+/*
  * Test the H_SET_SPRG0 h-call by setting some values and checking whether
  * the SPRG0 register contains the correct values afterwards
  */
@@ -46,7 +46,7 @@ static void test_h_set_sprg0(int argc, char **argv)
 	       sprg0_orig);
 }
 
-/**
+/*
  * Test the H_PAGE_INIT h-call by using it to clear and to copy a page, and
  * by checking for the correct values in the destination page afterwards
  */
@@ -97,7 +97,7 @@ static int h_random(uint64_t *val)
 	return r3;
 }
 
-/**
+/*
  * Test H_RANDOM by calling it a couple of times to check whether all bit
  * positions really toggle (there should be no "stuck" bits in the output)
  */
powerpc/spapr_vpa.c +2 -2
index 5586eb8d3341..6a3fe5e3f974 100644
@@ -53,7 +53,7 @@ static void print_vpa(struct vpa *vpa)
 #define SUBFUNC_REGISTER	(1ULL << 45)
 #define SUBFUNC_DEREGISTER	(5ULL << 45)
 
-/**
+/*
  * Test the H_REGISTER_VPA h-call register/deregister calls.
  */
 static void test_register_vpa(void)
@@ -111,7 +111,7 @@ static void test_register_vpa(void)
 	report_prefix_pop();
 }
 
-/**
+/*
  * Test some VPA fields.
  */
 static void test_vpa(void)
author
#5 lore raw

Re: [kvm-unit-tests PATCH v1 02/10] powerpc: properly format non-kernel-doc comments

Quoting Claudio Imbrenda (2023-11-06 17:53:16)

Quoted 29 lines
Quoted 15 lines · On Mon, 6 Nov 2023 13:50:58 +0100 Nico Boehr <[email protected]> wrote:

These comments do not follow the kernel-doc style, hence they should not start with /**.

---
 powerpc/emulator.c    | 2 +-
 powerpc/spapr_hcall.c | 6 +++---
 powerpc/spapr_vpa.c   | 4 ++--
 3 files changed, 6 insertions(+), 6 deletions(-)
powerpc/emulator.c +0 -0
index 65ae4b65e655..39dd59645368 100644

powerpc/emulator.c static void test_64bit(void) · line 76

Quoted 7 lines
powerpc/emulator.c +1 -1
@@ -71,7 +71,7 @@ static void test_64bit(void)
      report_prefix_pop();
 }
 
-/**
+/*
  * Test 'Load String Word Immediate' instruction
  */

this should have the name of the function first:
* test_lswi() - Test 'Load String ...

Quoted 1 line

(same for all the other functions here)

Since none of these comments really follow kerneldoc style and are mostly static anyways, the idea was to convert them to non-kerneldoc style, by changing the comment from:
/**

to:
/*

But I am just as fine to make the comments proper kerneldoc style, if we see value in that.

#6 lore raw

Re: [kvm-unit-tests PATCH v1 02/10] powerpc: properly format non-kernel-doc comments

Quoted 37 lines · Nico Boehr

Quoting Claudio Imbrenda (2023-11-06 17:53:16)

Quoted 29 lines
Quoted 15 lines · On Mon, 6 Nov 2023 13:50:58 +0100 Nico Boehr <[email protected]> wrote:

These comments do not follow the kernel-doc style, hence they should not start with /**.

---
  powerpc/emulator.c    | 2 +-
  powerpc/spapr_hcall.c | 6 +++---
  powerpc/spapr_vpa.c   | 4 ++--
  3 files changed, 6 insertions(+), 6 deletions(-)
powerpc/emulator.c +0 -0
index 65ae4b65e655..39dd59645368 100644

powerpc/emulator.c static void test_64bit(void) · line 76

Quoted 7 lines
powerpc/emulator.c +1 -1
@@ -71,7 +71,7 @@ static void test_64bit(void)
       report_prefix_pop();
  }
 
-/**
+/*
   * Test 'Load String Word Immediate' instruction
   */

this should have the name of the function first:
* test_lswi() - Test 'Load String ...

Quoted 1 line

(same for all the other functions here)

Since none of these comments really follow kerneldoc style and are mostly static anyways, the idea was to convert them to non-kerneldoc style, by changing the comment from:
/**

Quoted 5 lines

to:
/*

But I am just as fine to make the comments proper kerneldoc style, if we see value in that.

I think it makes sense to do that for the files in the lib/ folder ... for the other ones, I think it is not really necessary (but it wouldn't hurt either).

Thomas

#7 lore raw

Re: [kvm-unit-tests PATCH v1 02/10] powerpc: properly format non-kernel-doc comments

In reply to Nico Boehr
Quoted 37 lines · On Mon, 06 Nov 2023 18:13:37 +0100 Nico Boehr <[email protected]> wrote:

Quoting Claudio Imbrenda (2023-11-06 17:53:16)

Quoted 29 lines
Quoted 15 lines · On Mon, 6 Nov 2023 13:50:58 +0100 Nico Boehr <[email protected]> wrote:

These comments do not follow the kernel-doc style, hence they should not start with /**.

---
 powerpc/emulator.c    | 2 +-
 powerpc/spapr_hcall.c | 6 +++---
 powerpc/spapr_vpa.c   | 4 ++--
 3 files changed, 6 insertions(+), 6 deletions(-)
powerpc/emulator.c +0 -0
index 65ae4b65e655..39dd59645368 100644

powerpc/emulator.c static void test_64bit(void) · line 76

Quoted 7 lines
powerpc/emulator.c +1 -1
@@ -71,7 +71,7 @@ static void test_64bit(void)
      report_prefix_pop();
 }
 
-/**
+/*
  * Test 'Load String Word Immediate' instruction
  */  

this should have the name of the function first:
* test_lswi() - Test 'Load String ...

Quoted 1 line

(same for all the other functions here)

Since none of these comments really follow kerneldoc style and are mostly static anyways, the idea was to convert them to non-kerneldoc style, by changing the comment from:
/**

Quoted 5 lines

to:
/*

But I am just as fine to make the comments proper kerneldoc style, if we see value in that.

oufff yes sorry I had totally misread that

Reviewed-by on v1 2/10
#8 lore raw

Re: [kvm-unit-tests PATCH v1 02/10] powerpc: properly format non-kernel-doc comments

In reply to Nico Boehr
Quoted 9 lines · Nico Boehr

These comments do not follow the kernel-doc style, hence they should not start with /**.

---
  powerpc/emulator.c    | 2 +-
  powerpc/spapr_hcall.c | 6 +++---
  powerpc/spapr_vpa.c   | 4 ++--
  3 files changed, 6 insertions(+), 6 deletions(-)
author
#9 lore raw

PATCH 3/10 lib: s390x: cpacf: move kernel-doc comment to correct function

In reply to Nico Boehr

The kernel-doc comment seems to describe a different function further at the bottom of the file; move the comment there and adjust the comment accordingly.

---
 lib/s390x/asm/cpacf.h | 20 ++++++++++----------
 1 file changed, 10 insertions(+), 10 deletions(-)
lib/s390x/asm/cpacf.h +10 -10
index 685262b0ff62..378cd5cffcbf 100644
@@ -137,16 +137,6 @@
 
 typedef struct { unsigned char bytes[16]; } cpacf_mask_t;
 
-/**
- * cpacf_query() - check if a specific CPACF function is available
- * @opcode: the opcode of the crypto instruction
- * @func: the function code to test for
- *
- * Executes the query function for the given crypto instruction @opcode
- * and checks if @func is available
- *
- * Returns 1 if @func is available for @opcode, 0 otherwise
- */
 static __always_inline void __cpacf_query(unsigned int opcode, cpacf_mask_t *mask)
 {
 	register unsigned long r0 asm("0") = 0;	/* query function */
@@ -200,6 +190,16 @@ static inline int cpacf_test_func(cpacf_mask_t *mask, unsigned int func)
 	return (mask->bytes[func >> 3] & (0x80 >> (func & 7))) != 0;
 }
 
+/**
+ * cpacf_query_func() - check if a specific CPACF function is available
+ * @opcode: the opcode of the crypto instruction
+ * @func: the function code to test for
+ *
+ * Executes the query function for the given crypto instruction @opcode
+ * and checks if @func is available
+ *
+ * Returns 1 if @func is available for @opcode, 0 otherwise
+ */
 static inline int cpacf_query_func(unsigned int opcode, unsigned int func)
 {
 	cpacf_mask_t mask;
Signature · 1 line
2.41.0
Reviewed-by on v1 3/10
#10 lore raw

Re: [kvm-unit-tests PATCH v1 03/10] lib: s390x: cpacf: move kernel-doc comment to correct function

Quoted 8 lines · Nico Boehr

The kernel-doc comment seems to describe a different function further at the bottom of the file; move the comment there and adjust the comment accordingly.

---
  lib/s390x/asm/cpacf.h | 20 ++++++++++----------
  1 file changed, 10 insertions(+), 10 deletions(-)
author
#11 lore raw

PATCH 4/10 s390x: properly format non-kernel-doc comments

In reply to Nico Boehr

These comments do not follow the kernel-doc style, hence they should not start with /**.

---
 s390x/sclp.c | 32 ++++++++++++++++----------------
 1 file changed, 16 insertions(+), 16 deletions(-)
s390x/sclp.c +16 -16
index 1abb9029f984..ccbaa9136fdb 100644
@@ -32,7 +32,7 @@ static union {
 } sccb_template;
 static uint32_t valid_code;						/* valid command code for READ SCP INFO */
 
-/**
+/*
  * Perform one service call, handling exceptions and interrupts.
  */
 static int sclp_service_call_test(unsigned int command, void *sccb)
@@ -51,7 +51,7 @@ static int sclp_service_call_test(unsigned int command, void *sccb)
 	return cc;
 }
 
-/**
+/*
  * Perform one test at the given address, optionally using the SCCB template,
  * checking for the expected program interrupts and return codes.
  *
@@ -96,7 +96,7 @@ static bool test_one_sccb(uint32_t cmd, uint8_t *addr, uint16_t buf_len, uint64_
 	return true;
 }
 
-/**
+/*
  * Wrapper for test_one_sccb to be used when the template should not be
  * copied and the memory address should not be touched.
  */
@@ -105,7 +105,7 @@ static bool test_one_ro(uint32_t cmd, uint8_t *addr, uint64_t exp_pgm, uint16_t
 	return test_one_sccb(cmd, addr, 0, exp_pgm, exp_rc);
 }
 
-/**
+/*
  * Wrapper for test_one_sccb to set up a simple SCCB template.
  *
  * The parameter sccb_len indicates the value that will be saved in the SCCB
@@ -124,7 +124,7 @@ static bool test_one_simple(uint32_t cmd, uint8_t *addr, uint16_t sccb_len,
 	return test_one_sccb(cmd, addr, buf_len, exp_pgm, exp_rc);
 }
 
-/**
+/*
  * Test SCCB lengths < 8.
  */
 static void test_sccb_too_short(void)
@@ -138,7 +138,7 @@ static void test_sccb_too_short(void)
 	report(len == 8, "SCCB too short");
 }
 
-/**
+/*
  * Test SCCBs that are not 64-bit aligned.
  */
 static void test_sccb_unaligned(void)
@@ -151,7 +151,7 @@ static void test_sccb_unaligned(void)
 	report(offset == 8, "SCCB unaligned");
 }
 
-/**
+/*
  * Test SCCBs whose address is in the lowcore or prefix area.
  */
 static void test_sccb_prefix(void)
@@ -202,7 +202,7 @@ static void test_sccb_prefix(void)
 	set_prefix(prefix);
 }
 
-/**
+/*
  * Test SCCBs that are above 2GB. If outside of memory, an addressing
  * exception is also allowed.
  */
@@ -245,7 +245,7 @@ static void test_sccb_high(void)
 	report(i == len, "SCCB high addresses");
 }
 
-/**
+/*
  * Test invalid commands, both invalid command detail codes and valid
  * ones with invalid command class code.
  */
@@ -275,7 +275,7 @@ static void test_inval(void)
 }
 
 
-/**
+/*
  * Test short SCCBs (but larger than 8).
  */
 static void test_short(void)
@@ -294,7 +294,7 @@ static void test_short(void)
 	report(len == 40, "Insufficient SCCB length (Read CPU info)");
 }
 
-/**
+/*
  * Test SCCB page boundary violations.
  */
 static void test_boundary(void)
@@ -318,7 +318,7 @@ out:
 	report(len > 4096 && offset == 4096, "SCCB page boundary violation");
 }
 
-/**
+/*
  * Test excessively long SCCBs.
  */
 static void test_toolong(void)
@@ -338,7 +338,7 @@ static void test_toolong(void)
 	report(len == 8192, "SCCB bigger than 4k");
 }
 
-/**
+/*
  * Test privileged operation.
  */
 static void test_priv(void)
@@ -354,7 +354,7 @@ static void test_priv(void)
 	report_prefix_pop();
 }
 
-/**
+/*
  * Test addressing exceptions. We need to test SCCB addresses between the
  * end of available memory and 2GB, because after 2GB a specification
  * exception is also allowed.
@@ -393,7 +393,7 @@ out:
 	report(i + maxram >= 0x80000000, "Invalid SCCB address");
 }
 
-/**
+/*
  * Test some bits in the instruction format that are specified to be ignored.
  */
 static void test_instbits(void)
@@ -422,7 +422,7 @@ static void test_instbits(void)
 	report(cc == 0, "Instruction format ignored bits");
 }
 
-/**
+/*
  * Find a valid READ INFO command code; not all codes are always allowed, and
  * probing should be performed in the right order.
  */
Signature · 1 line
2.41.0
#12 lore raw

Re: [kvm-unit-tests PATCH v1 04/10] s390x: properly format non-kernel-doc comments

Quoted 13 lines · On Mon, 6 Nov 2023 13:51:00 +0100 Nico Boehr <[email protected]> wrote:

These comments do not follow the kernel-doc style, hence they should not start with /**.

---
 s390x/sclp.c | 32 ++++++++++++++++----------------
 1 file changed, 16 insertions(+), 16 deletions(-)
s390x/sclp.c +0 -0
index 1abb9029f984..ccbaa9136fdb 100644

s390x/sclp.c static union { · line 37

Quoted 7 lines
s390x/sclp.c +1 -1
@@ -32,7 +32,7 @@ static union {
 } sccb_template;
 static uint32_t valid_code;						/* valid command code for READ SCP INFO */
 
-/**
+/*
  * Perform one service call, handling exceptions and interrupts.
  */

* sclp_service_call_test() - Perform ...

(same for all the other functions)

Quoted 136 lines
s390x/sclp.c +15 -15
 static int sclp_service_call_test(unsigned int command, void *sccb)
@@ -51,7 +51,7 @@ static int sclp_service_call_test(unsigned int command, void *sccb)
 	return cc;
 }
 
-/**
+/*
  * Perform one test at the given address, optionally using the SCCB template,
  * checking for the expected program interrupts and return codes.
  *
@@ -96,7 +96,7 @@ static bool test_one_sccb(uint32_t cmd, uint8_t *addr, uint16_t buf_len, uint64_
 	return true;
 }
 
-/**
+/*
  * Wrapper for test_one_sccb to be used when the template should not be
  * copied and the memory address should not be touched.
  */
@@ -105,7 +105,7 @@ static bool test_one_ro(uint32_t cmd, uint8_t *addr, uint64_t exp_pgm, uint16_t
 	return test_one_sccb(cmd, addr, 0, exp_pgm, exp_rc);
 }
 
-/**
+/*
  * Wrapper for test_one_sccb to set up a simple SCCB template.
  *
  * The parameter sccb_len indicates the value that will be saved in the SCCB
@@ -124,7 +124,7 @@ static bool test_one_simple(uint32_t cmd, uint8_t *addr, uint16_t sccb_len,
 	return test_one_sccb(cmd, addr, buf_len, exp_pgm, exp_rc);
 }
 
-/**
+/*
  * Test SCCB lengths < 8.
  */
 static void test_sccb_too_short(void)
@@ -138,7 +138,7 @@ static void test_sccb_too_short(void)
 	report(len == 8, "SCCB too short");
 }
 
-/**
+/*
  * Test SCCBs that are not 64-bit aligned.
  */
 static void test_sccb_unaligned(void)
@@ -151,7 +151,7 @@ static void test_sccb_unaligned(void)
 	report(offset == 8, "SCCB unaligned");
 }
 
-/**
+/*
  * Test SCCBs whose address is in the lowcore or prefix area.
  */
 static void test_sccb_prefix(void)
@@ -202,7 +202,7 @@ static void test_sccb_prefix(void)
 	set_prefix(prefix);
 }
 
-/**
+/*
  * Test SCCBs that are above 2GB. If outside of memory, an addressing
  * exception is also allowed.
  */
@@ -245,7 +245,7 @@ static void test_sccb_high(void)
 	report(i == len, "SCCB high addresses");
 }
 
-/**
+/*
  * Test invalid commands, both invalid command detail codes and valid
  * ones with invalid command class code.
  */
@@ -275,7 +275,7 @@ static void test_inval(void)
 }
 
 
-/**
+/*
  * Test short SCCBs (but larger than 8).
  */
 static void test_short(void)
@@ -294,7 +294,7 @@ static void test_short(void)
 	report(len == 40, "Insufficient SCCB length (Read CPU info)");
 }
 
-/**
+/*
  * Test SCCB page boundary violations.
  */
 static void test_boundary(void)
@@ -318,7 +318,7 @@ out:
 	report(len > 4096 && offset == 4096, "SCCB page boundary violation");
 }
 
-/**
+/*
  * Test excessively long SCCBs.
  */
 static void test_toolong(void)
@@ -338,7 +338,7 @@ static void test_toolong(void)
 	report(len == 8192, "SCCB bigger than 4k");
 }
 
-/**
+/*
  * Test privileged operation.
  */
 static void test_priv(void)
@@ -354,7 +354,7 @@ static void test_priv(void)
 	report_prefix_pop();
 }
 
-/**
+/*
  * Test addressing exceptions. We need to test SCCB addresses between the
  * end of available memory and 2GB, because after 2GB a specification
  * exception is also allowed.
@@ -393,7 +393,7 @@ out:
 	report(i + maxram >= 0x80000000, "Invalid SCCB address");
 }
 
-/**
+/*
  * Test some bits in the instruction format that are specified to be ignored.
  */
 static void test_instbits(void)
@@ -422,7 +422,7 @@ static void test_instbits(void)
 	report(cc == 0, "Instruction format ignored bits");
 }
 
-/**
+/*
  * Find a valid READ INFO command code; not all codes are always allowed, and
  * probing should be performed in the right order.
  */
author
#14 lore raw

PATCH 5/10 s390x: ensure kernel-doc parameters are properly formated

In reply to Nico Boehr

In kernel-doc, parameters names should end in a colon (:). Add them where they are missing.

---
 lib/s390x/interrupt.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
lib/s390x/interrupt.c +3 -3
index 3f993a363ae2..75edcbfecb7d 100644
@@ -61,7 +61,7 @@ uint16_t clear_pgm_int(void)
 
 /**
  * check_pgm_int_code - Check the program interrupt code on the current CPU.
- * @code the expected program interrupt code on the current CPU
+ * @code: the expected program interrupt code on the current CPU
  *
  * Check and report if the program interrupt on the current CPU matches the
  * expected one.
@@ -77,7 +77,7 @@ void check_pgm_int_code(uint16_t code)
 /**
  * register_pgm_cleanup_func - Register a cleanup function for progam
  * interrupts for the current CPU.
- * @f the cleanup function to be registered on the current CPU
+ * @f: the cleanup function to be registered on the current CPU
  *
  * Register a cleanup function to be called at the end of the normal
  * interrupt handling for program interrupts for this CPU.
@@ -92,7 +92,7 @@ void register_pgm_cleanup_func(void (*f)(struct stack_frame_int *))
 /**
  * register_ext_cleanup_func - Register a cleanup function for external
  * interrupts for the current CPU.
- * @f the cleanup function to be registered on the current CPU
+ * @f: the cleanup function to be registered on the current CPU
  *
  * Register a cleanup function to be called at the end of the normal
  * interrupt handling for external interrupts for this CPU.
Signature · 1 line
2.41.0
Reviewed-by on v1 5/10
#15 lore raw

Re: [kvm-unit-tests PATCH v1 05/10] s390x: ensure kernel-doc parameters are properly formated

Quoted 7 lines · Nico Boehr

In kernel-doc, parameters names should end in a colon (:). Add them where they are missing.

---
  lib/s390x/interrupt.c | 6 +++---
  1 file changed, 3 insertions(+), 3 deletions(-)
author
#16 lore raw

PATCH 6/10 x86: properly format non-kernel-doc comments

In reply to Nico Boehr

These comments do not follow the kernel-doc style, hence they should not start with /**.

---
 x86/msr.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
x86/msr.c +1 -1
index 789f23f8de78..3a041fab160a 100644
@@ -6,7 +6,7 @@
 #include "msr.h"
 #include <stdlib.h>
 
-/**
+/*
  * This test allows two modes:
  * 1. Default: the `msr_info' array contains the default test configurations
  * 2. Custom: by providing command line arguments it is possible to test any MSR and value
Signature · 1 line
2.41.0
Reviewed-by on v1 6/10
#17 lore raw

Re: [kvm-unit-tests PATCH v1 06/10] x86: properly format non-kernel-doc comments

Quoted 13 lines · Nico Boehr

These comments do not follow the kernel-doc style, hence they should not start with /**.

---
  x86/msr.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
x86/msr.c +0 -0
index 789f23f8de78..3a041fab160a 100644

x86/msr.c line 12

Quoted 8 lines
x86/msr.c +1 -1
@@ -6,7 +6,7 @@
  #include "msr.h"
  #include <stdlib.h>
 
-/**
+/*
   * This test allows two modes:
   * 1. Default: the `msr_info' array contains the default test configurations
   * 2. Custom: by providing command line arguments it is possible to test any MSR and value
author
#18 lore raw

PATCH 7/10 s390x: cpumodel: list tcg_fail explicitly

In reply to Nico Boehr

This makes the list more readable.

---
 s390x/cpumodel.c | 38 +++++++++++++++++++-------------------
 1 file changed, 19 insertions(+), 19 deletions(-)
s390x/cpumodel.c +19 -19
index 5c0b73e0f9fe..5734312b102d 100644
@@ -84,28 +84,28 @@ static struct {
 	bool expected_tcg_fail;
 } dep[] = {
 	/* from SA22-7832-11 4-98 facility indications */
-	{   4,   3 },
-	{   5,   3 },
-	{   5,   4 },
-	{  19,  18 },
+	{   4,   3, false },
+	{   5,   3, false },
+	{   5,   4, false },
+	{  19,  18, false },
 	{  37,  42, true },  /* TCG does not have DFP and won't get it soon */
-	{  43,  42 },
-	{  73,  49 },
-	{ 134, 129 },
-	{ 135, 129 },
-	{ 139,  25 },
-	{ 139,  28 },
-	{ 146,  76 },
+	{  43,  42, false },
+	{  73,  49, false },
+	{ 134, 129, false },
+	{ 135, 129, false },
+	{ 139,  25, false },
+	{ 139,  28, false },
+	{ 146,  76, false },
 	/* indirectly documented in description */
-	{  78,   8 },  /* EDAT */
+	{  78,   8, false },  /* EDAT */
 	/* new dependencies from gen15 */
-	{  61,  45 },
-	{ 148, 129 },
-	{ 148, 135 },
-	{ 152, 129 },
-	{ 152, 134 },
-	{ 155,  76 },
-	{ 155,  77 },
+	{  61,  45, false },
+	{ 148, 129, false },
+	{ 148, 135, false },
+	{ 152, 129, false },
+	{ 152, 134, false },
+	{ 155,  76, false },
+	{ 155,  77, false },
 };
 
 int main(void)
Signature · 1 line
2.41.0
author
#19 lore raw

PATCH 8/10 s390x: gs: turn off formatter for inline assembly

In reply to Nico Boehr

clang-format does not properly understand the code and aligns the first opening quote on consecutive lines with the last opening quote on the previous line like so:

" some string " CONCATED_WITH_MACRO " continues here "
" weird indent for some reason"

Disable clang-format for this block of code and properly align the indented asm with the opening parenthesis.

---
 s390x/gs.c | 44 +++++++++++++++++++++++---------------------
 1 file changed, 23 insertions(+), 21 deletions(-)
s390x/gs.c +23 -21
index 9ae893eaf89a..7e08c2a78d32 100644
@@ -35,28 +35,30 @@ static inline unsigned long load_guarded(unsigned long *p)
 }
 
 /* guarded-storage event handler and finally it calls gs_handler */
+/* clang-format off */
 extern void gs_handler_asm(void);
-	asm (          ".macro	STGSC	args:vararg\n"
-		"	.insn	rxy,0xe30000000049,\\args\n"
-		"	.endm\n"
-		"	.globl	gs_handler_asm\n"
-		"gs_handler_asm:\n"
-		"	lgr	%r14,%r15\n"				/* Save current stack address in r14 */
-		".Lgs_handler_frame = 16*8+32+" xstr(STACK_FRAME_SIZE) "\n"
-		"	aghi	%r15,-(.Lgs_handler_frame)\n"		/* Allocate stack frame */
-		"	stmg	%r0,%r13,192(%r15)\n"			/* Store regs to save area */
-		"	stg	%r14,312(%r15)\n"
-		"	la	%r2," xstr(STACK_FRAME_SIZE) "(%r15)\n"	/* Store gscb address in this_cb */
-		"	STGSC	%r0," xstr(STACK_FRAME_SIZE) "(%r15)\n"
-		"	lg	%r14,24(%r2)\n"				/* Get GSEPLA from GSCB*/
-		"	lg	%r14,40(%r14)\n"			/* Get GSERA from GSEPL*/
-		"	stg	%r14,304(%r15)\n"			/* Store GSERA in r14 of reg save area */
-		"	brasl	%r14,gs_handler\n"			/* Jump to gs_handler */
-		"	lmg	%r0,%r15,192(%r15)\n"			/* Restore regs */
-		"	aghi	%r14, 6\n"				/* Add lgg instr len to GSERA */
-		"	br	%r14\n"					/* Jump to next instruction after lgg */
-		".size gs_handler_asm,.-gs_handler_asm\n"
-	);
+asm (".macro	STGSC	args:vararg\n"
+     "	.insn	rxy,0xe30000000049,\\args\n"
+     "	.endm\n"
+     "	.globl	gs_handler_asm\n"
+     "gs_handler_asm:\n"
+     "	lgr	%r14,%r15\n"				/* Save current stack address in r14 */
+     ".Lgs_handler_frame = 16*8+32+" xstr(STACK_FRAME_SIZE) "\n"
+     "	aghi	%r15,-(.Lgs_handler_frame)\n"		/* Allocate stack frame */
+     "	stmg	%r0,%r13,192(%r15)\n"			/* Store regs to save area */
+     "	stg	%r14,312(%r15)\n"
+     "	la	%r2," xstr(STACK_FRAME_SIZE) "(%r15)\n"	/* Store gscb address in this_cb */
+     "	STGSC	%r0," xstr(STACK_FRAME_SIZE) "(%r15)\n"
+     "	lg	%r14,24(%r2)\n"				/* Get GSEPLA from GSCB*/
+     "	lg	%r14,40(%r14)\n"			/* Get GSERA from GSEPL*/
+     "	stg	%r14,304(%r15)\n"			/* Store GSERA in r14 of reg save area */
+     "	brasl	%r14,gs_handler\n"			/* Jump to gs_handler */
+     "	lmg	%r0,%r15,192(%r15)\n"			/* Restore regs */
+     "	aghi	%r14, 6\n"				/* Add lgg instr len to GSERA */
+     "	br	%r14\n"					/* Jump to next instruction after lgg */
+     ".size gs_handler_asm,.-gs_handler_asm\n"
+);
+/* clang-format on */
 
 void gs_handler(struct gs_cb *this_cb)
 {
Signature · 1 line
2.41.0
author
#20 lore raw

PATCH 9/10 add clang-format configuration file

In reply to Nico Boehr

It is important that we follow a somewhat consistent source code formatting.

At the same time, going through minor formatting issues is exhausting for contributors and reviewers alike:

Contributors need to respin their patches because of minor formatting issues. Reviewers need to look for often easily overlooked formatting mistakes in submitted patches.

Since machines are much better at formatting source code than humans can ever be, add a .clang-format configuration file.

The clang-format file is taken from Linux with the following changes:
- ColumnLimit set to 0, since we don't enforce as strict of a column limit as in the kernel.
- AlignTrailingComments set to true since that seems to be quite common in existing code.

---
 .clang-format | 689 ++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 689 insertions(+)
 create mode 100644 .clang-format
.clang-format new file +689 -0
new file mode 100644
index 000000000000..3bf5c6f2a5a9
@@ -0,0 +1,689 @@
+# SPDX-License-Identifier: GPL-2.0
+#
+# clang-format configuration file. Intended for clang-format >= 11.
+#
+# For more information, see:
+#
+#   Documentation/process/clang-format.rst
+#   https://clang.llvm.org/docs/ClangFormat.html
+#   https://clang.llvm.org/docs/ClangFormatStyleOptions.html
+#
+---
+AccessModifierOffset: -4
+AlignAfterOpenBracket: Align
+AlignConsecutiveAssignments: false
+AlignConsecutiveDeclarations: false
+AlignEscapedNewlines: Left
+AlignOperands: true
+AlignTrailingComments: true
+AllowAllParametersOfDeclarationOnNextLine: false
+AllowShortBlocksOnASingleLine: false
+AllowShortCaseLabelsOnASingleLine: false
+AllowShortFunctionsOnASingleLine: None
+AllowShortIfStatementsOnASingleLine: false
+AllowShortLoopsOnASingleLine: false
+AlwaysBreakAfterDefinitionReturnType: None
+AlwaysBreakAfterReturnType: None
+AlwaysBreakBeforeMultilineStrings: false
+AlwaysBreakTemplateDeclarations: false
+BinPackArguments: true
+BinPackParameters: true
+BraceWrapping:
+  AfterClass: false
+  AfterControlStatement: false
+  AfterEnum: false
+  AfterFunction: true
+  AfterNamespace: true
+  AfterObjCDeclaration: false
+  AfterStruct: false
+  AfterUnion: false
+  AfterExternBlock: false
+  BeforeCatch: false
+  BeforeElse: false
+  IndentBraces: false
+  SplitEmptyFunction: true
+  SplitEmptyRecord: true
+  SplitEmptyNamespace: true
+BreakBeforeBinaryOperators: None
+BreakBeforeBraces: Custom
+BreakBeforeInheritanceComma: false
+BreakBeforeTernaryOperators: false
+BreakConstructorInitializersBeforeComma: false
+BreakConstructorInitializers: BeforeComma
+BreakAfterJavaFieldAnnotations: false
+BreakStringLiterals: false
+ColumnLimit: 0
+CommentPragmas: '^ IWYU pragma:'
+CompactNamespaces: false
+ConstructorInitializerAllOnOneLineOrOnePerLine: false
+ConstructorInitializerIndentWidth: 8
+ContinuationIndentWidth: 8
+Cpp11BracedListStyle: false
+DerivePointerAlignment: false
+DisableFormat: false
+ExperimentalAutoDetectBinPacking: false
+FixNamespaceComments: false
+
+# Taken from:
+#   git grep -h '^#define [^[:space:]]*for_each[^[:space:]]*(' include/ tools/ \
+#   | sed "s,^#define \([^[:space:]]*for_each[^[:space:]]*\)(.*$,  - '\1'," \
+#   | LC_ALL=C sort -u
+ForEachMacros:
+  - '__ata_qc_for_each'
+  - '__bio_for_each_bvec'
+  - '__bio_for_each_segment'
+  - '__evlist__for_each_entry'
+  - '__evlist__for_each_entry_continue'
+  - '__evlist__for_each_entry_from'
+  - '__evlist__for_each_entry_reverse'
+  - '__evlist__for_each_entry_safe'
+  - '__for_each_mem_range'
+  - '__for_each_mem_range_rev'
+  - '__for_each_thread'
+  - '__hlist_for_each_rcu'
+  - '__map__for_each_symbol_by_name'
+  - '__perf_evlist__for_each_entry'
+  - '__perf_evlist__for_each_entry_reverse'
+  - '__perf_evlist__for_each_entry_safe'
+  - '__rq_for_each_bio'
+  - '__shost_for_each_device'
+  - 'apei_estatus_for_each_section'
+  - 'ata_for_each_dev'
+  - 'ata_for_each_link'
+  - 'ata_qc_for_each'
+  - 'ata_qc_for_each_raw'
+  - 'ata_qc_for_each_with_internal'
+  - 'ax25_for_each'
+  - 'ax25_uid_for_each'
+  - 'bio_for_each_bvec'
+  - 'bio_for_each_bvec_all'
+  - 'bio_for_each_folio_all'
+  - 'bio_for_each_integrity_vec'
+  - 'bio_for_each_segment'
+  - 'bio_for_each_segment_all'
+  - 'bio_list_for_each'
+  - 'bip_for_each_vec'
+  - 'bond_for_each_slave'
+  - 'bond_for_each_slave_rcu'
+  - 'bpf__perf_for_each_map'
+  - 'bpf__perf_for_each_map_named'
+  - 'bpf_for_each_spilled_reg'
+  - 'bpf_object__for_each_map'
+  - 'bpf_object__for_each_program'
+  - 'bpf_object__for_each_safe'
+  - 'bpf_perf_object__for_each'
+  - 'btree_for_each_safe128'
+  - 'btree_for_each_safe32'
+  - 'btree_for_each_safe64'
+  - 'btree_for_each_safel'
+  - 'card_for_each_dev'
+  - 'cgroup_taskset_for_each'
+  - 'cgroup_taskset_for_each_leader'
+  - 'cpufreq_for_each_efficient_entry_idx'
+  - 'cpufreq_for_each_entry'
+  - 'cpufreq_for_each_entry_idx'
+  - 'cpufreq_for_each_valid_entry'
+  - 'cpufreq_for_each_valid_entry_idx'
+  - 'css_for_each_child'
+  - 'css_for_each_descendant_post'
+  - 'css_for_each_descendant_pre'
+  - 'damon_for_each_region'
+  - 'damon_for_each_region_safe'
+  - 'damon_for_each_scheme'
+  - 'damon_for_each_scheme_safe'
+  - 'damon_for_each_target'
+  - 'damon_for_each_target_safe'
+  - 'data__for_each_file'
+  - 'data__for_each_file_new'
+  - 'data__for_each_file_start'
+  - 'device_for_each_child_node'
+  - 'displayid_iter_for_each'
+  - 'dma_fence_array_for_each'
+  - 'dma_fence_chain_for_each'
+  - 'dma_fence_unwrap_for_each'
+  - 'dma_resv_for_each_fence'
+  - 'dma_resv_for_each_fence_unlocked'
+  - 'do_for_each_ftrace_op'
+  - 'drm_atomic_crtc_for_each_plane'
+  - 'drm_atomic_crtc_state_for_each_plane'
+  - 'drm_atomic_crtc_state_for_each_plane_state'
+  - 'drm_atomic_for_each_plane_damage'
+  - 'drm_client_for_each_connector_iter'
+  - 'drm_client_for_each_modeset'
+  - 'drm_connector_for_each_possible_encoder'
+  - 'drm_for_each_bridge_in_chain'
+  - 'drm_for_each_connector_iter'
+  - 'drm_for_each_crtc'
+  - 'drm_for_each_crtc_reverse'
+  - 'drm_for_each_encoder'
+  - 'drm_for_each_encoder_mask'
+  - 'drm_for_each_fb'
+  - 'drm_for_each_legacy_plane'
+  - 'drm_for_each_plane'
+  - 'drm_for_each_plane_mask'
+  - 'drm_for_each_privobj'
+  - 'drm_mm_for_each_hole'
+  - 'drm_mm_for_each_node'
+  - 'drm_mm_for_each_node_in_range'
+  - 'drm_mm_for_each_node_safe'
+  - 'dsa_switch_for_each_available_port'
+  - 'dsa_switch_for_each_cpu_port'
+  - 'dsa_switch_for_each_port'
+  - 'dsa_switch_for_each_port_continue_reverse'
+  - 'dsa_switch_for_each_port_safe'
+  - 'dsa_switch_for_each_user_port'
+  - 'dsa_tree_for_each_user_port'
+  - 'dso__for_each_symbol'
+  - 'dsos__for_each_with_build_id'
+  - 'elf_hash_for_each_possible'
+  - 'elf_section__for_each_rel'
+  - 'elf_section__for_each_rela'
+  - 'elf_symtab__for_each_symbol'
+  - 'evlist__for_each_cpu'
+  - 'evlist__for_each_entry'
+  - 'evlist__for_each_entry_continue'
+  - 'evlist__for_each_entry_from'
+  - 'evlist__for_each_entry_reverse'
+  - 'evlist__for_each_entry_safe'
+  - 'flow_action_for_each'
+  - 'for_each_acpi_dev_match'
+  - 'for_each_active_dev_scope'
+  - 'for_each_active_drhd_unit'
+  - 'for_each_active_iommu'
+  - 'for_each_active_route'
+  - 'for_each_aggr_pgid'
+  - 'for_each_available_child_of_node'
+  - 'for_each_bench'
+  - 'for_each_bio'
+  - 'for_each_board_func_rsrc'
+  - 'for_each_btf_ext_rec'
+  - 'for_each_btf_ext_sec'
+  - 'for_each_bvec'
+  - 'for_each_card_auxs'
+  - 'for_each_card_auxs_safe'
+  - 'for_each_card_components'
+  - 'for_each_card_dapms'
+  - 'for_each_card_pre_auxs'
+  - 'for_each_card_prelinks'
+  - 'for_each_card_rtds'
+  - 'for_each_card_rtds_safe'
+  - 'for_each_card_widgets'
+  - 'for_each_card_widgets_safe'
+  - 'for_each_cgroup_storage_type'
+  - 'for_each_child_of_node'
+  - 'for_each_clear_bit'
+  - 'for_each_clear_bit_from'
+  - 'for_each_clear_bitrange'
+  - 'for_each_clear_bitrange_from'
+  - 'for_each_cmd'
+  - 'for_each_cmsghdr'
+  - 'for_each_collection'
+  - 'for_each_comp_order'
+  - 'for_each_compatible_node'
+  - 'for_each_component_dais'
+  - 'for_each_component_dais_safe'
+  - 'for_each_console'
+  - 'for_each_console_srcu'
+  - 'for_each_cpu'
+  - 'for_each_cpu_and'
+  - 'for_each_cpu_wrap'
+  - 'for_each_dapm_widgets'
+  - 'for_each_dedup_cand'
+  - 'for_each_dev_addr'
+  - 'for_each_dev_scope'
+  - 'for_each_dma_cap_mask'
+  - 'for_each_dpcm_be'
+  - 'for_each_dpcm_be_rollback'
+  - 'for_each_dpcm_be_safe'
+  - 'for_each_dpcm_fe'
+  - 'for_each_drhd_unit'
+  - 'for_each_dss_dev'
+  - 'for_each_efi_memory_desc'
+  - 'for_each_efi_memory_desc_in_map'
+  - 'for_each_element'
+  - 'for_each_element_extid'
+  - 'for_each_element_id'
+  - 'for_each_endpoint_of_node'
+  - 'for_each_event'
+  - 'for_each_event_tps'
+  - 'for_each_evictable_lru'
+  - 'for_each_fib6_node_rt_rcu'
+  - 'for_each_fib6_walker_rt'
+  - 'for_each_free_mem_pfn_range_in_zone'
+  - 'for_each_free_mem_pfn_range_in_zone_from'
+  - 'for_each_free_mem_range'
+  - 'for_each_free_mem_range_reverse'
+  - 'for_each_func_rsrc'
+  - 'for_each_group_device'
+  - 'for_each_group_evsel'
+  - 'for_each_group_member'
+  - 'for_each_hstate'
+  - 'for_each_if'
+  - 'for_each_inject_fn'
+  - 'for_each_insn'
+  - 'for_each_insn_prefix'
+  - 'for_each_intid'
+  - 'for_each_iommu'
+  - 'for_each_ip_tunnel_rcu'
+  - 'for_each_irq_nr'
+  - 'for_each_lang'
+  - 'for_each_link_codecs'
+  - 'for_each_link_cpus'
+  - 'for_each_link_platforms'
+  - 'for_each_lru'
+  - 'for_each_matching_node'
+  - 'for_each_matching_node_and_match'
+  - 'for_each_mem_pfn_range'
+  - 'for_each_mem_range'
+  - 'for_each_mem_range_rev'
+  - 'for_each_mem_region'
+  - 'for_each_member'
+  - 'for_each_memory'
+  - 'for_each_migratetype_order'
+  - 'for_each_missing_reg'
+  - 'for_each_net'
+  - 'for_each_net_continue_reverse'
+  - 'for_each_net_rcu'
+  - 'for_each_netdev'
+  - 'for_each_netdev_continue'
+  - 'for_each_netdev_continue_rcu'
+  - 'for_each_netdev_continue_reverse'
+  - 'for_each_netdev_feature'
+  - 'for_each_netdev_in_bond_rcu'
+  - 'for_each_netdev_rcu'
+  - 'for_each_netdev_reverse'
+  - 'for_each_netdev_safe'
+  - 'for_each_new_connector_in_state'
+  - 'for_each_new_crtc_in_state'
+  - 'for_each_new_mst_mgr_in_state'
+  - 'for_each_new_plane_in_state'
+  - 'for_each_new_plane_in_state_reverse'
+  - 'for_each_new_private_obj_in_state'
+  - 'for_each_new_reg'
+  - 'for_each_node'
+  - 'for_each_node_by_name'
+  - 'for_each_node_by_type'
+  - 'for_each_node_mask'
+  - 'for_each_node_state'
+  - 'for_each_node_with_cpus'
+  - 'for_each_node_with_property'
+  - 'for_each_nonreserved_multicast_dest_pgid'
+  - 'for_each_of_allnodes'
+  - 'for_each_of_allnodes_from'
+  - 'for_each_of_cpu_node'
+  - 'for_each_of_pci_range'
+  - 'for_each_old_connector_in_state'
+  - 'for_each_old_crtc_in_state'
+  - 'for_each_old_mst_mgr_in_state'
+  - 'for_each_old_plane_in_state'
+  - 'for_each_old_private_obj_in_state'
+  - 'for_each_oldnew_connector_in_state'
+  - 'for_each_oldnew_crtc_in_state'
+  - 'for_each_oldnew_mst_mgr_in_state'
+  - 'for_each_oldnew_plane_in_state'
+  - 'for_each_oldnew_plane_in_state_reverse'
+  - 'for_each_oldnew_private_obj_in_state'
+  - 'for_each_online_cpu'
+  - 'for_each_online_node'
+  - 'for_each_online_pgdat'
+  - 'for_each_path'
+  - 'for_each_pci_bridge'
+  - 'for_each_pci_dev'
+  - 'for_each_pcm_streams'
+  - 'for_each_physmem_range'
+  - 'for_each_populated_zone'
+  - 'for_each_possible_cpu'
+  - 'for_each_present_cpu'
+  - 'for_each_prime_number'
+  - 'for_each_prime_number_from'
+  - 'for_each_probe_cache_entry'
+  - 'for_each_process'
+  - 'for_each_process_thread'
+  - 'for_each_prop_codec_conf'
+  - 'for_each_prop_dai_codec'
+  - 'for_each_prop_dai_cpu'
+  - 'for_each_prop_dlc_codecs'
+  - 'for_each_prop_dlc_cpus'
+  - 'for_each_prop_dlc_platforms'
+  - 'for_each_property_of_node'
+  - 'for_each_reg'
+  - 'for_each_reg_filtered'
+  - 'for_each_registered_fb'
+  - 'for_each_requested_gpio'
+  - 'for_each_requested_gpio_in_range'
+  - 'for_each_reserved_mem_range'
+  - 'for_each_reserved_mem_region'
+  - 'for_each_rtd_codec_dais'
+  - 'for_each_rtd_components'
+  - 'for_each_rtd_cpu_dais'
+  - 'for_each_rtd_dais'
+  - 'for_each_script'
+  - 'for_each_sec'
+  - 'for_each_set_bit'
+  - 'for_each_set_bit_from'
+  - 'for_each_set_bitrange'
+  - 'for_each_set_bitrange_from'
+  - 'for_each_set_clump8'
+  - 'for_each_sg'
+  - 'for_each_sg_dma_page'
+  - 'for_each_sg_page'
+  - 'for_each_sgtable_dma_page'
+  - 'for_each_sgtable_dma_sg'
+  - 'for_each_sgtable_page'
+  - 'for_each_sgtable_sg'
+  - 'for_each_shell_test'
+  - 'for_each_sibling_event'
+  - 'for_each_subelement'
+  - 'for_each_subelement_extid'
+  - 'for_each_subelement_id'
+  - 'for_each_sublist'
+  - 'for_each_subsystem'
+  - 'for_each_supported_activate_fn'
+  - 'for_each_supported_inject_fn'
+  - 'for_each_test'
+  - 'for_each_thread'
+  - 'for_each_token'
+  - 'for_each_unicast_dest_pgid'
+  - 'for_each_vsi'
+  - 'for_each_wakeup_source'
+  - 'for_each_zone'
+  - 'for_each_zone_zonelist'
+  - 'for_each_zone_zonelist_nodemask'
+  - 'func_for_each_insn'
+  - 'fwnode_for_each_available_child_node'
+  - 'fwnode_for_each_child_node'
+  - 'fwnode_graph_for_each_endpoint'
+  - 'gadget_for_each_ep'
+  - 'genradix_for_each'
+  - 'genradix_for_each_from'
+  - 'hash_for_each'
+  - 'hash_for_each_possible'
+  - 'hash_for_each_possible_rcu'
+  - 'hash_for_each_possible_rcu_notrace'
+  - 'hash_for_each_possible_safe'
+  - 'hash_for_each_rcu'
+  - 'hash_for_each_safe'
+  - 'hashmap__for_each_entry'
+  - 'hashmap__for_each_entry_safe'
+  - 'hashmap__for_each_key_entry'
+  - 'hashmap__for_each_key_entry_safe'
+  - 'hctx_for_each_ctx'
+  - 'hists__for_each_format'
+  - 'hists__for_each_sort_list'
+  - 'hlist_bl_for_each_entry'
+  - 'hlist_bl_for_each_entry_rcu'
+  - 'hlist_bl_for_each_entry_safe'
+  - 'hlist_for_each'
+  - 'hlist_for_each_entry'
+  - 'hlist_for_each_entry_continue'
+  - 'hlist_for_each_entry_continue_rcu'
+  - 'hlist_for_each_entry_continue_rcu_bh'
+  - 'hlist_for_each_entry_from'
+  - 'hlist_for_each_entry_from_rcu'
+  - 'hlist_for_each_entry_rcu'
+  - 'hlist_for_each_entry_rcu_bh'
+  - 'hlist_for_each_entry_rcu_notrace'
+  - 'hlist_for_each_entry_safe'
+  - 'hlist_for_each_entry_srcu'
+  - 'hlist_for_each_safe'
+  - 'hlist_nulls_for_each_entry'
+  - 'hlist_nulls_for_each_entry_from'
+  - 'hlist_nulls_for_each_entry_rcu'
+  - 'hlist_nulls_for_each_entry_safe'
+  - 'i3c_bus_for_each_i2cdev'
+  - 'i3c_bus_for_each_i3cdev'
+  - 'idr_for_each_entry'
+  - 'idr_for_each_entry_continue'
+  - 'idr_for_each_entry_continue_ul'
+  - 'idr_for_each_entry_ul'
+  - 'in_dev_for_each_ifa_rcu'
+  - 'in_dev_for_each_ifa_rtnl'
+  - 'inet_bind_bucket_for_each'
+  - 'inet_lhash2_for_each_icsk'
+  - 'inet_lhash2_for_each_icsk_continue'
+  - 'inet_lhash2_for_each_icsk_rcu'
+  - 'interval_tree_for_each_double_span'
+  - 'interval_tree_for_each_span'
+  - 'intlist__for_each_entry'
+  - 'intlist__for_each_entry_safe'
+  - 'iopt_for_each_contig_area'
+  - 'kcore_copy__for_each_phdr'
+  - 'key_for_each'
+  - 'key_for_each_safe'
+  - 'klp_for_each_func'
+  - 'klp_for_each_func_safe'
+  - 'klp_for_each_func_static'
+  - 'klp_for_each_object'
+  - 'klp_for_each_object_safe'
+  - 'klp_for_each_object_static'
+  - 'kunit_suite_for_each_test_case'
+  - 'kvm_for_each_memslot'
+  - 'kvm_for_each_memslot_in_gfn_range'
+  - 'kvm_for_each_vcpu'
+  - 'libbpf_nla_for_each_attr'
+  - 'list_for_each'
+  - 'list_for_each_codec'
+  - 'list_for_each_codec_safe'
+  - 'list_for_each_continue'
+  - 'list_for_each_entry'
+  - 'list_for_each_entry_continue'
+  - 'list_for_each_entry_continue_rcu'
+  - 'list_for_each_entry_continue_reverse'
+  - 'list_for_each_entry_from'
+  - 'list_for_each_entry_from_rcu'
+  - 'list_for_each_entry_from_reverse'
+  - 'list_for_each_entry_lockless'
+  - 'list_for_each_entry_rcu'
+  - 'list_for_each_entry_reverse'
+  - 'list_for_each_entry_safe'
+  - 'list_for_each_entry_safe_continue'
+  - 'list_for_each_entry_safe_from'
+  - 'list_for_each_entry_safe_reverse'
+  - 'list_for_each_entry_srcu'
+  - 'list_for_each_from'
+  - 'list_for_each_prev'
+  - 'list_for_each_prev_safe'
+  - 'list_for_each_safe'
+  - 'llist_for_each'
+  - 'llist_for_each_entry'
+  - 'llist_for_each_entry_safe'
+  - 'llist_for_each_safe'
+  - 'map__for_each_symbol'
+  - 'map__for_each_symbol_by_name'
+  - 'map_for_each_event'
+  - 'map_for_each_metric'
+  - 'maps__for_each_entry'
+  - 'maps__for_each_entry_safe'
+  - 'mci_for_each_dimm'
+  - 'media_device_for_each_entity'
+  - 'media_device_for_each_intf'
+  - 'media_device_for_each_link'
+  - 'media_device_for_each_pad'
+  - 'msi_for_each_desc'
+  - 'nanddev_io_for_each_page'
+  - 'netdev_for_each_lower_dev'
+  - 'netdev_for_each_lower_private'
+  - 'netdev_for_each_lower_private_rcu'
+  - 'netdev_for_each_mc_addr'
+  - 'netdev_for_each_uc_addr'
+  - 'netdev_for_each_upper_dev_rcu'
+  - 'netdev_hw_addr_list_for_each'
+  - 'nft_rule_for_each_expr'
+  - 'nla_for_each_attr'
+  - 'nla_for_each_nested'
+  - 'nlmsg_for_each_attr'
+  - 'nlmsg_for_each_msg'
+  - 'nr_neigh_for_each'
+  - 'nr_neigh_for_each_safe'
+  - 'nr_node_for_each'
+  - 'nr_node_for_each_safe'
+  - 'of_for_each_phandle'
+  - 'of_property_for_each_string'
+  - 'of_property_for_each_u32'
+  - 'pci_bus_for_each_resource'
+  - 'pci_dev_for_each_resource'
+  - 'pcl_for_each_chunk'
+  - 'pcl_for_each_segment'
+  - 'pcm_for_each_format'
+  - 'perf_config_items__for_each_entry'
+  - 'perf_config_sections__for_each_entry'
+  - 'perf_config_set__for_each_entry'
+  - 'perf_cpu_map__for_each_cpu'
+  - 'perf_evlist__for_each_entry'
+  - 'perf_evlist__for_each_entry_reverse'
+  - 'perf_evlist__for_each_entry_safe'
+  - 'perf_evlist__for_each_evsel'
+  - 'perf_evlist__for_each_mmap'
+  - 'perf_hpp_list__for_each_format'
+  - 'perf_hpp_list__for_each_format_safe'
+  - 'perf_hpp_list__for_each_sort_list'
+  - 'perf_hpp_list__for_each_sort_list_safe'
+  - 'perf_pmu__for_each_hybrid_pmu'
+  - 'ping_portaddr_for_each_entry'
+  - 'ping_portaddr_for_each_entry_rcu'
+  - 'plist_for_each'
+  - 'plist_for_each_continue'
+  - 'plist_for_each_entry'
+  - 'plist_for_each_entry_continue'
+  - 'plist_for_each_entry_safe'
+  - 'plist_for_each_safe'
+  - 'pnp_for_each_card'
+  - 'pnp_for_each_dev'
+  - 'protocol_for_each_card'
+  - 'protocol_for_each_dev'
+  - 'queue_for_each_hw_ctx'
+  - 'radix_tree_for_each_slot'
+  - 'radix_tree_for_each_tagged'
+  - 'rb_for_each'
+  - 'rbtree_postorder_for_each_entry_safe'
+  - 'rdma_for_each_block'
+  - 'rdma_for_each_port'
+  - 'rdma_umem_for_each_dma_block'
+  - 'resort_rb__for_each_entry'
+  - 'resource_list_for_each_entry'
+  - 'resource_list_for_each_entry_safe'
+  - 'rhl_for_each_entry_rcu'
+  - 'rhl_for_each_rcu'
+  - 'rht_for_each'
+  - 'rht_for_each_entry'
+  - 'rht_for_each_entry_from'
+  - 'rht_for_each_entry_rcu'
+  - 'rht_for_each_entry_rcu_from'
+  - 'rht_for_each_entry_safe'
+  - 'rht_for_each_from'
+  - 'rht_for_each_rcu'
+  - 'rht_for_each_rcu_from'
+  - 'rq_for_each_bvec'
+  - 'rq_for_each_segment'
+  - 'rq_list_for_each'
+  - 'rq_list_for_each_safe'
+  - 'scsi_for_each_prot_sg'
+  - 'scsi_for_each_sg'
+  - 'sctp_for_each_hentry'
+  - 'sctp_skb_for_each'
+  - 'sec_for_each_insn'
+  - 'sec_for_each_insn_continue'
+  - 'sec_for_each_insn_from'
+  - 'shdma_for_each_chan'
+  - 'shost_for_each_device'
+  - 'sk_for_each'
+  - 'sk_for_each_bound'
+  - 'sk_for_each_entry_offset_rcu'
+  - 'sk_for_each_from'
+  - 'sk_for_each_rcu'
+  - 'sk_for_each_safe'
+  - 'sk_nulls_for_each'
+  - 'sk_nulls_for_each_from'
+  - 'sk_nulls_for_each_rcu'
+  - 'snd_array_for_each'
+  - 'snd_pcm_group_for_each_entry'
+  - 'snd_soc_dapm_widget_for_each_path'
+  - 'snd_soc_dapm_widget_for_each_path_safe'
+  - 'snd_soc_dapm_widget_for_each_sink_path'
+  - 'snd_soc_dapm_widget_for_each_source_path'
+  - 'strlist__for_each_entry'
+  - 'strlist__for_each_entry_safe'
+  - 'sym_for_each_insn'
+  - 'sym_for_each_insn_continue_reverse'
+  - 'symbols__for_each_entry'
+  - 'tb_property_for_each'
+  - 'tcf_act_for_each_action'
+  - 'tcf_exts_for_each_action'
+  - 'udp_portaddr_for_each_entry'
+  - 'udp_portaddr_for_each_entry_rcu'
+  - 'usb_hub_for_each_child'
+  - 'v4l2_device_for_each_subdev'
+  - 'v4l2_m2m_for_each_dst_buf'
+  - 'v4l2_m2m_for_each_dst_buf_safe'
+  - 'v4l2_m2m_for_each_src_buf'
+  - 'v4l2_m2m_for_each_src_buf_safe'
+  - 'virtio_device_for_each_vq'
+  - 'while_for_each_ftrace_op'
+  - 'xa_for_each'
+  - 'xa_for_each_marked'
+  - 'xa_for_each_range'
+  - 'xa_for_each_start'
+  - 'xas_for_each'
+  - 'xas_for_each_conflict'
+  - 'xas_for_each_marked'
+  - 'xbc_array_for_each_value'
+  - 'xbc_for_each_key_value'
+  - 'xbc_node_for_each_array_value'
+  - 'xbc_node_for_each_child'
+  - 'xbc_node_for_each_key_value'
+  - 'xbc_node_for_each_subkey'
+  - 'zorro_for_each_dev'
+
+IncludeBlocks: Preserve
+IncludeCategories:
+  - Regex: '.*'
+    Priority: 1
+IncludeIsMainRegex: '(Test)?$'
+IndentCaseLabels: false
+IndentGotoLabels: false
+IndentPPDirectives: None
+IndentWidth: 8
+IndentWrappedFunctionNames: false
+JavaScriptQuotes: Leave
+JavaScriptWrapImports: true
+KeepEmptyLinesAtTheStartOfBlocks: false
+MacroBlockBegin: ''
+MacroBlockEnd: ''
+MaxEmptyLinesToKeep: 1
+NamespaceIndentation: None
+ObjCBinPackProtocolList: Auto
+ObjCBlockIndentWidth: 8
+ObjCSpaceAfterProperty: true
+ObjCSpaceBeforeProtocolList: true
+
+# Taken from git's rules
+PenaltyBreakAssignment: 10
+PenaltyBreakBeforeFirstCallParameter: 30
+PenaltyBreakComment: 10
+PenaltyBreakFirstLessLess: 0
+PenaltyBreakString: 10
+PenaltyExcessCharacter: 100
+PenaltyReturnTypeOnItsOwnLine: 60
+
+PointerAlignment: Right
+ReflowComments: false
+SortIncludes: false
+SortUsingDeclarations: false
+SpaceAfterCStyleCast: false
+SpaceAfterTemplateKeyword: true
+SpaceBeforeAssignmentOperators: true
+SpaceBeforeCtorInitializerColon: true
+SpaceBeforeInheritanceColon: true
+SpaceBeforeParens: ControlStatementsExceptForEachMacros
+SpaceBeforeRangeBasedForLoopColon: true
+SpaceInEmptyParentheses: false
+SpacesBeforeTrailingComments: 1
+SpacesInAngles: false
+SpacesInContainerLiterals: false
+SpacesInCStyleCastParentheses: false
+SpacesInParentheses: false
+SpacesInSquareBrackets: false
+Standard: Cpp03
+TabWidth: 8
+UseTab: Always
+...
Signature · 1 line
2.41.0
#21 lore raw

Re: [kvm-unit-tests PATCH v1 09/10] add clang-format configuration file

Quoted 21 lines · Nico Boehr

It is important that we follow a somewhat consistent source code formatting.

At the same time, going through minor formatting issues is exhausting for contributors and reviewers alike:

Contributors need to respin their patches because of minor formatting issues. Reviewers need to look for often easily overlooked formatting mistakes in submitted patches.

Since machines are much better at formatting source code than humans can ever be, add a .clang-format configuration file.

The clang-format file is taken from Linux with the following changes:
- ColumnLimit set to 0, since we don't enforce as strict of a column limit as in the kernel.
- AlignTrailingComments set to true since that seems to be quite common in existing code.

---

...

Quoted 559 lines
.clang-format new file +559 -0
+# Taken from:
+#   git grep -h '^#define [^[:space:]]*for_each[^[:space:]]*(' include/ tools/ \
+#   | sed "s,^#define \([^[:space:]]*for_each[^[:space:]]*\)(.*$,  - '\1'," \
+#   | LC_ALL=C sort -u
+ForEachMacros:
+  - '__ata_qc_for_each'
+  - '__bio_for_each_bvec'
+  - '__bio_for_each_segment'
+  - '__evlist__for_each_entry'
+  - '__evlist__for_each_entry_continue'
+  - '__evlist__for_each_entry_from'
+  - '__evlist__for_each_entry_reverse'
+  - '__evlist__for_each_entry_safe'
+  - '__for_each_mem_range'
+  - '__for_each_mem_range_rev'
+  - '__for_each_thread'
+  - '__hlist_for_each_rcu'
+  - '__map__for_each_symbol_by_name'
+  - '__perf_evlist__for_each_entry'
+  - '__perf_evlist__for_each_entry_reverse'
+  - '__perf_evlist__for_each_entry_safe'
+  - '__rq_for_each_bio'
+  - '__shost_for_each_device'
+  - 'apei_estatus_for_each_section'
+  - 'ata_for_each_dev'
+  - 'ata_for_each_link'
+  - 'ata_qc_for_each'
+  - 'ata_qc_for_each_raw'
+  - 'ata_qc_for_each_with_internal'
+  - 'ax25_for_each'
+  - 'ax25_uid_for_each'
+  - 'bio_for_each_bvec'
+  - 'bio_for_each_bvec_all'
+  - 'bio_for_each_folio_all'
+  - 'bio_for_each_integrity_vec'
+  - 'bio_for_each_segment'
+  - 'bio_for_each_segment_all'
+  - 'bio_list_for_each'
+  - 'bip_for_each_vec'
+  - 'bond_for_each_slave'
+  - 'bond_for_each_slave_rcu'
+  - 'bpf__perf_for_each_map'
+  - 'bpf__perf_for_each_map_named'
+  - 'bpf_for_each_spilled_reg'
+  - 'bpf_object__for_each_map'
+  - 'bpf_object__for_each_program'
+  - 'bpf_object__for_each_safe'
+  - 'bpf_perf_object__for_each'
+  - 'btree_for_each_safe128'
+  - 'btree_for_each_safe32'
+  - 'btree_for_each_safe64'
+  - 'btree_for_each_safel'
+  - 'card_for_each_dev'
+  - 'cgroup_taskset_for_each'
+  - 'cgroup_taskset_for_each_leader'
+  - 'cpufreq_for_each_efficient_entry_idx'
+  - 'cpufreq_for_each_entry'
+  - 'cpufreq_for_each_entry_idx'
+  - 'cpufreq_for_each_valid_entry'
+  - 'cpufreq_for_each_valid_entry_idx'
+  - 'css_for_each_child'
+  - 'css_for_each_descendant_post'
+  - 'css_for_each_descendant_pre'
+  - 'damon_for_each_region'
+  - 'damon_for_each_region_safe'
+  - 'damon_for_each_scheme'
+  - 'damon_for_each_scheme_safe'
+  - 'damon_for_each_target'
+  - 'damon_for_each_target_safe'
+  - 'data__for_each_file'
+  - 'data__for_each_file_new'
+  - 'data__for_each_file_start'
+  - 'device_for_each_child_node'
+  - 'displayid_iter_for_each'
+  - 'dma_fence_array_for_each'
+  - 'dma_fence_chain_for_each'
+  - 'dma_fence_unwrap_for_each'
+  - 'dma_resv_for_each_fence'
+  - 'dma_resv_for_each_fence_unlocked'
+  - 'do_for_each_ftrace_op'
+  - 'drm_atomic_crtc_for_each_plane'
+  - 'drm_atomic_crtc_state_for_each_plane'
+  - 'drm_atomic_crtc_state_for_each_plane_state'
+  - 'drm_atomic_for_each_plane_damage'
+  - 'drm_client_for_each_connector_iter'
+  - 'drm_client_for_each_modeset'
+  - 'drm_connector_for_each_possible_encoder'
+  - 'drm_for_each_bridge_in_chain'
+  - 'drm_for_each_connector_iter'
+  - 'drm_for_each_crtc'
+  - 'drm_for_each_crtc_reverse'
+  - 'drm_for_each_encoder'
+  - 'drm_for_each_encoder_mask'
+  - 'drm_for_each_fb'
+  - 'drm_for_each_legacy_plane'
+  - 'drm_for_each_plane'
+  - 'drm_for_each_plane_mask'
+  - 'drm_for_each_privobj'
+  - 'drm_mm_for_each_hole'
+  - 'drm_mm_for_each_node'
+  - 'drm_mm_for_each_node_in_range'
+  - 'drm_mm_for_each_node_safe'
+  - 'dsa_switch_for_each_available_port'
+  - 'dsa_switch_for_each_cpu_port'
+  - 'dsa_switch_for_each_port'
+  - 'dsa_switch_for_each_port_continue_reverse'
+  - 'dsa_switch_for_each_port_safe'
+  - 'dsa_switch_for_each_user_port'
+  - 'dsa_tree_for_each_user_port'
+  - 'dso__for_each_symbol'
+  - 'dsos__for_each_with_build_id'
+  - 'elf_hash_for_each_possible'
+  - 'elf_section__for_each_rel'
+  - 'elf_section__for_each_rela'
+  - 'elf_symtab__for_each_symbol'
+  - 'evlist__for_each_cpu'
+  - 'evlist__for_each_entry'
+  - 'evlist__for_each_entry_continue'
+  - 'evlist__for_each_entry_from'
+  - 'evlist__for_each_entry_reverse'
+  - 'evlist__for_each_entry_safe'
+  - 'flow_action_for_each'
+  - 'for_each_acpi_dev_match'
+  - 'for_each_active_dev_scope'
+  - 'for_each_active_drhd_unit'
+  - 'for_each_active_iommu'
+  - 'for_each_active_route'
+  - 'for_each_aggr_pgid'
+  - 'for_each_available_child_of_node'
+  - 'for_each_bench'
+  - 'for_each_bio'
+  - 'for_each_board_func_rsrc'
+  - 'for_each_btf_ext_rec'
+  - 'for_each_btf_ext_sec'
+  - 'for_each_bvec'
+  - 'for_each_card_auxs'
+  - 'for_each_card_auxs_safe'
+  - 'for_each_card_components'
+  - 'for_each_card_dapms'
+  - 'for_each_card_pre_auxs'
+  - 'for_each_card_prelinks'
+  - 'for_each_card_rtds'
+  - 'for_each_card_rtds_safe'
+  - 'for_each_card_widgets'
+  - 'for_each_card_widgets_safe'
+  - 'for_each_cgroup_storage_type'
+  - 'for_each_child_of_node'
+  - 'for_each_clear_bit'
+  - 'for_each_clear_bit_from'
+  - 'for_each_clear_bitrange'
+  - 'for_each_clear_bitrange_from'
+  - 'for_each_cmd'
+  - 'for_each_cmsghdr'
+  - 'for_each_collection'
+  - 'for_each_comp_order'
+  - 'for_each_compatible_node'
+  - 'for_each_component_dais'
+  - 'for_each_component_dais_safe'
+  - 'for_each_console'
+  - 'for_each_console_srcu'
+  - 'for_each_cpu'
+  - 'for_each_cpu_and'
+  - 'for_each_cpu_wrap'
+  - 'for_each_dapm_widgets'
+  - 'for_each_dedup_cand'
+  - 'for_each_dev_addr'
+  - 'for_each_dev_scope'
+  - 'for_each_dma_cap_mask'
+  - 'for_each_dpcm_be'
+  - 'for_each_dpcm_be_rollback'
+  - 'for_each_dpcm_be_safe'
+  - 'for_each_dpcm_fe'
+  - 'for_each_drhd_unit'
+  - 'for_each_dss_dev'
+  - 'for_each_efi_memory_desc'
+  - 'for_each_efi_memory_desc_in_map'
+  - 'for_each_element'
+  - 'for_each_element_extid'
+  - 'for_each_element_id'
+  - 'for_each_endpoint_of_node'
+  - 'for_each_event'
+  - 'for_each_event_tps'
+  - 'for_each_evictable_lru'
+  - 'for_each_fib6_node_rt_rcu'
+  - 'for_each_fib6_walker_rt'
+  - 'for_each_free_mem_pfn_range_in_zone'
+  - 'for_each_free_mem_pfn_range_in_zone_from'
+  - 'for_each_free_mem_range'
+  - 'for_each_free_mem_range_reverse'
+  - 'for_each_func_rsrc'
+  - 'for_each_group_device'
+  - 'for_each_group_evsel'
+  - 'for_each_group_member'
+  - 'for_each_hstate'
+  - 'for_each_if'
+  - 'for_each_inject_fn'
+  - 'for_each_insn'
+  - 'for_each_insn_prefix'
+  - 'for_each_intid'
+  - 'for_each_iommu'
+  - 'for_each_ip_tunnel_rcu'
+  - 'for_each_irq_nr'
+  - 'for_each_lang'
+  - 'for_each_link_codecs'
+  - 'for_each_link_cpus'
+  - 'for_each_link_platforms'
+  - 'for_each_lru'
+  - 'for_each_matching_node'
+  - 'for_each_matching_node_and_match'
+  - 'for_each_mem_pfn_range'
+  - 'for_each_mem_range'
+  - 'for_each_mem_range_rev'
+  - 'for_each_mem_region'
+  - 'for_each_member'
+  - 'for_each_memory'
+  - 'for_each_migratetype_order'
+  - 'for_each_missing_reg'
+  - 'for_each_net'
+  - 'for_each_net_continue_reverse'
+  - 'for_each_net_rcu'
+  - 'for_each_netdev'
+  - 'for_each_netdev_continue'
+  - 'for_each_netdev_continue_rcu'
+  - 'for_each_netdev_continue_reverse'
+  - 'for_each_netdev_feature'
+  - 'for_each_netdev_in_bond_rcu'
+  - 'for_each_netdev_rcu'
+  - 'for_each_netdev_reverse'
+  - 'for_each_netdev_safe'
+  - 'for_each_new_connector_in_state'
+  - 'for_each_new_crtc_in_state'
+  - 'for_each_new_mst_mgr_in_state'
+  - 'for_each_new_plane_in_state'
+  - 'for_each_new_plane_in_state_reverse'
+  - 'for_each_new_private_obj_in_state'
+  - 'for_each_new_reg'
+  - 'for_each_node'
+  - 'for_each_node_by_name'
+  - 'for_each_node_by_type'
+  - 'for_each_node_mask'
+  - 'for_each_node_state'
+  - 'for_each_node_with_cpus'
+  - 'for_each_node_with_property'
+  - 'for_each_nonreserved_multicast_dest_pgid'
+  - 'for_each_of_allnodes'
+  - 'for_each_of_allnodes_from'
+  - 'for_each_of_cpu_node'
+  - 'for_each_of_pci_range'
+  - 'for_each_old_connector_in_state'
+  - 'for_each_old_crtc_in_state'
+  - 'for_each_old_mst_mgr_in_state'
+  - 'for_each_old_plane_in_state'
+  - 'for_each_old_private_obj_in_state'
+  - 'for_each_oldnew_connector_in_state'
+  - 'for_each_oldnew_crtc_in_state'
+  - 'for_each_oldnew_mst_mgr_in_state'
+  - 'for_each_oldnew_plane_in_state'
+  - 'for_each_oldnew_plane_in_state_reverse'
+  - 'for_each_oldnew_private_obj_in_state'
+  - 'for_each_online_cpu'
+  - 'for_each_online_node'
+  - 'for_each_online_pgdat'
+  - 'for_each_path'
+  - 'for_each_pci_bridge'
+  - 'for_each_pci_dev'
+  - 'for_each_pcm_streams'
+  - 'for_each_physmem_range'
+  - 'for_each_populated_zone'
+  - 'for_each_possible_cpu'
+  - 'for_each_present_cpu'
+  - 'for_each_prime_number'
+  - 'for_each_prime_number_from'
+  - 'for_each_probe_cache_entry'
+  - 'for_each_process'
+  - 'for_each_process_thread'
+  - 'for_each_prop_codec_conf'
+  - 'for_each_prop_dai_codec'
+  - 'for_each_prop_dai_cpu'
+  - 'for_each_prop_dlc_codecs'
+  - 'for_each_prop_dlc_cpus'
+  - 'for_each_prop_dlc_platforms'
+  - 'for_each_property_of_node'
+  - 'for_each_reg'
+  - 'for_each_reg_filtered'
+  - 'for_each_registered_fb'
+  - 'for_each_requested_gpio'
+  - 'for_each_requested_gpio_in_range'
+  - 'for_each_reserved_mem_range'
+  - 'for_each_reserved_mem_region'
+  - 'for_each_rtd_codec_dais'
+  - 'for_each_rtd_components'
+  - 'for_each_rtd_cpu_dais'
+  - 'for_each_rtd_dais'
+  - 'for_each_script'
+  - 'for_each_sec'
+  - 'for_each_set_bit'
+  - 'for_each_set_bit_from'
+  - 'for_each_set_bitrange'
+  - 'for_each_set_bitrange_from'
+  - 'for_each_set_clump8'
+  - 'for_each_sg'
+  - 'for_each_sg_dma_page'
+  - 'for_each_sg_page'
+  - 'for_each_sgtable_dma_page'
+  - 'for_each_sgtable_dma_sg'
+  - 'for_each_sgtable_page'
+  - 'for_each_sgtable_sg'
+  - 'for_each_shell_test'
+  - 'for_each_sibling_event'
+  - 'for_each_subelement'
+  - 'for_each_subelement_extid'
+  - 'for_each_subelement_id'
+  - 'for_each_sublist'
+  - 'for_each_subsystem'
+  - 'for_each_supported_activate_fn'
+  - 'for_each_supported_inject_fn'
+  - 'for_each_test'
+  - 'for_each_thread'
+  - 'for_each_token'
+  - 'for_each_unicast_dest_pgid'
+  - 'for_each_vsi'
+  - 'for_each_wakeup_source'
+  - 'for_each_zone'
+  - 'for_each_zone_zonelist'
+  - 'for_each_zone_zonelist_nodemask'
+  - 'func_for_each_insn'
+  - 'fwnode_for_each_available_child_node'
+  - 'fwnode_for_each_child_node'
+  - 'fwnode_graph_for_each_endpoint'
+  - 'gadget_for_each_ep'
+  - 'genradix_for_each'
+  - 'genradix_for_each_from'
+  - 'hash_for_each'
+  - 'hash_for_each_possible'
+  - 'hash_for_each_possible_rcu'
+  - 'hash_for_each_possible_rcu_notrace'
+  - 'hash_for_each_possible_safe'
+  - 'hash_for_each_rcu'
+  - 'hash_for_each_safe'
+  - 'hashmap__for_each_entry'
+  - 'hashmap__for_each_entry_safe'
+  - 'hashmap__for_each_key_entry'
+  - 'hashmap__for_each_key_entry_safe'
+  - 'hctx_for_each_ctx'
+  - 'hists__for_each_format'
+  - 'hists__for_each_sort_list'
+  - 'hlist_bl_for_each_entry'
+  - 'hlist_bl_for_each_entry_rcu'
+  - 'hlist_bl_for_each_entry_safe'
+  - 'hlist_for_each'
+  - 'hlist_for_each_entry'
+  - 'hlist_for_each_entry_continue'
+  - 'hlist_for_each_entry_continue_rcu'
+  - 'hlist_for_each_entry_continue_rcu_bh'
+  - 'hlist_for_each_entry_from'
+  - 'hlist_for_each_entry_from_rcu'
+  - 'hlist_for_each_entry_rcu'
+  - 'hlist_for_each_entry_rcu_bh'
+  - 'hlist_for_each_entry_rcu_notrace'
+  - 'hlist_for_each_entry_safe'
+  - 'hlist_for_each_entry_srcu'
+  - 'hlist_for_each_safe'
+  - 'hlist_nulls_for_each_entry'
+  - 'hlist_nulls_for_each_entry_from'
+  - 'hlist_nulls_for_each_entry_rcu'
+  - 'hlist_nulls_for_each_entry_safe'
+  - 'i3c_bus_for_each_i2cdev'
+  - 'i3c_bus_for_each_i3cdev'
+  - 'idr_for_each_entry'
+  - 'idr_for_each_entry_continue'
+  - 'idr_for_each_entry_continue_ul'
+  - 'idr_for_each_entry_ul'
+  - 'in_dev_for_each_ifa_rcu'
+  - 'in_dev_for_each_ifa_rtnl'
+  - 'inet_bind_bucket_for_each'
+  - 'inet_lhash2_for_each_icsk'
+  - 'inet_lhash2_for_each_icsk_continue'
+  - 'inet_lhash2_for_each_icsk_rcu'
+  - 'interval_tree_for_each_double_span'
+  - 'interval_tree_for_each_span'
+  - 'intlist__for_each_entry'
+  - 'intlist__for_each_entry_safe'
+  - 'iopt_for_each_contig_area'
+  - 'kcore_copy__for_each_phdr'
+  - 'key_for_each'
+  - 'key_for_each_safe'
+  - 'klp_for_each_func'
+  - 'klp_for_each_func_safe'
+  - 'klp_for_each_func_static'
+  - 'klp_for_each_object'
+  - 'klp_for_each_object_safe'
+  - 'klp_for_each_object_static'
+  - 'kunit_suite_for_each_test_case'
+  - 'kvm_for_each_memslot'
+  - 'kvm_for_each_memslot_in_gfn_range'
+  - 'kvm_for_each_vcpu'
+  - 'libbpf_nla_for_each_attr'
+  - 'list_for_each'
+  - 'list_for_each_codec'
+  - 'list_for_each_codec_safe'
+  - 'list_for_each_continue'
+  - 'list_for_each_entry'
+  - 'list_for_each_entry_continue'
+  - 'list_for_each_entry_continue_rcu'
+  - 'list_for_each_entry_continue_reverse'
+  - 'list_for_each_entry_from'
+  - 'list_for_each_entry_from_rcu'
+  - 'list_for_each_entry_from_reverse'
+  - 'list_for_each_entry_lockless'
+  - 'list_for_each_entry_rcu'
+  - 'list_for_each_entry_reverse'
+  - 'list_for_each_entry_safe'
+  - 'list_for_each_entry_safe_continue'
+  - 'list_for_each_entry_safe_from'
+  - 'list_for_each_entry_safe_reverse'
+  - 'list_for_each_entry_srcu'
+  - 'list_for_each_from'
+  - 'list_for_each_prev'
+  - 'list_for_each_prev_safe'
+  - 'list_for_each_safe'
+  - 'llist_for_each'
+  - 'llist_for_each_entry'
+  - 'llist_for_each_entry_safe'
+  - 'llist_for_each_safe'
+  - 'map__for_each_symbol'
+  - 'map__for_each_symbol_by_name'
+  - 'map_for_each_event'
+  - 'map_for_each_metric'
+  - 'maps__for_each_entry'
+  - 'maps__for_each_entry_safe'
+  - 'mci_for_each_dimm'
+  - 'media_device_for_each_entity'
+  - 'media_device_for_each_intf'
+  - 'media_device_for_each_link'
+  - 'media_device_for_each_pad'
+  - 'msi_for_each_desc'
+  - 'nanddev_io_for_each_page'
+  - 'netdev_for_each_lower_dev'
+  - 'netdev_for_each_lower_private'
+  - 'netdev_for_each_lower_private_rcu'
+  - 'netdev_for_each_mc_addr'
+  - 'netdev_for_each_uc_addr'
+  - 'netdev_for_each_upper_dev_rcu'
+  - 'netdev_hw_addr_list_for_each'
+  - 'nft_rule_for_each_expr'
+  - 'nla_for_each_attr'
+  - 'nla_for_each_nested'
+  - 'nlmsg_for_each_attr'
+  - 'nlmsg_for_each_msg'
+  - 'nr_neigh_for_each'
+  - 'nr_neigh_for_each_safe'
+  - 'nr_node_for_each'
+  - 'nr_node_for_each_safe'
+  - 'of_for_each_phandle'
+  - 'of_property_for_each_string'
+  - 'of_property_for_each_u32'
+  - 'pci_bus_for_each_resource'
+  - 'pci_dev_for_each_resource'
+  - 'pcl_for_each_chunk'
+  - 'pcl_for_each_segment'
+  - 'pcm_for_each_format'
+  - 'perf_config_items__for_each_entry'
+  - 'perf_config_sections__for_each_entry'
+  - 'perf_config_set__for_each_entry'
+  - 'perf_cpu_map__for_each_cpu'
+  - 'perf_evlist__for_each_entry'
+  - 'perf_evlist__for_each_entry_reverse'
+  - 'perf_evlist__for_each_entry_safe'
+  - 'perf_evlist__for_each_evsel'
+  - 'perf_evlist__for_each_mmap'
+  - 'perf_hpp_list__for_each_format'
+  - 'perf_hpp_list__for_each_format_safe'
+  - 'perf_hpp_list__for_each_sort_list'
+  - 'perf_hpp_list__for_each_sort_list_safe'
+  - 'perf_pmu__for_each_hybrid_pmu'
+  - 'ping_portaddr_for_each_entry'
+  - 'ping_portaddr_for_each_entry_rcu'
+  - 'plist_for_each'
+  - 'plist_for_each_continue'
+  - 'plist_for_each_entry'
+  - 'plist_for_each_entry_continue'
+  - 'plist_for_each_entry_safe'
+  - 'plist_for_each_safe'
+  - 'pnp_for_each_card'
+  - 'pnp_for_each_dev'
+  - 'protocol_for_each_card'
+  - 'protocol_for_each_dev'
+  - 'queue_for_each_hw_ctx'
+  - 'radix_tree_for_each_slot'
+  - 'radix_tree_for_each_tagged'
+  - 'rb_for_each'
+  - 'rbtree_postorder_for_each_entry_safe'
+  - 'rdma_for_each_block'
+  - 'rdma_for_each_port'
+  - 'rdma_umem_for_each_dma_block'
+  - 'resort_rb__for_each_entry'
+  - 'resource_list_for_each_entry'
+  - 'resource_list_for_each_entry_safe'
+  - 'rhl_for_each_entry_rcu'
+  - 'rhl_for_each_rcu'
+  - 'rht_for_each'
+  - 'rht_for_each_entry'
+  - 'rht_for_each_entry_from'
+  - 'rht_for_each_entry_rcu'
+  - 'rht_for_each_entry_rcu_from'
+  - 'rht_for_each_entry_safe'
+  - 'rht_for_each_from'
+  - 'rht_for_each_rcu'
+  - 'rht_for_each_rcu_from'
+  - 'rq_for_each_bvec'
+  - 'rq_for_each_segment'
+  - 'rq_list_for_each'
+  - 'rq_list_for_each_safe'
+  - 'scsi_for_each_prot_sg'
+  - 'scsi_for_each_sg'
+  - 'sctp_for_each_hentry'
+  - 'sctp_skb_for_each'
+  - 'sec_for_each_insn'
+  - 'sec_for_each_insn_continue'
+  - 'sec_for_each_insn_from'
+  - 'shdma_for_each_chan'
+  - 'shost_for_each_device'
+  - 'sk_for_each'
+  - 'sk_for_each_bound'
+  - 'sk_for_each_entry_offset_rcu'
+  - 'sk_for_each_from'
+  - 'sk_for_each_rcu'
+  - 'sk_for_each_safe'
+  - 'sk_nulls_for_each'
+  - 'sk_nulls_for_each_from'
+  - 'sk_nulls_for_each_rcu'
+  - 'snd_array_for_each'
+  - 'snd_pcm_group_for_each_entry'
+  - 'snd_soc_dapm_widget_for_each_path'
+  - 'snd_soc_dapm_widget_for_each_path_safe'
+  - 'snd_soc_dapm_widget_for_each_sink_path'
+  - 'snd_soc_dapm_widget_for_each_source_path'
+  - 'strlist__for_each_entry'
+  - 'strlist__for_each_entry_safe'
+  - 'sym_for_each_insn'
+  - 'sym_for_each_insn_continue_reverse'
+  - 'symbols__for_each_entry'
+  - 'tb_property_for_each'
+  - 'tcf_act_for_each_action'
+  - 'tcf_exts_for_each_action'
+  - 'udp_portaddr_for_each_entry'
+  - 'udp_portaddr_for_each_entry_rcu'
+  - 'usb_hub_for_each_child'
+  - 'v4l2_device_for_each_subdev'
+  - 'v4l2_m2m_for_each_dst_buf'
+  - 'v4l2_m2m_for_each_dst_buf_safe'
+  - 'v4l2_m2m_for_each_src_buf'
+  - 'v4l2_m2m_for_each_src_buf_safe'
+  - 'virtio_device_for_each_vq'
+  - 'while_for_each_ftrace_op'
+  - 'xa_for_each'
+  - 'xa_for_each_marked'
+  - 'xa_for_each_range'
+  - 'xa_for_each_start'

.clang-format line 635

Quoted 10 lines
.clang-format new file +10 -0
+  - 'xas_for_each'
+  - 'xas_for_each_conflict'
+  - 'xas_for_each_marked'
+  - 'xbc_array_for_each_value'
+  - 'xbc_for_each_key_value'
+  - 'xbc_node_for_each_array_value'
+  - 'xbc_node_for_each_child'
+  - 'xbc_node_for_each_key_value'
+  - 'xbc_node_for_each_subkey'
+  - 'zorro_for_each_dev'

A lot of these symbols don't and will never exist in kvm-unit-tests ... shouldn't we better trim the list to the ones that are available here?

Thomas

author
#22 lore raw

PATCH 10/10 add make format

In reply to Nico Boehr

Add target "format" to the makefile to format all source files with clang-format.

This currently assumes all architectures want to opt-in to formatting with clang-format. Maybe they don't want that, then we can move the target to architecture-specific folders.

---
 Makefile | 3 +++
 1 file changed, 3 insertions(+)
Makefile +3 -0
index 602910dda11b..b5509c74ad5b 100644
@@ -147,3 +147,6 @@ tags:
 
 check-kerneldoc:
 	find . -name '*.[ch]' -exec scripts/kernel-doc -none {} +
+
+format:
+	find . -name '*.[ch]' ! -type l -exec clang-format -i {} +
Signature · 1 line
2.41.0
#23 lore raw
In reply to Nico Boehr
Quoted 17 lines · Nico Boehr

It is important that we have a consistent formatting of our source code and comments in kvm-unit-tests.

Yet, it's not always easy since tiny formatting mistakes are hard to spot for reviewers. Respinning patches because of these issues can also be frustrating for contributors.

This series is a RFC suggestion on how the situation could be improved for kvm-unit-tests.

It adds a clang-format file, mostly based on the one already present in the kernel. A new "make format" target makes it easy to properly format the source. If maintainers want, they could even re-format the source code of ther arch to ensure a consistent code formatting, but this is entirely optional. I am also happy to move the "make format" into arch-specific code if requested.

Quoted 3 lines

Additionally, I noticed that there is quite inconsistent use of kernel-doc comments in the code. Add a respective check command and fix the existing issues.

I think the kerneldoc patches are good to go, so I went ahead and pushed them to the repo now.

For the s390x beautification patches (patch 07 and 08), it would be good to get some other reviews first ... Claudio? Janosch?

Thomas