[v3] devtools: add .clang-format file

Message ID 20240504191837.1096185-1-aomeryamac@gmail.com (mailing list archive)
State Superseded
Delegated to: Thomas Monjalon
Headers
Series [v3] devtools: add .clang-format file |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/loongarch-compilation success Compilation OK
ci/loongarch-unit-testing success Unit Testing PASS
ci/Intel-compilation success Compilation OK
ci/intel-Testing success Testing PASS
ci/iol-intel-Performance success Performance Testing PASS
ci/intel-Functional success Functional PASS
ci/iol-compile-amd64-testing success Testing PASS
ci/github-robot: build success github build: passed
ci/iol-abi-testing success Testing PASS
ci/iol-sample-apps-testing success Testing PASS
ci/iol-unit-amd64-testing success Testing PASS
ci/iol-unit-arm64-testing success Testing PASS
ci/iol-compile-arm64-testing success Testing PASS
ci/iol-broadcom-Performance success Performance Testing PASS
ci/iol-broadcom-Functional success Functional Testing PASS
ci/iol-intel-Functional success Functional Testing PASS
ci/iol-mellanox-Performance success Performance Testing PASS

Commit Message

Abdullah Ömer Yamaç May 4, 2024, 7:18 p.m. UTC
  clang-format is a tool to format C/C++/Objective-C code. It can be used
to reformat code to match a given coding style, or to ensure that code
adheres to a specific coding style. It helps to maintain a consistent
coding style across the DPDK codebase.

.clang-format file overrides the default style options provided by
clang-format and large set of IDEs and text editors support it.

Signed-off-by: Abdullah Ömer Yamaç <aomeryamac@gmail.com>
---
 .clang-format | 138 ++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 138 insertions(+)
 create mode 100644 .clang-format
  

Comments

Stephen Hemminger May 5, 2024, 4:18 p.m. UTC | #1
On Sat,  4 May 2024 19:18:37 +0000
Abdullah Ömer Yamaç <aomeryamac@gmail.com> wrote:

> clang-format is a tool to format C/C++/Objective-C code. It can be used
> to reformat code to match a given coding style, or to ensure that code
> adheres to a specific coding style. It helps to maintain a consistent
> coding style across the DPDK codebase.
> 
> .clang-format file overrides the default style options provided by
> clang-format and large set of IDEs and text editors support it.
> 
> Signed-off-by: Abdullah Ömer Yamaç <aomeryamac@gmail.com>
> ---
>  .clang-format | 138 ++++++++++++++++++++++++++++++++++++++++++++++++++
>  1 file changed, 138 insertions(+)
>  create mode 100644 .clang-format

Tried this, but it needs some change to how braces at start of function
are handled.  For example, this is not how DPDK should look:

 static int
