Skip to content

Commit 00618cd

Browse files
committed
clang-format: disable include sorting and trailing comment alignment
Explained in comments. Minimal impact to existing .c code, but makes rendered code blocks in markdown easier to read. Signed-off-by: Timo Beckers <[email protected]>
1 parent 9f877e1 commit 00618cd

File tree

4 files changed

+11
-5
lines changed

4 files changed

+11
-5
lines changed

.clang-format

+6
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@ BasedOnStyle: LLVM
44
AlignAfterOpenBracket: DontAlign
55
AlignConsecutiveAssignments: true
66
AlignEscapedNewlines: DontAlign
7+
# mkdocs annotations in source code are written as trailing comments
8+
# and alignment pushes these really far away from the content.
9+
AlignTrailingComments: false
710
AlwaysBreakBeforeMultilineStrings: true
811
AlwaysBreakTemplateDeclarations: false
912
AllowAllParametersOfDeclarationOnNextLine: false
@@ -16,4 +19,7 @@ UseTab: ForContinuationAndIndentation
1619
ColumnLimit: 1000
1720
# Go compiler comments need to stay unindented.
1821
CommentPragmas: '^go:.*'
22+
# linux/bpf.h needs to be included before bpf/bpf_helpers.h for types like __u64
23+
# and sorting makes this impossible.
24+
SortIncludes: false
1925
...

btf/testdata/relocs_read_tgt.c

+3-3
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,10 @@ typedef unsigned long u64;
2020
struct bits {
2121
/*int x;*/
2222
u8 b : 2, a : 4; /* a was before b */
23-
my_u32 d : 2; /* was 'unsigned int' */
24-
u16 c : 1; /* was before d */
23+
my_u32 d : 2; /* was 'unsigned int' */
24+
u16 c : 1; /* was before d */
2525
enum { ZERO = 0, ONE = 1 } e : 1;
26-
u16 f; /* was: u64 f:16 */
26+
u16 f; /* was: u64 f:16 */
2727
u32 g : 30; /* was: u64 g:30 */
2828
};
2929

examples/xdp/xdp.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ char __license[] SEC("license") = "Dual MIT/GPL";
1111
struct {
1212
__uint(type, BPF_MAP_TYPE_LRU_HASH);
1313
__uint(max_entries, MAX_MAP_ENTRIES);
14-
__type(key, __u32); // source IPv4 address
14+
__type(key, __u32); // source IPv4 address
1515
__type(value, __u32); // packet count
1616
} xdp_stats_map SEC(".maps");
1717

testdata/loader.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ int __attribute__((noinline)) global_fn(uint32_t arg) {
112112
static volatile unsigned int key1 = 0; // .bss
113113
static volatile unsigned int key2 = 1; // .data
114114
volatile const unsigned int key3 = 2; // .rodata
115-
static volatile const uint32_t arg; // .rodata, populated by loader
115+
static volatile const uint32_t arg; // .rodata, populated by loader
116116
// custom .rodata section, populated by loader
117117
static volatile const uint32_t arg2 __section(".rodata.test");
118118
#endif

0 commit comments

Comments
 (0)