public inbox for dev@dpdk.org
 help / color / mirror / Atom feed
From: Stephen Hemminger <stephen@networkplumber.org>
To: "Abdullah Ömer Yamaç" <aomeryamac@gmail.com>
Cc: dev@dpdk.org
Subject: Re: [PATCH v6] devtools: add .clang-format file
Date: Tue, 13 Jan 2026 21:13:30 -0800	[thread overview]
Message-ID: <20260113211331.3fb0de98@phoenix.local> (raw)
In-Reply-To: <20241014221545.66810-1-aomeryamac@gmail.com>

On Mon, 14 Oct 2024 22:15:45 +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>
> ---

Adding a clang-format would be good, but the patch never got reviewed.
I was a little concerned that the new clang-format would have some
style conflicts with current DPDK usage; so I asked AI.
Please consider these proposed changes and resubmit.


## Patch Review: devtools: add .clang-format file

### Commit Message Analysis

| Check | Status | Notes |
|-------|--------|-------|
| Subject ≤60 chars | ✅ | 39 characters |
| Lowercase after colon | ✅ | "add .clang-format file" |
| Imperative mood | ✅ | "add" |
| No trailing period | ✅ | |
| Signed-off-by | ✅ | Present with real name and email |
| Body ≤75 chars | ✅ | Lines are within limit |

**Warning**: The prefix `devtools:` is potentially misleading since the `.clang-format` file is being added to the repository root, not to the `devtools/` directory. Consider using a prefix like `style:` or `build:`, or simply omit the prefix for root-level config files.

---

### Clang-Format Settings Review

#### ✅ Correct Settings

| Setting | Value | DPDK Requirement | Status |
|---------|-------|------------------|--------|
| `ColumnLimit` | 100 | 100 chars max | ✅ |
| `TabWidth` | 8 | 8 characters | ✅ |
| `IndentWidth` | 8 | 8 characters | ✅ |
| `LineEnding` | LF | Unix line endings | ✅ |
| `InsertNewlineAtEOF` | true | Files end with newline | ✅ |
| `AfterFunction` | true | Brace on new line for functions | ✅ |
| `AfterControlStatement` | false | Brace on same line for if/for/while | ✅ |
| `IncludeBlocks` | Preserve | Don't reorder include groups | ✅ |
| `SortIncludes` | Never | Preserve include order | ✅ |
| `AlwaysBreakAfterReturnType` | TopLevelDefinitions | Return type on own line | ✅ |
| `IndentGotoLabels` | false | Labels not indented | ✅ |
| `ForEachMacros` | comprehensive list | Treat as loops | ✅ |

#### ⚠️ Issues to Address

**1. UseTab Setting (Warning)**

```yaml
UseTab: Always
```

DPDK style specifies: *"hard tabs for indentation, spaces for alignment"*

`UseTab: Always` will use tabs everywhere including for alignment, which can cause misalignment when viewed with different tab widths. Consider:

```yaml
UseTab: ForIndentation
```

**2. Missing Pointer Alignment (Warning)**

DPDK follows Linux kernel style where the `*` binds to the variable name:
```c
char *ptr;      /* Correct */
char* ptr;      /* Wrong */
```

Add:
```yaml
PointerAlignment: Right
```

**3. Missing Space After Cast (Info)**

DPDK style typically has no space after casts. Consider adding:
```yaml
SpaceAfterCStyleCast: false
```

**4. Missing Short Function Settings (Info)**

To prevent unwanted single-line functions:
```yaml
AllowShortFunctionsOnASingleLine: None
AllowShortBlocksOnASingleLine: Never
```

**5. Missing Brace Wrapping Settings (Info)**

The `BraceWrapping` section is incomplete. For full DPDK compliance, consider:
```yaml
BraceWrapping:
        AfterFunction: true
        AfterControlStatement: false
        AfterStruct: false
        AfterEnum: false
        AfterUnion: false
        BeforeElse: false
        BeforeWhile: false
        SplitEmptyFunction: true
```

**6. Switch Statement Indentation (Info)**

DPDK style shows `case` labels not indented relative to `switch`. Add:
```yaml
IndentCaseLabels: false
IndentCaseBlocks: false
```

**7. BasedOnStyle Consideration (Info)**

`BasedOnStyle: LLVM` is a reasonable starting point, but Linux kernel style (`BasedOnStyle: Kernel` if available in your clang-format version) might be closer to DPDK's actual style since DPDK is modeled on Linux kernel development.

---

### Summary

| Severity | Count | Items |
|----------|-------|-------|
| **Error** | 0 | None |
| **Warning** | 2 | `UseTab: Always` should be `ForIndentation`; Missing `PointerAlignment: Right` |
| **Info** | 5 | Subject prefix; Missing short function settings; Incomplete brace wrapping; Missing switch indent settings; Space after cast |

**Recommendation**: The patch is a solid foundation but needs the pointer alignment and tab usage fixes before merge. The current `UseTab: Always` setting will cause alignment issues in multi-line function arguments and struct initializers, and the missing `PointerAlignment: Right` will format pointers contrary to DPDK convention.

  parent reply	other threads:[~2026-01-14  5:13 UTC|newest]

Thread overview: 35+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-04-29 13:04 [PATCH] devtools: add .clang-format file 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ç
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
2026-01-14  5:13                                         ` Stephen Hemminger [this message]
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=20260113211331.3fb0de98@phoenix.local \
    --to=stephen@networkplumber.org \
    --cc=aomeryamac@gmail.com \
    --cc=dev@dpdk.org \
    /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