-rte_pmd_tap_remove(struct rte_vdev_device *dev)
-{
+rte_pmd_tap_remove(struct rte_vdev_device *dev) {
 	struct rte_eth_dev *eth_dev = NULL;
 
 	/* find the ethdev entry */
  
Stephen Hemminger May 5, 2024, 4:20 p.m. UTC | #2
On Sat,  4 May 2024 19:18:37 +0000
Abdullah Ömer Yamaç <aomeryamac@gmail.com> wrote:

> clang-format is a tool to format C/C++/Objective-C code. It can be used
> to reformat code to match a given coding style, or to ensure that code
> adheres to a specific coding style. It helps to maintain a consistent
> coding style across the DPDK codebase.
> 
> .clang-format file overrides the default style options provided by
> clang-format and large set of IDEs and text editors support it.
> 
> Signed-off-by: Abdullah Ömer Yamaç <aomeryamac@gmail.com>

Also, this looks wrong.  The initialized arrays looked better before.

 
-static const char *tuntap_types[ETH_TUNTAP_TYPE_MAX] = {
-	"UNKNOWN", "TUN", "TAP"
-};
+static const char *tuntap_types[ETH_TUNTAP_TYPE_MAX] = {"UNKNOWN", "TUN", "TAP"};
 
-static const char *valid_arguments[] = {
-	ETH_TAP_IFACE_ARG,
-	ETH_TAP_REMOTE_ARG,
-	ETH_TAP_MAC_ARG,
-	ETH_TAP_PERSIST_ARG,
-	NULL
-};
+static const char *valid_arguments[] = {ETH_TAP_IFACE_ARG, ETH_TAP_REMOTE_ARG, ETH_TAP_MAC_ARG,
+					ETH_TAP_PERSIST_ARG, NULL};
  
Abdullah Ömer Yamaç May 5, 2024, 6:43 p.m. UTC | #3
On Sun, May 5, 2024 at 7:18 PM Stephen Hemminger <stephen@networkplumber.org>
wrote:

> On Sat,  4 May 2024 19:18:37 +0000
> Abdullah Ömer Yamaç <aomeryamac@gmail.com> wrote:
>
> > clang-format is a tool to format C/C++/Objective-C code. It can be used
> > to reformat code to match a given coding style, or to ensure that code
> > adheres to a specific coding style. It helps to maintain a consistent
> > coding style across the DPDK codebase.
> >
> > .clang-format file overrides the default style options provided by
> > clang-format and large set of IDEs and text editors support it.
> >
> > Signed-off-by: Abdullah Ömer Yamaç <aomeryamac@gmail.com>
> > ---
> >  .clang-format | 138 ++++++++++++++++++++++++++++++++++++++++++++++++++
> >  1 file changed, 138 insertions(+)
> >  create mode 100644 .clang-format
>
> Tried this, but it needs some change to how braces at start of function
> are handled.  For example, this is not how DPDK should look:
>
Are the changes below ok? When I fix these cases, some macros are also
formatted in the same manner.

-#define RTE_RX_OFFLOAD_BIT2STR(_name) \
- { RTE_ETH_RX_OFFLOAD_##_name, #_name }
+#define RTE_RX_OFFLOAD_BIT2STR(_name)              \
+ {                                          \
+ RTE_ETH_RX_OFFLOAD_##_name, #_name \
+ }


>
>  static int
> -rte_pmd_tap_remove(struct rte_vdev_device *dev)
> -{
> +rte_pmd_tap_remove(struct rte_vdev_device *dev) {
>         struct rte_eth_dev *eth_dev = NULL;
>
>         /* find the ethdev entry */
>
  
Abdullah Ömer Yamaç May 5, 2024, 7:42 p.m. UTC | #4
On Sun, May 5, 2024 at 7:21 PM Stephen Hemminger <stephen@networkplumber.org>
wrote:

> On Sat,  4 May 2024 19:18:37 +0000
> Abdullah Ömer Yamaç <aomeryamac@gmail.com> wrote:
>
> > clang-format is a tool to format C/C++/Objective-C code. It can be used
> > to reformat code to match a given coding style, or to ensure that code
> > adheres to a specific coding style. It helps to maintain a consistent
> > coding style across the DPDK codebase.
> >
> > .clang-format file overrides the default style options provided by
> > clang-format and large set of IDEs and text editors support it.
> >
> > Signed-off-by: Abdullah Ömer Yamaç <aomeryamac@gmail.com>
>
> Also, this looks wrong.  The initialized arrays looked better before.
>
>
> -static const char *tuntap_types[ETH_TUNTAP_TYPE_MAX] = {
> -       "UNKNOWN", "TUN", "TAP"
> -};
> +static const char *tuntap_types[ETH_TUNTAP_TYPE_MAX] = {"UNKNOWN", "TUN",
> "TAP"};
>
> -static const char *valid_arguments[] = {
> -       ETH_TAP_IFACE_ARG,
> -       ETH_TAP_REMOTE_ARG,
> -       ETH_TAP_MAC_ARG,
> -       ETH_TAP_PERSIST_ARG,
> -       NULL
> -};
> +static const char *valid_arguments[] = {ETH_TAP_IFACE_ARG,
> ETH_TAP_REMOTE_ARG, ETH_TAP_MAC_ARG,
> +                                       ETH_TAP_PERSIST_ARG, NULL};
>

I am confused about these variables.  tuntap_types list values in a single
line, but valid_arguments' values are listed separately.
So, it is getting more complex to handle both of them. What should we do,
do you have any idea?
  
Stephen Hemminger May 5, 2024, 8:38 p.m. UTC | #5
On Sun, 5 May 2024 22:42:57 +0300
Abdullah Ömer Yamaç <aomeryamac@gmail.com> wrote:

> > Also, this looks wrong.  The initialized arrays looked better before.
> >
> >
> > -static const char *tuntap_types[ETH_TUNTAP_TYPE_MAX] = {
> > -       "UNKNOWN", "TUN", "TAP"
> > -};
> > +static const char *tuntap_types[ETH_TUNTAP_TYPE_MAX] = {"UNKNOWN", "TUN",
> > "TAP"};
> >
> > -static const char *valid_arguments[] = {
> > -       ETH_TAP_IFACE_ARG,
> > -       ETH_TAP_REMOTE_ARG,
> > -       ETH_TAP_MAC_ARG,
> > -       ETH_TAP_PERSIST_ARG,
> > -       NULL
> > -};
> > +static const char *valid_arguments[] = {ETH_TAP_IFACE_ARG,
> > ETH_TAP_REMOTE_ARG, ETH_TAP_MAC_ARG,
> > +                                       ETH_TAP_PERSIST_ARG, NULL};
> >  
> 
> I am confused about these variables.  tuntap_types list values in a single
> line, but valid_arguments' values are listed separately.
> So, it is getting more complex to handle both of them. What should we do,
> do you have any idea?

Ignore the initialized lists for now. It should be possible to have it generate something
like 

static const char *tuntap_types[ETH_TUNTAP_TYPE_MAX] = {
      "UNKNOWN", "TUN", "TAP"
};

With the following changes result looks better. You got the format wrong for the ForEach list.

diff --git a/.clang-format b/.clang-format
index 16164ef1de..d16185c049 100644
--- a/.clang-format
+++ b/.clang-format
@@ -1,12 +1,20 @@
 ---
 BasedOnStyle: LLVM
 
+AttributeMacros:
+  - __rte_aligned
+  - __rte_packed
+  - __rte_may_alias
+  - __rte_deprecated
+  - __rte_weak
+  - __rte_unused
+  - __rte_restrict
+
 # Place opening and closing parentheses on the same line for control statements
 BreakBeforeBraces: Custom
 BraceWrapping:
-        AfterFunction: false
+        AfterFunction: true
         AfterControlStatement: false
-        AfterEnum: false
 
 # Set maximum line length to 100 characters
 ColumnLimit: 100
@@ -41,98 +49,117 @@ AlwaysBreakAfterReturnType: TopLevelDefinitions
 # Always break before multiline string literals
 AlignEscapedNewlines: Left
 
-# Foreach macros
-ForEachMacros: [
-        "CIRBUF_FOREACH",
-        "DLB2_LIST_FOR_EACH",
-        "DLB2_LIST_FOR_EACH_SAFE",
-        "ECORE_LIST_FOR_EACH_ENTRY",
-        "ECORE_LIST_FOR_EACH_ENTRY_SAFE",
-        "FOR_EACH",
-        "FOR_EACH_BUCKET",
-        "FOR_EACH_CNIC_QUEUE",
-        "FOR_EACH_COS_IN_TX_QUEUE",
-        "FOR_EACH_ETH_QUEUE",
-        "FOR_EACH_MEMBER",
-        "FOR_EACH_NONDEFAULT_ETH_QUEUE",
-        "FOR_EACH_NONDEFAULT_QUEUE",
-        "FOR_EACH_PORT",
-        "FOR_EACH_PORT_IF",
-        "FOR_EACH_QUEUE",
-        "FOR_EACH_SUITE_TESTCASE",
-        "FOR_EACH_SUITE_TESTSUITE",
-        "FOREACH_ABS_FUNC_IN_PORT",
-        "FOREACH_DEVICE_ON_AUXILIARY_BUS",
-        "FOREACH_DEVICE_ON_CDXBUS",
-        "FOREACH_DEVICE_ON_PCIBUS",
-        "FOREACH_DEVICE_ON_PLATFORM_BUS",
-        "FOREACH_DEVICE_ON_UACCEBUS",
-        "FOREACH_DEVICE_ON_VMBUS",
-        "FOREACH_DRIVER_ON_AUXILIARY_BUS",
-        "FOREACH_DRIVER_ON_CDXBUS",
-        "FOREACH_DRIVER_ON_PCIBUS",
-        "FOREACH_DRIVER_ON_PLATFORM_BUS",
-        "FOREACH_DRIVER_ON_UACCEBUS",
-        "FOREACH_DRIVER_ON_VMBUS",
-        "FOREACH_SUBDEV",
-        "FOREACH_SUBDEV_STATE",
-        "HLIST_FOR_EACH_ENTRY",
-        "ILIST_FOREACH",
-        "LIST_FOR_EACH_ENTRY",
-        "LIST_FOR_EACH_ENTRY_SAFE",
-        "LIST_FOREACH",
-        "LIST_FOREACH_FROM",
-        "LIST_FOREACH_FROM_SAFE",
-        "LIST_FOREACH_SAFE",
-        "ML_AVG_FOREACH_QP",
-        "ML_AVG_FOREACH_QP_MVTVM",
-        "ML_AVG_RESET_FOREACH_QP",
-        "ML_MAX_FOREACH_QP",
-        "ML_MAX_FOREACH_QP_MVTVM",
-        "ML_MAX_RESET_FOREACH_QP",
-        "ML_MIN_FOREACH_QP",
-        "ML_MIN_FOREACH_QP_MVTVM",
-        "ML_MIN_RESET_FOREACH_QP",
-        "MLX5_ETH_FOREACH_DEV",
-        "MLX5_IPOOL_FOREACH",
-        "MLX5_L3T_FOREACH",
-        "OSAL_LIST_FOR_EACH_ENTRY",
-        "OSAL_LIST_FOR_EACH_ENTRY_SAFE",
-        "PLT_TAILQ_FOREACH_SAFE",
-        "RTE_BBDEV_FOREACH",
-        "RTE_DEV_FOREACH",
-        "RTE_DMA_FOREACH_DEV",
-        "RTE_EAL_DEVARGS_FOREACH",
-        "RTE_ETH_FOREACH_DEV",
-        "RTE_ETH_FOREACH_DEV_OF",
-        "RTE_ETH_FOREACH_DEV_OWNED_BY",
-        "RTE_ETH_FOREACH_DEV_SIBLING",
-        "RTE_ETH_FOREACH_MATCHING_DEV",
-        "RTE_ETH_FOREACH_VALID_DEV",
-        "RTE_GPU_FOREACH",
-        "RTE_GPU_FOREACH_CHILD",
-        "RTE_GPU_FOREACH_PARENT",
-        "RTE_LCORE_FOREACH",
-        "RTE_LCORE_FOREACH_WORKER",
-        "RTE_TAILQ_FOREACH",
-        "RTE_TAILQ_FOREACH_SAFE",
-        "SILIST_FOREACH",
-        "SLIST_FOREACH",
-        "SLIST_FOREACH_FROM",
-        "SLIST_FOREACH_FROM_SAFE",
-        "SLIST_FOREACH_PREVPTR",
-        "SLIST_FOREACH_SAFE",
-        "STAILQ_FOREACH",
-        "STAILQ_FOREACH_FROM",
-        "STAILQ_FOREACH_FROM_SAFE",
-        "STAILQ_FOREACH_SAFE",
-        "TAILQ_FOREACH",
-        "TAILQ_FOREACH_ENTRY",
-        "TAILQ_FOREACH_ENTRY_SAFE",
-        "TAILQ_FOREACH_FROM",
-        "TAILQ_FOREACH_FROM_SAFE",
-        "TAILQ_FOREACH_REVERSE",
-        "TAILQ_FOREACH_REVERSE_FROM",
-        "TAILQ_FOREACH_REVERSE_FROM_SAFE",
-        "TAILQ_FOREACH_REVERSE_SAFE",
-        "TAILQ_FOREACH_SAFE", ]
+ForEachMacros:
+  - CIRBUF_FOREACH
+  - DLB2_LIST_FOR_EACH
+  - DLB2_LIST_FOR_EACH_SAFE
+  - ECORE_LIST_FOR_EACH_ENTRY
+  - ECORE_LIST_FOR_EACH_ENTRY_SAFE
+  - FOREACH_ABS_FUNC_IN_PORT
+  - FOREACH_DEVICE_ON_AUXILIARY_BUS
+  - FOREACH_DEVICE_ON_CDXBUS
+  - FOREACH_DEVICE_ON_PCIBUS
+  - FOREACH_DEVICE_ON_PLATFORM_BUS
+  - FOREACH_DEVICE_ON_UACCEBUS
+  - FOREACH_DEVICE_ON_VMBUS
+  - FOREACH_DRIVER_ON_AUXILIARY_BUS
+  - FOREACH_DRIVER_ON_CDXBUS
+  - FOREACH_DRIVER_ON_PCIBUS
+  - FOREACH_DRIVER_ON_PLATFORM_BUS
+  - FOREACH_DRIVER_ON_UACCEBUS
+  - FOREACH_DRIVER_ON_VMBUS
+  - FOREACH_SUBDEV
+  - FOREACH_SUBDEV_STATE
+  - FOR_EACH
+  - FOR_EACH_BUCKET
+  - FOR_EACH_CNIC_QUEUE
+  - FOR_EACH_COS_IN_TX_QUEUE
+  - FOR_EACH_ETH_QUEUE
+  - FOR_EACH_MEMBER
+  - FOR_EACH_NONDEFAULT_ETH_QUEUE
+  - FOR_EACH_NONDEFAULT_QUEUE
+  - FOR_EACH_PORT
+  - FOR_EACH_PORT_IF
+  - FOR_EACH_QUEUE
+  - FOR_EACH_SUITE_TESTCASE
+  - FOR_EACH_SUITE_TESTSUITE
+  - HLIST_FOR_EACH_ENTRY
+  - ILIST_FOREACH
+  - LIST_FOREACH
+  - LIST_FOREACH_FROM
+  - LIST_FOREACH_FROM_SAFE
+  - LIST_FOREACH_SAFE
+  - LIST_FOR_EACH_ENTRY
+  - LIST_FOR_EACH_ENTRY_SAFE
+  - MLX5_ETH_FOREACH_DEV
+  - MLX5_IPOOL_FOREACH
+  - MLX5_L3T_FOREACH
+  - ML_AVG_FOREACH_QP
+  - ML_AVG_FOREACH_QP_MVTVM
+  - ML_AVG_RESET_FOREACH_QP
+  - ML_MAX_FOREACH_QP
+  - ML_MAX_FOREACH_QP_MVTVM
+  - ML_MAX_RESET_FOREACH_QP
+  - ML_MIN_FOREACH_QP
+  - ML_MIN_FOREACH_QP_MVTVM
+  - ML_MIN_RESET_FOREACH_QP
+  - OSAL_LIST_FOR_EACH_ENTRY
+  - OSAL_LIST_FOR_EACH_ENTRY_SAFE
+  - PLT_TAILQ_FOREACH_SAFE
+  - RTE_BBDEV_FOREACH
+  - RTE_BBDEV_FOREACH
+  - RTE_DEV_FOREACH
+  - RTE_DEV_FOREACH
+  - RTE_DMA_FOREACH_DEV
+  - RTE_DMA_FOREACH_DEV
+  - RTE_EAL_DEVARGS_FOREACH
+  - RTE_EAL_DEVARGS_FOREACH
+  - RTE_ETH_FOREACH_DEV
+  - RTE_ETH_FOREACH_DEV
+  - RTE_ETH_FOREACH_DEV_OF
+  - RTE_ETH_FOREACH_DEV_OF
+  - RTE_ETH_FOREACH_DEV_OWNED_BY
+  - RTE_ETH_FOREACH_DEV_OWNED_BY
+  - RTE_ETH_FOREACH_DEV_SIBLING
+  - RTE_ETH_FOREACH_DEV_SIBLING
+  - RTE_ETH_FOREACH_MATCHING_DEV
+  - RTE_ETH_FOREACH_MATCHING_DEV
+  - RTE_ETH_FOREACH_VALID_DEV
+  - RTE_ETH_FOREACH_VALID_DEV
+  - RTE_GPU_FOREACH
+  - RTE_GPU_FOREACH
+  - RTE_GPU_FOREACH_CHILD
+  - RTE_GPU_FOREACH_CHILD
+  - RTE_GPU_FOREACH_PARENT
+  - RTE_GPU_FOREACH_PARENT
+  - RTE_LCORE_FOREACH
+  - RTE_LCORE_FOREACH
+  - RTE_LCORE_FOREACH_WORKER
+  - RTE_LCORE_FOREACH_WORKER
+  - RTE_TAILQ_FOREACH
+  - RTE_TAILQ_FOREACH
+  - RTE_TAILQ_FOREACH_SAFE
+  - RTE_TAILQ_FOREACH_SAFE
+  - SILIST_FOREACH
+  - SLIST_FOREACH
+  - SLIST_FOREACH_FROM
+  - SLIST_FOREACH_FROM_SAFE
+  - SLIST_FOREACH_PREVPTR
+  - SLIST_FOREACH_SAFE
+  - STAILQ_FOREACH
+  - STAILQ_FOREACH_FROM
+  - STAILQ_FOREACH_FROM_SAFE
+  - STAILQ_FOREACH_SAFE
+  - TAILQ_FOREACH
+  - TAILQ_FOREACH_ENTRY
+  - TAILQ_FOREACH_ENTRY_SAFE
+  - TAILQ_FOREACH_FROM
+  - TAILQ_FOREACH_FROM_SAFE
+  - TAILQ_FOREACH_REVERSE
+  - TAILQ_FOREACH_REVERSE_FROM
+  - TAILQ_FOREACH_REVERSE_FROM_SAFE
+  - TAILQ_FOREACH_REVERSE_SAFE
+  - TAILQ_FOREACH_SAFE
+
+ObjCSpaceAfterProperty: true
+IndentGotoLabels: false
  
Abdullah Ömer Yamaç May 6, 2024, 10:43 a.m. UTC | #6
Unaddressed
On Sun, May 5, 2024 at 11:38 PM Stephen Hemminger <
stephen@networkplumber.org> wrote:

> On Sun, 5 May 2024 22:42:57 +0300
> Abdullah Ömer Yamaç <aomeryamac@gmail.com> wrote:
>
> > > Also, this looks wrong.  The initialized arrays looked better before.
> > >
> > >
> > > -static const char *tuntap_types[ETH_TUNTAP_TYPE_MAX] = {
> > > -       "UNKNOWN", "TUN", "TAP"
> > > -};
> > > +static const char *tuntap_types[ETH_TUNTAP_TYPE_MAX] = {"UNKNOWN",
> "TUN",
> > > "TAP"};
> > >
> > > -static const char *valid_arguments[] = {
> > > -       ETH_TAP_IFACE_ARG,
> > > -       ETH_TAP_REMOTE_ARG,
> > > -       ETH_TAP_MAC_ARG,
> > > -       ETH_TAP_PERSIST_ARG,
> > > -       NULL
> > > -};
> > > +static const char *valid_arguments[] = {ETH_TAP_IFACE_ARG,
> > > ETH_TAP_REMOTE_ARG, ETH_TAP_MAC_ARG,
> > > +                                       ETH_TAP_PERSIST_ARG, NULL};
> > >
> >
> > I am confused about these variables.  tuntap_types list values in a
> single
> > line, but valid_arguments' values are listed separately.
> > So, it is getting more complex to handle both of them. What should we do,
> > do you have any idea?
>
> Ignore the initialized lists for now. It should be possible to have it
> generate something
> like
>
> static const char *tuntap_types[ETH_TUNTAP_TYPE_MAX] = {
>       "UNKNOWN", "TUN", "TAP"
> };
>
> With the following changes result looks better. You got the format wrong
> for the ForEach list.
>
> diff --git a/.clang-format b/.clang-format
> index 16164ef1de..d16185c049 100644
> --- a/.clang-format
> +++ b/.clang-format
> @@ -1,12 +1,20 @@
>  ---
>  BasedOnStyle: LLVM
>
> +AttributeMacros:
> +  - __rte_aligned
> +  - __rte_packed
> +  - __rte_may_alias
> +  - __rte_deprecated
> +  - __rte_weak
> +  - __rte_unused
> +  - __rte_restrict
> +
>  # Place opening and closing parentheses on the same line for control
> statements
>  BreakBeforeBraces: Custom
>  BraceWrapping:
> -        AfterFunction: false
> +        AfterFunction: true
>          AfterControlStatement: false
> -        AfterEnum: false
>
> These are ok for me.

>  # Set maximum line length to 100 characters
>  ColumnLimit: 100
> @@ -41,98 +49,117 @@ AlwaysBreakAfterReturnType: TopLevelDefinitions
>  # Always break before multiline string literals
>  AlignEscapedNewlines: Left
>
> -# Foreach macros
>
In the clang documentation, it says "ForEachMacros (List of Strings)" and
gives an example: "ForEachMacros: ['RANGES_FOR', 'FOREACH']"

> ...
> +ObjCSpaceAfterProperty: true
> +IndentGotoLabels: false
>
These are also ok for me.

If you agree on the for-each part, then I will send the new patch.
Thanks
  

Patch

diff --git a/.clang-format b/.clang-format
new file mode 100644
index 0000000000..16164ef1de
--- /dev/null
+++ b/.clang-format
@@ -0,0 +1,138 @@ 
+---
+BasedOnStyle: LLVM
+
+# Place opening and closing parentheses on the same line for control statements
+BreakBeforeBraces: Custom
+BraceWrapping:
+        AfterFunction: false
+        AfterControlStatement: false
+        AfterEnum: false
+
+# Set maximum line length to 100 characters
+ColumnLimit: 100
+
+# Use LF (line feed) as the end-of-line character
+LineEnding: LF
+
+# Insert a newline at the end of the file
+InsertNewlineAtEOF: true
+
+# Set indentation width to 8 spaces
+IndentWidth: 8
+
+# Set continuation indentation width to 8 spaces
+ContinuationIndentWidth: 8
+
+# Set tab width to 8 spaces
+TabWidth: 8
+
+# Use tabs for indentation
+UseTab: Always
+
+# Preserve include blocks as they are
+IncludeBlocks: Preserve
+
+# Never sort includes
+SortIncludes: Never
+
+# Always break after return type for top-level definitions
+AlwaysBreakAfterReturnType: TopLevelDefinitions
+
+# Always break before multiline string literals
+AlignEscapedNewlines: Left
+
+# Foreach macros
+ForEachMacros: [
+        "CIRBUF_FOREACH",
+        "DLB2_LIST_FOR_EACH",
+        "DLB2_LIST_FOR_EACH_SAFE",
+        "ECORE_LIST_FOR_EACH_ENTRY",
+        "ECORE_LIST_FOR_EACH_ENTRY_SAFE",
+        "FOR_EACH",
+        "FOR_EACH_BUCKET",
+        "FOR_EACH_CNIC_QUEUE",
+        "FOR_EACH_COS_IN_TX_QUEUE",
+        "FOR_EACH_ETH_QUEUE",
+        "FOR_EACH_MEMBER",
+        "FOR_EACH_NONDEFAULT_ETH_QUEUE",
+        "FOR_EACH_NONDEFAULT_QUEUE",
+        "FOR_EACH_PORT",
+        "FOR_EACH_PORT_IF",
+        "FOR_EACH_QUEUE",
+        "FOR_EACH_SUITE_TESTCASE",
+        "FOR_EACH_SUITE_TESTSUITE",
+        "FOREACH_ABS_FUNC_IN_PORT",
+        "FOREACH_DEVICE_ON_AUXILIARY_BUS",
+        "FOREACH_DEVICE_ON_CDXBUS",
+        "FOREACH_DEVICE_ON_PCIBUS",
+        "FOREACH_DEVICE_ON_PLATFORM_BUS",
+        "FOREACH_DEVICE_ON_UACCEBUS",
+        "FOREACH_DEVICE_ON_VMBUS",
+        "FOREACH_DRIVER_ON_AUXILIARY_BUS",
+        "FOREACH_DRIVER_ON_CDXBUS",
+        "FOREACH_DRIVER_ON_PCIBUS",
+        "FOREACH_DRIVER_ON_PLATFORM_BUS",
+        "FOREACH_DRIVER_ON_UACCEBUS",
+        "FOREACH_DRIVER_ON_VMBUS",
+        "FOREACH_SUBDEV",
+        "FOREACH_SUBDEV_STATE",
+        "HLIST_FOR_EACH_ENTRY",
+        "ILIST_FOREACH",
+        "LIST_FOR_EACH_ENTRY",
+        "LIST_FOR_EACH_ENTRY_SAFE",
+        "LIST_FOREACH",
+        "LIST_FOREACH_FROM",
+        "LIST_FOREACH_FROM_SAFE",
+        "LIST_FOREACH_SAFE",
+        "ML_AVG_FOREACH_QP",
+        "ML_AVG_FOREACH_QP_MVTVM",
+        "ML_AVG_RESET_FOREACH_QP",
+        "ML_MAX_FOREACH_QP",
+        "ML_MAX_FOREACH_QP_MVTVM",
+        "ML_MAX_RESET_FOREACH_QP",
+        "ML_MIN_FOREACH_QP",
+        "ML_MIN_FOREACH_QP_MVTVM",
+        "ML_MIN_RESET_FOREACH_QP",
+        "MLX5_ETH_FOREACH_DEV",
+        "MLX5_IPOOL_FOREACH",
+        "MLX5_L3T_FOREACH",
+        "OSAL_LIST_FOR_EACH_ENTRY",
+        "OSAL_LIST_FOR_EACH_ENTRY_SAFE",
+        "PLT_TAILQ_FOREACH_SAFE",
+        "RTE_BBDEV_FOREACH",
+        "RTE_DEV_FOREACH",
+        "RTE_DMA_FOREACH_DEV",
+        "RTE_EAL_DEVARGS_FOREACH",
+        "RTE_ETH_FOREACH_DEV",
+        "RTE_ETH_FOREACH_DEV_OF",
+        "RTE_ETH_FOREACH_DEV_OWNED_BY",
+        "RTE_ETH_FOREACH_DEV_SIBLING",
+        "RTE_ETH_FOREACH_MATCHING_DEV",
+        "RTE_ETH_FOREACH_VALID_DEV",
+        "RTE_GPU_FOREACH",
+        "RTE_GPU_FOREACH_CHILD",
+        "RTE_GPU_FOREACH_PARENT",
+        "RTE_LCORE_FOREACH",
+        "RTE_LCORE_FOREACH_WORKER",
+        "RTE_TAILQ_FOREACH",
+        "RTE_TAILQ_FOREACH_SAFE",
+        "SILIST_FOREACH",
+        "SLIST_FOREACH",
+        "SLIST_FOREACH_FROM",
+        "SLIST_FOREACH_FROM_SAFE",
+        "SLIST_FOREACH_PREVPTR",
+        "SLIST_FOREACH_SAFE",
+        "STAILQ_FOREACH",
+        "STAILQ_FOREACH_FROM",
+        "STAILQ_FOREACH_FROM_SAFE",
+        "STAILQ_FOREACH_SAFE",
+        "TAILQ_FOREACH",
+        "TAILQ_FOREACH_ENTRY",
+        "TAILQ_FOREACH_ENTRY_SAFE",
+        "TAILQ_FOREACH_FROM",
+        "TAILQ_FOREACH_FROM_SAFE",
+        "TAILQ_FOREACH_REVERSE",
+        "TAILQ_FOREACH_REVERSE_FROM",
+        "TAILQ_FOREACH_REVERSE_FROM_SAFE",
+        "TAILQ_FOREACH_REVERSE_SAFE",
+        "TAILQ_FOREACH_SAFE", ]