From: "Abdullah Ömer Yamaç" <aomeryamac@gmail.com>
To: Stephen Hemminger <stephen@networkplumber.org>
Cc: Ferruh Yigit <ferruh.yigit@amd.com>, dev@dpdk.org, thomas@monjalon.net
Subject: Re: [PATCH] devtools: add .clang-format file
Date: Sat, 4 May 2024 16:38:03 +0300 [thread overview]
Message-ID: <CA+sj1i_PvUf-m5juUG2_sd178fBOw3Df7VstRxyJ5ycU4WCRuA@mail.gmail.com> (raw)
In-Reply-To: <20240429084356.58ac2bc8@hermes.local>
[-- Attachment #1: Type: text/plain, Size: 4421 bytes --]
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 == NULL) {
...
I will send the current configuration as v2. You can test it.
On Mon, Apr 29, 2024 at 6:43 PM Stephen Hemminger <
stephen@networkplumber.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 Ömer Yamaç 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>
> > >
> >
> > 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: unknown
> > 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: unknown
> > 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: unknown
> > 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 commented
> > 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[]
> = {
> > - {"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 = 0,
> > - STAT_QMAP_RX
> > -};
> > +enum { STAT_QMAP_TX = 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=C 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'
>
>
>
[-- Attachment #2: Type: text/html, Size: 5797 bytes --]
next prev parent reply other threads:[~2024-05-04 13:38 UTC|newest]
Thread overview: 34+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-04-29 13:04 Abdullah Ömer Yamaç
2024-04-29 13:32 ` Ferruh Yigit
2024-04-29 15:36 ` Stephen Hemminger
2024-04-29 15:43 ` Stephen Hemminger
2024-05-04 13:38 ` Abdullah Ömer Yamaç [this message]
2024-05-04 13:41 ` [PATCH v2] " Abdullah Ömer Yamaç
2024-05-04 16:27 ` Stephen Hemminger
2024-05-04 18:18 ` Abdullah Ömer Yamaç
2024-05-04 19:18 ` [PATCH v3] " Abdullah Ömer Yamaç
2024-05-05 16:18 ` Stephen Hemminger
2024-05-05 18:43 ` Abdullah Ömer Yamaç
2024-05-05 16:20 ` Stephen Hemminger
2024-05-05 19:42 ` Abdullah Ömer Yamaç
2024-05-05 20:38 ` Stephen Hemminger
2024-05-06 10:43 ` Abdullah Ömer Yamaç
2024-05-08 21:19 ` [PATCH v4] " Abdullah Ömer Yamaç
2024-05-13 13:08 ` Ferruh Yigit
2024-05-13 15:55 ` Stephen Hemminger
2024-05-13 19:11 ` Morten Brørup
2024-05-14 7:56 ` Bruce Richardson
2024-05-14 16:59 ` Tyler Retzlaff
2024-05-15 8:28 ` Abdullah Ömer Yamaç
2024-05-15 8:43 ` Bruce Richardson
2024-05-15 10:19 ` Abdullah Ömer Yamaç
2024-05-15 11:41 ` Bruce Richardson
2024-05-15 15:07 ` Stephen Hemminger
2024-05-15 20:32 ` Abdullah Ömer Yamaç
2024-05-16 8:20 ` [PATCH v5] " Abdullah Ömer Yamaç
2024-05-17 9:30 ` Bruce Richardson
2024-10-07 17:24 ` Stephen Hemminger
2024-10-14 22:15 ` [PATCH v6] " Abdullah Ömer Yamaç
2024-10-15 3:12 ` Stephen Hemminger
2024-10-14 22:16 ` Abdullah Ömer Yamaç
2024-04-30 21:27 ` [PATCH] " Abdullah Ömer Yamaç
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=CA+sj1i_PvUf-m5juUG2_sd178fBOw3Df7VstRxyJ5ycU4WCRuA@mail.gmail.com \
--to=aomeryamac@gmail.com \
--cc=dev@dpdk.org \
--cc=ferruh.yigit@amd.com \
--cc=stephen@networkplumber.org \
--cc=thomas@monjalon.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).