Skip to content

Commit 52faca1

Browse files
authored
Format code with clang-format v19 (#601)
Using a template taken from FreeBSD Add a github action to enforce this
1 parent 5524da4 commit 52faca1

68 files changed

Lines changed: 4559 additions & 4962 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.clang-format

Lines changed: 203 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,203 @@
1+
# Basic .clang-format taken from FreeBSD
2+
---
3+
BasedOnStyle: WebKit
4+
AlignAfterOpenBracket: DontAlign
5+
AlignConsecutiveMacros: AcrossEmptyLines
6+
AlignConsecutiveAssignments: false
7+
AlignConsecutiveDeclarations: false
8+
AlignEscapedNewlines: Left
9+
AlignOperands: false
10+
AlignTrailingComments: true
11+
AllowAllArgumentsOnNextLine: false
12+
AllowAllParametersOfDeclarationOnNextLine: false
13+
AllowShortBlocksOnASingleLine: Never
14+
AllowShortCaseLabelsOnASingleLine: false
15+
AllowShortFunctionsOnASingleLine: InlineOnly
16+
AllowShortIfStatementsOnASingleLine: Never
17+
AllowShortLoopsOnASingleLine: false
18+
AlwaysBreakAfterReturnType: TopLevelDefinitions
19+
AlwaysBreakBeforeMultilineStrings: false
20+
AlwaysBreakTemplateDeclarations: MultiLine
21+
BinPackArguments: true
22+
BinPackParameters: true
23+
BreakBeforeBinaryOperators: None
24+
BreakBeforeBraces: WebKit
25+
BreakBeforeTernaryOperators: false
26+
# TODO: BreakStringLiterals can cause very strange formatting so turn it off?
27+
BreakStringLiterals: false
28+
# Prefer:
29+
# some_var = function(arg1,
30+
# arg2)
31+
# over:
32+
# some_var =
33+
# function(arg1, arg2)
34+
PenaltyBreakAssignment: 100
35+
# Prefer:
36+
# some_long_function(arg1, arg2
37+
# arg3)
38+
# over:
39+
# some_long_function(
40+
# arg1, arg2, arg3)
41+
PenaltyBreakBeforeFirstCallParameter: 100
42+
CompactNamespaces: true
43+
DerivePointerAlignment: false
44+
DisableFormat: false
45+
ForEachMacros:
46+
- ARB_ARRFOREACH
47+
- ARB_ARRFOREACH_REVWCOND
48+
- ARB_ARRFOREACH_REVERSE
49+
- ARB_FOREACH
50+
- ARB_FOREACH_FROM
51+
- ARB_FOREACH_SAFE
52+
- ARB_FOREACH_REVERSE
53+
- ARB_FOREACH_REVERSE_FROM
54+
- ARB_FOREACH_REVERSE_SAFE
55+
- BIT_FOREACH_ISCLR
56+
- BIT_FOREACH_ISSET
57+
- CPU_FOREACH
58+
- CPU_FOREACH_ISCLR
59+
- CPU_FOREACH_ISSET
60+
- FOREACH_THREAD_IN_PROC
61+
- FOREACH_PROC_IN_SYSTEM
62+
- FOREACH_PRISON_CHILD
63+
- FOREACH_PRISON_DESCENDANT
64+
- FOREACH_PRISON_DESCENDANT_LOCKED
65+
- FOREACH_PRISON_DESCENDANT_LOCKED_LEVEL
66+
- MNT_VNODE_FOREACH_ALL
67+
- MNT_VNODE_FOREACH_ACTIVE
68+
- RB_FOREACH
69+
- RB_FOREACH_FROM
70+
- RB_FOREACH_SAFE
71+
- RB_FOREACH_REVERSE
72+
- RB_FOREACH_REVERSE_FROM
73+
- RB_FOREACH_REVERSE_SAFE
74+
- SLIST_FOREACH
75+
- SLIST_FOREACH_FROM
76+
- SLIST_FOREACH_FROM_SAFE
77+
- SLIST_FOREACH_SAFE
78+
- SLIST_FOREACH_PREVPTR
79+
- SPLAY_FOREACH
80+
- LIST_FOREACH
81+
- LIST_FOREACH_FROM
82+
- LIST_FOREACH_FROM_SAFE
83+
- LIST_FOREACH_SAFE
84+
- STAILQ_FOREACH
85+
- STAILQ_FOREACH_FROM
86+
- STAILQ_FOREACH_FROM_SAFE
87+
- STAILQ_FOREACH_SAFE
88+
- TAILQ_FOREACH
89+
- TAILQ_FOREACH_FROM
90+
- TAILQ_FOREACH_FROM_SAFE
91+
- TAILQ_FOREACH_REVERSE
92+
- TAILQ_FOREACH_REVERSE_FROM
93+
- TAILQ_FOREACH_REVERSE_FROM_SAFE
94+
- TAILQ_FOREACH_REVERSE_SAFE
95+
- TAILQ_FOREACH_SAFE
96+
- VM_MAP_ENTRY_FOREACH
97+
- VM_PAGE_DUMP_FOREACH
98+
SpaceBeforeParens: ControlStatementsExceptForEachMacros
99+
IndentCaseLabels: false
100+
IndentPPDirectives: None
101+
Language: Cpp
102+
NamespaceIndentation: None
103+
PointerAlignment: Right
104+
ContinuationIndentWidth: 4
105+
IndentWidth: 8
106+
TabWidth: 8
107+
ColumnLimit: 80
108+
UseTab: Always
109+
SpaceAfterCStyleCast: false
110+
IncludeBlocks: Regroup
111+
IncludeCategories:
112+
- Regex: '^\"opt_.*\.h\"'
113+
Priority: 1
114+
SortPriority: 10
115+
- Regex: '^<sys/cdefs\.h>'
116+
Priority: 2
117+
SortPriority: 20
118+
- Regex: '^<sys/types\.h>'
119+
Priority: 2
120+
SortPriority: 21
121+
- Regex: '^<sys/param\.h>'
122+
Priority: 2
123+
SortPriority: 22
124+
- Regex: '^<sys/systm\.h>'
125+
Priority: 2
126+
SortPriority: 23
127+
- Regex: '^<sys.*/'
128+
Priority: 2
129+
SortPriority: 24
130+
- Regex: '^<vm/vm\.h>'
131+
Priority: 3
132+
SortPriority: 30
133+
- Regex: '^<vm/'
134+
Priority: 3
135+
SortPriority: 31
136+
- Regex: '^<machine/'
137+
Priority: 4
138+
SortPriority: 40
139+
- Regex: '^<(x86|amd64|i386|xen)/'
140+
Priority: 5
141+
SortPriority: 50
142+
- Regex: '^<dev/'
143+
Priority: 6
144+
SortPriority: 60
145+
# Most BSD require <netinet/in.h> before this ...
146+
- Regex: '^<netinet/if_ether.h>'
147+
Priority: 7
148+
SortPriority: 71
149+
- Regex: '^<net.*/'
150+
Priority: 7
151+
SortPriority: 70
152+
- Regex: '^<protocols/'
153+
Priority: 7
154+
SortPriority: 72
155+
- Regex: '^<(fs|nfs(|client|server)|ufs)/'
156+
Priority: 8
157+
SortPriority: 80
158+
- Regex: '^<[^/].*\.h'
159+
Priority: 9
160+
SortPriority: 90
161+
- Regex: '^\".*\.h\"'
162+
Priority: 10
163+
SortPriority: 100
164+
# LLVM's header include ordering style is almost the exact opposite of ours.
165+
# Unfortunately, they have hard-coded their preferences into clang-format.
166+
# Clobbering this regular expression to avoid matching prevents non-system
167+
# headers from being forcibly moved to the top of the include list.
168+
# http://llvm.org/docs/CodingStandards.html#include-style
169+
IncludeIsMainRegex: 'BLAH_DONT_MATCH_ANYTHING'
170+
SortIncludes: true
171+
KeepEmptyLinesAtTheStartOfBlocks: false
172+
TypenameMacros:
173+
- ARB_ELMTYPE
174+
- ARB_HEAD
175+
- ARB8_HEAD
176+
- ARB16_HEAD
177+
- ARB32_HEAD
178+
- ARB_ENTRY
179+
- ARB8_ENTRY
180+
- ARB16_ENTRY
181+
- ARB32_ENTRY
182+
- LIST_CLASS_ENTRY
183+
- LIST_CLASS_HEAD
184+
- LIST_ENTRY
185+
- LIST_HEAD
186+
- QUEUE_TYPEOF
187+
- RB_ENTRY
188+
- RB_HEAD
189+
- SLIST_CLASS_HEAD
190+
- SLIST_CLASS_ENTRY
191+
- SLIST_HEAD
192+
- SLIST_ENTRY
193+
- SMR_POINTER
194+
- SPLAY_ENTRY
195+
- SPLAY_HEAD
196+
- STAILQ_CLASS_ENTRY
197+
- STAILQ_CLASS_HEAD
198+
- STAILQ_ENTRY
199+
- STAILQ_HEAD
200+
- TAILQ_CLASS_ENTRY
201+
- TAILQ_CLASS_HEAD
202+
- TAILQ_ENTRY
203+
- TAILQ_HEAD

.clang-tidy

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Disable DeprecatedOrUnsafeBufferHandling - our use of these is fine
2+
# and musl does not support the the _s variants.
3+
# Disable valist due to clang-tidy bug fixed in v19?
4+
Checks: "cert-*,-clang-analyzer-security.insecureAPI.DeprecatedOrUnsafeBufferHandling,-clang-analyzer-valist.Uninitialized"
5+
HeaderFilterRegex: ".*"

.clangd

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
If:
22
PathMatch: src/dev/.*\.c
33
CompileFlags:
4-
Add: [-I.., -I../.., -I../../compat]
4+
Add: [-I.., -I../.., -I../../compat, -I../../vendor]
55
---
66
If:
7-
PathMatch: src/.*\.c
7+
PathMatch: src/.*\.(c|h)
88
CompileFlags:
9-
Add: [-I.., -I../compat]
9+
Add: [-I.., -I../compat, -I../vendor]
1010
---
1111
CompileFlags:
1212
Add: [-DINET, -DARP, -DARPING, -DIPV4LL, -DINET6, -DDHCP6, -DPLUGIN_DEV, -DAUTH, -DPRIVSEP]

.github/workflows/build.yml

Lines changed: 83 additions & 81 deletions
Original file line numberDiff line numberDiff line change
@@ -28,84 +28,86 @@ jobs:
2828
- name: Tests
2929
run: make tests
3030

31-
openbsd:
32-
runs-on: ubuntu-latest
33-
steps:
34-
- name: Bootstrap OpenBSD-latest
35-
uses: mario-campos/emulate@v1
36-
with:
37-
operating-system: openbsd-latest
38-
39-
- name: Install Dependencies
40-
run: pkg_add git
41-
42-
- name: Build
43-
run: |
44-
git clone --depth=1 "${{ github.server_url }}/${{ github.repository }}" build
45-
cd build
46-
[ "${{ github.event.pull_request.number }}" = "" ] || (echo "fetching PR ${{ github.event.pull_request.number }}"; git fetch origin pull/${{ github.event.pull_request.number }}/head:pr-${{ github.event.pull_request.number }} && git checkout "pr-${{ github.event.pull_request.number }}")
47-
./configure
48-
make
49-
50-
- name: Tests
51-
run: |
52-
ulimit -n 1024
53-
cd build
54-
make tests
55-
56-
freebsd:
57-
runs-on: ubuntu-latest
58-
steps:
59-
- name: Bootstrap FreeBSD-latest
60-
uses: mario-campos/emulate@v1
61-
with:
62-
operating-system: freebsd-latest
63-
64-
- name: Install Dependencies
65-
run: pkg install -y git
66-
67-
- name: Build
68-
run: |
69-
git clone --depth=1 "${{ github.server_url }}/${{ github.repository }}" build
70-
cd build
71-
[ "${{ github.event.pull_request.number }}" = "" ] || (echo "fetching PR ${{ github.event.pull_request.number }}"; git fetch origin pull/${{ github.event.pull_request.number }}/head:pr-${{ github.event.pull_request.number }} && git checkout "pr-${{ github.event.pull_request.number }}")
72-
./configure
73-
make
74-
75-
- name: Tests
76-
run: |
77-
cd build
78-
make tests
79-
80-
netbsd:
81-
strategy:
82-
matrix:
83-
args:
84-
-
85-
- --disable-ipv4
86-
- --disable-arp
87-
- --disable-ipv4ll
88-
- --disable-ipv6
89-
- --disable-dhcp6
90-
cppflags:
91-
-
92-
- -DSMALL
93-
runs-on: ubuntu-latest
94-
steps:
95-
- name: Bootstrap NetBSD-latest
96-
uses: mario-campos/emulate@v1
97-
with:
98-
operating-system: netbsd-latest
99-
100-
- name: Build
101-
run: |
102-
git clone --depth=1 "${{ github.server_url }}/${{ github.repository }}" build
103-
cd build
104-
[ "${{ github.event.pull_request.number }}" = "" ] || (echo "fetching PR ${{ github.event.pull_request.number }}"; git fetch origin pull/${{ github.event.pull_request.number }}/head:pr-${{ github.event.pull_request.number }} && git checkout "pr-${{ github.event.pull_request.number }}")
105-
CFLAGS=-Werror CPPFLAGS="${{ matrix.cppflags }}" ./configure ${{ matrix.args }}
106-
make
107-
108-
- name: Tests
109-
run: |
110-
cd build
111-
make tests
31+
# Sadly the BSDs have stopped building ....
32+
33+
# openbsd:
34+
# runs-on: ubuntu-latest
35+
# steps:
36+
# - name: Bootstrap OpenBSD-latest
37+
# uses: mario-campos/emulate@v1
38+
# with:
39+
# operating-system: openbsd-latest
40+
41+
# - name: Install Dependencies
42+
# run: pkg_add git
43+
44+
# - name: Build
45+
# run: |
46+
# git clone --depth=1 "${{ github.server_url }}/${{ github.repository }}" build
47+
# cd build
48+
# [ "${{ github.event.pull_request.number }}" = "" ] || (echo "fetching PR ${{ github.event.pull_request.number }}"; git fetch origin pull/${{ github.event.pull_request.number }}/head:pr-${{ github.event.pull_request.number }} && git checkout "pr-${{ github.event.pull_request.number }}")
49+
# ./configure
50+
# make
51+
52+
# - name: Tests
53+
# run: |
54+
# ulimit -n 1024
55+
# cd build
56+
# make tests
57+
58+
# freebsd:
59+
# runs-on: ubuntu-latest
60+
# steps:
61+
# - name: Bootstrap FreeBSD-latest
62+
# uses: mario-campos/emulate@v1
63+
# with:
64+
# operating-system: freebsd-latest
65+
66+
# - name: Install Dependencies
67+
# run: pkg install -y git
68+
69+
# - name: Build
70+
# run: |
71+
# git clone --depth=1 "${{ github.server_url }}/${{ github.repository }}" build
72+
# cd build
73+
# [ "${{ github.event.pull_request.number }}" = "" ] || (echo "fetching PR ${{ github.event.pull_request.number }}"; git fetch origin pull/${{ github.event.pull_request.number }}/head:pr-${{ github.event.pull_request.number }} && git checkout "pr-${{ github.event.pull_request.number }}")
74+
# ./configure
75+
# make
76+
77+
# - name: Tests
78+
# run: |
79+
# cd build
80+
# make tests
81+
82+
# netbsd:
83+
# strategy:
84+
# matrix:
85+
# args:
86+
# -
87+
# - --disable-ipv4
88+
# - --disable-arp
89+
# - --disable-ipv4ll
90+
# - --disable-ipv6
91+
# - --disable-dhcp6
92+
# cppflags:
93+
# -
94+
# - -DSMALL
95+
# runs-on: ubuntu-latest
96+
# steps:
97+
# - name: Bootstrap NetBSD-latest
98+
# uses: mario-campos/emulate@v1
99+
# with:
100+
# operating-system: netbsd-latest
101+
102+
# - name: Build
103+
# run: |
104+
# git clone --depth=1 "${{ github.server_url }}/${{ github.repository }}" build
105+
# cd build
106+
# [ "${{ github.event.pull_request.number }}" = "" ] || (echo "fetching PR ${{ github.event.pull_request.number }}"; git fetch origin pull/${{ github.event.pull_request.number }}/head:pr-${{ github.event.pull_request.number }} && git checkout "pr-${{ github.event.pull_request.number }}")
107+
# CFLAGS=-Werror CPPFLAGS="${{ matrix.cppflags }}" ./configure ${{ matrix.args }}
108+
# make
109+
110+
# - name: Tests
111+
# run: |
112+
# cd build
113+
# make tests

0 commit comments

Comments
 (0)