Skip to content

Commit 89b7eb6

Browse files
Tests: Indent the loop C reference with spaces
The remove-tabs pre-commit hook rejects tab indentation outside docs/ and Makefiles, which failed the Format job.
1 parent 5fb3c8d commit 89b7eb6

1 file changed

Lines changed: 40 additions & 40 deletions

File tree

‎tests/c-form/loops.bpf.c‎

Lines changed: 40 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -19,61 +19,61 @@ __s64 n = 10;
1919
SEC("tracepoint/syscalls/sys_enter_execve")
2020
__s64 range_sum(void *ctx)
2121
{
22-
__s64 total = 0;
23-
for (__s64 idx = 0; idx < 10; idx += 1) {
24-
__s64 i = idx;
25-
total = total + 1;
26-
}
27-
return total;
22+
__s64 total = 0;
23+
for (__s64 idx = 0; idx < 10; idx += 1) {
24+
__s64 i = idx;
25+
total = total + 1;
26+
}
27+
return total;
2828
}
2929

3030
/* for i in range(0, 10, 2): total = total + i */
3131
SEC("tracepoint/syscalls/sys_enter_execve")
3232
__s64 range_step(void *ctx)
3333
{
34-
__s64 total = 0;
35-
for (__s64 idx = 0; idx < 10; idx += 2) {
36-
__s64 i = idx;
37-
total = total + i;
38-
}
39-
return total;
34+
__s64 total = 0;
35+
for (__s64 idx = 0; idx < 10; idx += 2) {
36+
__s64 i = idx;
37+
total = total + i;
38+
}
39+
return total;
4040
}
4141

4242
/* while i < 10: i = i + 1 */
4343
SEC("tracepoint/syscalls/sys_enter_execve")
4444
__s64 while_basic(void *ctx)
4545
{
46-
__s64 i = 0;
47-
while (i < 10)
48-
i = i + 1;
49-
return i;
46+
__s64 i = 0;
47+
while (i < 10)
48+
i = i + 1;
49+
return i;
5050
}
5151

5252
/* while True: total += 1; if total == 10: break */
5353
SEC("tracepoint/syscalls/sys_enter_execve")
5454
__s64 while_true_break(void *ctx)
5555
{
56-
__s64 total = 0;
57-
while (1) {
58-
total = total + 1;
59-
if (total == 10)
60-
break;
61-
}
62-
return total;
56+
__s64 total = 0;
57+
while (1) {
58+
total = total + 1;
59+
if (total == 10)
60+
break;
61+
}
62+
return total;
6363
}
6464

6565
/* for i in range(10): if i % 2 == 0: continue; total = total + i */
6666
SEC("tracepoint/syscalls/sys_enter_execve")
6767
__s64 for_continue(void *ctx)
6868
{
69-
__s64 total = 0;
70-
for (__s64 idx = 0; idx < 10; idx += 1) {
71-
__s64 i = idx;
72-
if (i % 2 == 0)
73-
continue;
74-
total = total + i;
75-
}
76-
return total;
69+
__s64 total = 0;
70+
for (__s64 idx = 0; idx < 10; idx += 1) {
71+
__s64 i = idx;
72+
if (i % 2 == 0)
73+
continue;
74+
total = total + i;
75+
}
76+
return total;
7777
}
7878

7979
static __u32 (*bpf_get_prandom_u32)(void) = (void *)7;
@@ -85,13 +85,13 @@ static __u32 (*bpf_get_prandom_u32)(void) = (void *)7;
8585
SEC("tracepoint/syscalls/sys_enter_execve")
8686
__s64 dyn_helper(void *ctx)
8787
{
88-
__s64 total = 0;
89-
__s64 stop = n;
90-
if (stop > 64)
91-
stop = 64;
92-
for (__s64 idx = 0; idx < stop; idx += 1) {
93-
__s64 i = idx;
94-
total = total + bpf_get_prandom_u32();
95-
}
96-
return total;
88+
__s64 total = 0;
89+
__s64 stop = n;
90+
if (stop > 64)
91+
stop = 64;
92+
for (__s64 idx = 0; idx < stop; idx += 1) {
93+
__s64 i = idx;
94+
total = total + bpf_get_prandom_u32();
95+
}
96+
return total;
9797
}

0 commit comments

Comments
 (0)