From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 7EC8743F86; Sat, 4 May 2024 15:38:17 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 0A072402D5; Sat, 4 May 2024 15:38:17 +0200 (CEST) Received: from mail-oo1-f47.google.com (mail-oo1-f47.google.com [209.85.161.47]) by mails.dpdk.org (Postfix) with ESMTP id 744874014F for ; Sat, 4 May 2024 15:38:15 +0200 (CEST) Received: by mail-oo1-f47.google.com with SMTP id 006d021491bc7-5afbd1c3ffeso281857eaf.2 for ; Sat, 04 May 2024 06:38:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1714829894; x=1715434694; darn=dpdk.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=vai8ogfCMjKI1GvdQPa2OL4EEVrJUk7gIngypfXymF4=; b=IJlREOaCCBRwQc29bp/w3PEAi9mguvjr4odvP5+MDFscpjl8J+hKH2z3LRF5jDHfEm qRP8cgB8biRHQHHd0wItp8QiIp2jhQN0VT6VgAuBto+S4dPGT2S+qLXO3EZiVg6xZe+s dNjEysW1dowSjnAfh/sEA2oQjKptSZ+3v4RfcMeODiGwb4DuNfv4QvFn89+GvqKei0bV id+ZPhjoguJ6DcGiVUx5SOOx3M97cO30imIX9b7kw4DWEGvB3PyGf9kFQ1NSwyJ7/grC g7Tas/GdDlb9aQ2ukiqBtcqj0aPYNkMcPASLkaYc1CwuLN6j3rDqOiQxPU6j+ky4pjAW ctaQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1714829894; x=1715434694; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=vai8ogfCMjKI1GvdQPa2OL4EEVrJUk7gIngypfXymF4=; b=inJUUdg+4sGTULhpHhRDOjct1xjZE6ZECS5z0AU8ZCVjCidPbsrMPPXU4NbWGzQOG6 I63xxjGT4AhbGc2FpAX1+ADOJTZ/84X7O2g89YHSEAFZb/+O9+21/+WgA/VWhwq8ePRS KI28oRwaYLa2LcFj1WKjqmIHe+QDIq/BtbU3a/sonT9JE6aCAlQURmPW8MPCqKdwe8ln o2ZRdbIT8wNIBLwngJo9xyj566wVo3/oftgZBwRju90UIQ5b/RYOWfiuXgF8ScFuE8sE Crt9TI4bgiHDi7wnwWvEWsj6gapXRTJVM8DSBnF4UposxGXsi0oUjsA5k6F2T4zIZ5W8 IFOA== X-Forwarded-Encrypted: i=1; AJvYcCUyuX2Lgdj7nTsBByGdlANW1JAmtYQV1sPl0rGfYHtkuGad096wygNvOnICpFsCGC9Yv+iQonV0bF2gEdE= X-Gm-Message-State: AOJu0Yz/fbMVoImM67Ki84KdFusjcQRHwKfmliPPJ+bCCyc/FmVUVC6X 7Xwpkk8ZYEDz+1COwurt6ZalwMjwDv5aPbvu2pc58F3h52Z98EOyjqelMFRYgmx6WkUhXh0wgSm cLZm8H8sMmDlTMmSlWXmxc+Uic0CN6ZEx X-Google-Smtp-Source: AGHT+IFtH8Mo+zekKesC+0NkE85RBmSnpOY/zN6ETD3R23cOFbwSpHW4t03UAlYjlqbpDSWihOzQRW7KdgkHNi+XVvU= X-Received: by 2002:a05:6870:c78e:b0:22e:b354:f5ee with SMTP id dy14-20020a056870c78e00b0022eb354f5eemr4732959oab.15.1714829894330; Sat, 04 May 2024 06:38:14 -0700 (PDT) MIME-Version: 1.0 References: <20240429130414.1049310-1-aomeryamac@gmail.com> <64089d51-ed3c-4383-9014-920d772c9a98@amd.com> <20240429084356.58ac2bc8@hermes.local> In-Reply-To: <20240429084356.58ac2bc8@hermes.local> From: =?UTF-8?B?QWJkdWxsYWggw5ZtZXIgWWFtYcOn?= Date: Sat, 4 May 2024 16:38:03 +0300 Message-ID: Subject: Re: [PATCH] devtools: add .clang-format file To: Stephen Hemminger Cc: Ferruh Yigit , dev@dpdk.org, thomas@monjalon.net Content-Type: multipart/alternative; boundary="000000000000b3b3380617a0f24f" X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org --000000000000b3b3380617a0f24f Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Hello, I am facing a problem while creating the configuration. I am trying to make a clang-format that formats codes without changing any codebases. Here is the question: clang-format related config: ... BraceWrapping: AfterFunction: true ... If the configuration supports braces after function, then MACRO's formats fail. An example of the formatted MACRO is given below: ... #define RTE_RX_OFFLOAD_BIT2STR(_name) \ { \ ... If the AfterFunction is false, the functions' formats fail; here is a formatted example. ... if (devargs_str =3D=3D NULL) { ... I will send the current configuration as v2. You can test it. On Mon, Apr 29, 2024 at 6:43=E2=80=AFPM Stephen Hemminger < stephen@networkplumber.org> wrote: > On Mon, 29 Apr 2024 14:32:43 +0100 > Ferruh Yigit wrote: > > > On 4/29/2024 2:04 PM, Abdullah =C3=96mer Yama=C3=A7 wrote: > > > clang-format is a tool to format C/C++/Objective-C code. It can be us= ed > > > to reformat code to match a given coding style, or to ensure that cod= e > > > 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 =C3=96mer Yama=C3=A7 > > > > > > > Overall +1 to have a format file, specially to help non-frequent > > contributors. > > > > 1. Some options are failing for me [1], I don't know if it requires a > > specific version of clang-format > > > > 2. Current options are not fully aligned with coding convention, it is > > easier to see what is not compatible by running the tool on an existing > > file [2]. > > we need to fix them. > > > > > > > > [1] > > `clang-format -i ./lib/ethdev/rte_ethdev.c` > > a. > > /home/amd/development/dpdk-next-net/./.clang-format:28:1: error: unknow= n > > key 'Whitespace' > > Whitespace: > > ^~~~~~~~~~ > > Error reading /home/amd/development/dpdk-next-net/./.clang-format: > > Invalid argument > > > > b. > > /home/amd/development/dpdk-next-net/./.clang-format:12:1: error: unknow= n > > key 'EndOfLine' > > EndOfLine: lf > > ^~~~~~~~~ > > Error reading /home/amd/development/dpdk-next-net/./.clang-format: > > Invalid argument > > > > c. > > /home/amd/development/dpdk-next-net/./.clang-format:15:1: error: unknow= n > > key 'File' > > File: > > ^~~~ > > Error reading /home/amd/development/dpdk-next-net/./.clang-format: > > Invalid argument > > > > > > > > [2] > > `clang-format -i ./lib/ethdev/rte_ethdev.c` (with failing part commente= d > > out) > > `git diff` > > > > A few diff samples to fix at first glance: > > ``` > > static const struct rte_eth_xstats_name_off eth_dev_txq_stats_strings[= ] > =3D { > > - {"packets", offsetof(struct rte_eth_stats, q_opackets)}, > > - {"bytes", offsetof(struct rte_eth_stats, q_obytes)}, > > + {"packets", offsetof(struct rte_eth_stats, q_opackets)}, > > + {"bytes", offsetof(struct rte_eth_stats, q_obytes)}, > > }; > > ``` > > > > ``` > > -enum { > > - STAT_QMAP_TX =3D 0, > > - STAT_QMAP_RX > > -}; > > +enum { STAT_QMAP_TX =3D 0, STAT_QMAP_RX }; > > ``` > > > > ``` > > -int > > -rte_eth_iterator_init(struct rte_dev_iterator *iter, const char > > *devargs_str) > > +int rte_eth_iterator_init(struct rte_dev_iterator *iter, const char > > *devargs_str) > > ``` > > > > ``` > > RTE_ETH_FOREACH_DEV(p) > > Add this > > # Take from > # > # git grep -h '^#define [^[:space:]]*FOREACH[^[:space:]]*(' lib/ \ > # | sed "s,^#define \([^[:space:]]*FOREACH[^[:space:]]*\)(.*$, - '\1',"= \ > # | LC_ALL=3DC sort -u > ForeachMacros: > - 'CIRBUF_FOREACH' > - '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' > > > --000000000000b3b3380617a0f24f Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Hello,
I am facing a problem while creating the configu= ration. I am trying to make a clang-format that formats codes without chang= ing any codebases.=C2=A0Here is the question:

clang-format related c= onfig:
...
BraceWrapping:
=C2=A0 =C2=A0 =C2=A0 =C2=A0 AfterFunctio= n: true
...

If the configuration supports braces after function, = then MACRO's formats fail.=C2=A0

An example of the f= ormatted=C2=A0MACRO is given below:
...
#define RTE_RX_OFFLOAD_BIT2ST= R(_name) =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0\
{ =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0\
...
<= br>If the AfterFunction is false, the functions' formats fail; here is = a formatted example.
...
=C2=A0if (devargs_str =3D=3D NULL) {...

I will send the current configuration as v2. You can test it.= =C2=A0



On Mon, Apr 29, 2024 at 6:43=E2=80=AFPM Steph= en Hemminger <stephen@netw= orkplumber.org> wrote:
On Mon, 29 Apr 2024 14:32:43 +0100
Ferruh Yigit <= ferruh.yigit@amd.com> wrote:

> On 4/29/2024 2:04 PM, Abdullah =C3=96mer Yama=C3=A7 wrote:
> > clang-format is a tool to format C/C++/Objective-C code. It can b= e 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 consis= tent
> > coding style across the DPDK codebase.
> >
> > .clang-format file overrides the default style options provided b= y
> > clang-format and large set of IDEs and text editors support it. > >
> > Signed-off-by: Abdullah =C3=96mer Yama=C3=A7 <aomeryamac@gmail.com>
> >=C2=A0
>
> Overall +1 to have a format file, specially to help non-frequent
> contributors.
>
> 1. Some options are failing for me [1], I don't know if it require= s a
> specific version of clang-format
>
> 2. Current options are not fully aligned with coding convention, it is=
> easier to see what is not compatible by running the tool on an existin= g
> file [2].
> we need to fix them.
>
>
>
> [1]
> `clang-format -i ./lib/ethdev/rte_ethdev.c`
> a.
> /home/amd/development/dpdk-next-net/./.clang-format:28:1: error: unkno= wn
> key 'Whitespace'
> Whitespace:
> ^~~~~~~~~~
> Error reading /home/amd/development/dpdk-next-net/./.clang-format:
> Invalid argument
>
> b.
> /home/amd/development/dpdk-next-net/./.clang-format:12:1: error: unkno= wn
> key 'EndOfLine'
> EndOfLine: lf
> ^~~~~~~~~
> Error reading /home/amd/development/dpdk-next-net/./.clang-format:
> Invalid argument
>
> c.
> /home/amd/development/dpdk-next-net/./.clang-format:15:1: error: unkno= wn
> key 'File'
> File:
> ^~~~
> Error reading /home/amd/development/dpdk-next-net/./.clang-format:
> Invalid argument
>
>
>
> [2]
> `clang-format -i ./lib/ethdev/rte_ethdev.c` (with failing part comment= ed
> out)
> `git diff`
>
> A few diff samples to fix at first glance:
> ```
>=C2=A0 static const struct rte_eth_xstats_name_off eth_dev_txq_stats_st= rings[] =3D {
>=C2=A0 -=C2=A0 =C2=A0 =C2=A0 =C2=A0{"packets", offsetof(struc= t rte_eth_stats, q_opackets)},
>=C2=A0 -=C2=A0 =C2=A0 =C2=A0 =C2=A0{"bytes", offsetof(struct = rte_eth_stats, q_obytes)},
>=C2=A0 +=C2=A0 =C2=A0 {"packets", offsetof(struct rte_eth_sta= ts, q_opackets)},
>=C2=A0 +=C2=A0 =C2=A0 {"bytes", offsetof(struct rte_eth_stats= , q_obytes)},
>=C2=A0 };
> ```
>
> ```
>=C2=A0 -enum {
>=C2=A0 -=C2=A0 =C2=A0 =C2=A0 =C2=A0STAT_QMAP_TX =3D 0,
>=C2=A0 -=C2=A0 =C2=A0 =C2=A0 =C2=A0STAT_QMAP_RX
>=C2=A0 -};
>=C2=A0 +enum { STAT_QMAP_TX =3D 0, STAT_QMAP_RX };
> ```
>
> ```
>=C2=A0 -int
>=C2=A0 -rte_eth_iterator_init(struct rte_dev_iterator *iter, const char=
> *devargs_str)
>=C2=A0 +int rte_eth_iterator_init(struct rte_dev_iterator *iter, const = char
> *devargs_str)
> ```
>
> ```
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 RTE_ETH_FOREACH_DEV(p)

Add this

# Take from
#
# git grep -h '^#define [^[:space:]]*FOREACH[^[:space:]]*(' lib/ \<= br> #=C2=A0 | sed "s,^#define \([^[:space:]]*FOREACH[^[:space:]]*\)(.*$,= =C2=A0 - '\1'," \
#=C2=A0 | LC_ALL=3DC sort -u
ForeachMacros:
=C2=A0- 'CIRBUF_FOREACH'
=C2=A0 - 'RTE_BBDEV_FOREACH'
=C2=A0 - 'RTE_DEV_FOREACH'
=C2=A0 - 'RTE_DMA_FOREACH_DEV'
=C2=A0 - 'RTE_EAL_DEVARGS_FOREACH'
=C2=A0 - 'RTE_ETH_FOREACH_DEV'
=C2=A0 - 'RTE_ETH_FOREACH_DEV_OF'
=C2=A0 - 'RTE_ETH_FOREACH_DEV_OWNED_BY'
=C2=A0 - 'RTE_ETH_FOREACH_DEV_SIBLING'
=C2=A0 - 'RTE_ETH_FOREACH_MATCHING_DEV'
=C2=A0 - 'RTE_ETH_FOREACH_VALID_DEV'
=C2=A0 - 'RTE_GPU_FOREACH'
=C2=A0 - 'RTE_GPU_FOREACH_CHILD'
=C2=A0 - 'RTE_GPU_FOREACH_PARENT'
=C2=A0 - 'RTE_LCORE_FOREACH'
=C2=A0 - 'RTE_LCORE_FOREACH_WORKER'
=C2=A0 - 'RTE_TAILQ_FOREACH'
=C2=A0 - 'RTE_TAILQ_FOREACH_SAFE'


--000000000000b3b3380617a0f24f--