Skip to content

Commit 46d3863

Browse files
authored
fix build under clang (#45)
* fix build under clang * catch v2.0.1 → v2.13.10 * actions/checkout@v2 → v4 ``` stm32 Node.js 16 actions are deprecated. Please update the following actions to use Node.js 20: actions/checkout@v2. For more information see: https://github.blog/changelog/2023-09-22-github-actions-transitioning-from-node-16-to-node-20/. ``` * try to switch llvm 12 → 18 * try revert to clang-format-12 * try fix clang format/tidy issues * disable `modernize-macro-to-enum,` * disable readability-identifier-length & bugprone-easily-swappable-parameters * fix style
1 parent fdd4d79 commit 46d3863

File tree

8 files changed

+10887
-4934
lines changed

8 files changed

+10887
-4934
lines changed

.github/workflows/main.yml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ jobs:
1616
runs-on: ubuntu-latest
1717

1818
steps:
19-
- uses: actions/checkout@v2
19+
- uses: actions/checkout@v4
2020
with:
2121
submodules: 'recursive'
2222

@@ -44,23 +44,23 @@ jobs:
4444
stm32:
4545
runs-on: ubuntu-latest
4646
steps:
47-
- uses: actions/checkout@v2
47+
- uses: actions/checkout@v4
4848
with:
4949
submodules: 'recursive'
5050

5151
- name: Install Dependencies
5252
run: |
5353
sudo apt update
54-
wget https://apt.llvm.org/llvm.sh && chmod +x llvm.sh && sudo ./llvm.sh 12
55-
sudo apt install clang-tidy-12 clang-format-12
54+
wget https://apt.llvm.org/llvm.sh && chmod +x llvm.sh && sudo ./llvm.sh 18
55+
sudo apt install clang-tidy-18 clang-format-18
5656
5757
- name: Static analysis
5858
working-directory: ${{github.workspace}}/stm32/libcanard/bxcan/
59-
run: clang-tidy-12 src/*.c --extra-arg='-DBXCAN_MAX_IFACE_INDEX=1' --extra-arg='-DBXCAN_BUSYWAIT_DELAY_SYSTEM_CORE_CLOCK=72000000'
59+
run: clang-tidy-18 src/*.c --extra-arg='-DBXCAN_MAX_IFACE_INDEX=1' --extra-arg='-DBXCAN_BUSYWAIT_DELAY_SYSTEM_CORE_CLOCK=72000000'
6060

6161
- name: Format check
6262
working-directory: ${{github.workspace}}/stm32/libcanard/bxcan/
6363
run: |
64-
clang-format-12 -i -fallback-style=none -style=file --verbose src/*.[ch]
64+
clang-format-18 -i -fallback-style=none -style=file --verbose src/*.[ch]
6565
modified="$(git status --porcelain --untracked-files=no)"
6666
if [ -n "$modified" ]; then echo "Please format code properly."; exit 1; fi

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,3 +41,7 @@ build/
4141
cmake-build-*/
4242
__pycache__/
4343
dsdlc_generated/
44+
45+
# OS stuff
46+
.DS_Store
47+
*.bak

socketcan/libcanard/.clang-format

Lines changed: 29 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,67 +1,61 @@
1-
---
2-
Language: Cpp
3-
# BasedOnStyle: LLVM
1+
---
2+
Language: Cpp
3+
BasedOnStyle: LLVM
44
AccessModifierOffset: -4
55
AlignAfterOpenBracket: Align
66
AlignConsecutiveAssignments: true
77
AlignConsecutiveDeclarations: true
88
AlignEscapedNewlines: Left
9-
AlignOperands: true
9+
AlignOperands: true
1010
AlignTrailingComments: true
1111
AllowAllParametersOfDeclarationOnNextLine: false
12-
AllowShortBlocksOnASingleLine: false
12+
AllowShortBlocksOnASingleLine: Never
1313
AllowShortCaseLabelsOnASingleLine: false
14-
AllowShortFunctionsOnASingleLine: Inline
15-
AllowShortIfStatementsOnASingleLine: Never
14+
AllowShortFunctionsOnASingleLine: Empty
15+
AllowShortIfStatementsOnASingleLine: false
1616
AllowShortLoopsOnASingleLine: false
1717
AlwaysBreakAfterDefinitionReturnType: None
1818
AlwaysBreakAfterReturnType: None
1919
AlwaysBreakBeforeMultilineStrings: false
2020
AlwaysBreakTemplateDeclarations: Yes
2121
BinPackArguments: false
2222
BinPackParameters: false
23+
BreakBeforeBinaryOperators: None
24+
BreakBeforeBraces: Custom
2325
BraceWrapping:
24-
AfterCaseLabel: true
26+
SplitEmptyRecord: false
27+
AfterEnum: true
28+
AfterStruct: true
2529
AfterClass: true
2630
AfterControlStatement: true
27-
AfterEnum: true
2831
AfterFunction: true
29-
AfterNamespace: true
30-
AfterStruct: true
3132
AfterUnion: true
32-
BeforeCatch: true
33+
AfterNamespace: true
34+
AfterExternBlock: false
3335
BeforeElse: true
34-
IndentBraces: false
35-
SplitEmptyFunction: false
36-
SplitEmptyRecord: false
37-
SplitEmptyNamespace: false
38-
AfterExternBlock: false # Keeps the contents un-indented.
39-
BreakBeforeBinaryOperators: None
40-
BreakBeforeBraces: Custom
36+
4137
BreakBeforeTernaryOperators: true
42-
BreakConstructorInitializers: AfterColon
43-
# BreakInheritanceList: AfterColon
38+
BreakConstructorInitializers: BeforeComma
4439
BreakStringLiterals: true
45-
ColumnLimit: 120
46-
CommentPragmas: '^ (coverity|pragma:)'
40+
ColumnLimit: 120
41+
CommentPragmas: '^ (coverity|pragma:)'
4742
CompactNamespaces: false
48-
ConstructorInitializerAllOnOneLineOrOnePerLine: true
43+
ConstructorInitializerAllOnOneLineOrOnePerLine: false
4944
ConstructorInitializerIndentWidth: 4
5045
ContinuationIndentWidth: 4
5146
Cpp11BracedListStyle: true
5247
DerivePointerAlignment: false
53-
DisableFormat: false
54-
ExperimentalAutoDetectBinPacking: false
48+
DisableFormat: false
5549
FixNamespaceComments: true
56-
ForEachMacros: [ foreach, Q_FOREACH, BOOST_FOREACH ]
50+
ForEachMacros: [ foreach, Q_FOREACH, BOOST_FOREACH ]
5751
IncludeBlocks: Preserve
5852
IndentCaseLabels: false
5953
IndentPPDirectives: AfterHash
60-
IndentWidth: 4
54+
IndentWidth: 4
6155
IndentWrappedFunctionNames: false
6256
KeepEmptyLinesAtTheStartOfBlocks: false
6357
MacroBlockBegin: ''
64-
MacroBlockEnd: ''
58+
MacroBlockEnd: ''
6559
MaxEmptyLinesToKeep: 1
6660
NamespaceIndentation: None
6761
PenaltyBreakAssignment: 2
@@ -72,25 +66,21 @@ PenaltyBreakString: 1000
7266
PenaltyExcessCharacter: 1000000
7367
PenaltyReturnTypeOnItsOwnLine: 10000 # Raised intentionally because it hurts readability
7468
PointerAlignment: Left
75-
ReflowComments: true
76-
SortIncludes: false
69+
ReflowComments: true
70+
SortIncludes: Never
7771
SortUsingDeclarations: false
7872
SpaceAfterCStyleCast: true
7973
SpaceAfterTemplateKeyword: true
8074
SpaceBeforeAssignmentOperators: true
81-
SpaceBeforeCpp11BracedList: false
82-
SpaceBeforeInheritanceColon: true
8375
SpaceBeforeParens: ControlStatements
84-
SpaceBeforeCtorInitializerColon: true
85-
SpaceBeforeRangeBasedForLoopColon: true
8676
SpaceInEmptyParentheses: false
8777
SpacesBeforeTrailingComments: 2
88-
SpacesInAngles: false
78+
SpacesInAngles: false
8979
SpacesInCStyleCastParentheses: false
9080
SpacesInContainerLiterals: false
9181
SpacesInParentheses: false
9282
SpacesInSquareBrackets: false
93-
Standard: Cpp11
94-
TabWidth: 8
95-
UseTab: Never
83+
Standard: c++14
84+
TabWidth: 8
85+
UseTab: Never
9686
...

socketcan/libcanard/src/socketcan.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
#define KILO 1000L
3131
#define MEGA (KILO * KILO)
3232

33-
static int16_t getNegatedErrno()
33+
static int16_t getNegatedErrno(void)
3434
{
3535
const int out = -abs(errno);
3636
if (out < 0)

0 commit comments

Comments
 (0)