Skip to content

Commit 6ccb48f

Browse files
committed
all: reformat C/C++ files
1 parent d43aeb5 commit 6ccb48f

36 files changed

+578
-471
lines changed

pkg/kfuzztest/testdata/common.h

Lines changed: 29 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@
1212
#include <stdint.h>
1313

1414
struct kfuzztest_target {
15-
const char *name;
16-
const char *arg_type_name;
15+
const char* name;
16+
const char* arg_type_name;
1717
uintptr_t write_input_cb;
1818
} __attribute__((aligned(32)));
1919

@@ -28,8 +28,8 @@ enum kfuzztest_constraint_type {
2828
};
2929

3030
struct kfuzztest_constraint {
31-
const char *input_type;
32-
const char *field_name;
31+
const char* input_type;
32+
const char* field_name;
3333
uintptr_t value1;
3434
uintptr_t value2;
3535
enum kfuzztest_constraint_type type;
@@ -42,40 +42,40 @@ enum kfuzztest_annotation_attribute {
4242
};
4343

4444
struct kfuzztest_annotation {
45-
const char *input_type;
46-
const char *field_name;
47-
const char *linked_field_name;
45+
const char* input_type;
46+
const char* field_name;
47+
const char* linked_field_name;
4848
enum kfuzztest_annotation_attribute attrib;
4949
} __attribute__((aligned(32)));
5050

51-
#define DEFINE_FUZZ_TARGET(test_name, test_arg_type) \
52-
struct kfuzztest_target __fuzz_test__##test_name \
53-
__attribute__((section(".kfuzztest_target"), __used__)) = { \
54-
.name = #test_name, \
55-
.arg_type_name = #test_arg_type, \
56-
}; \
57-
/* Avoid the compiler optimizing out the struct definition. */ \
51+
#define DEFINE_FUZZ_TARGET(test_name, test_arg_type) \
52+
struct kfuzztest_target __fuzz_test__##test_name \
53+
__attribute__((section(".kfuzztest_target"), __used__)) = { \
54+
.name = #test_name, \
55+
.arg_type_name = #test_arg_type, \
56+
}; \
57+
/* Avoid the compiler optimizing out the struct definition. */ \
5858
static test_arg_type arg;
5959

6060
#define DEFINE_CONSTRAINT(arg_type, field, val1, val2, tpe) \
6161
static struct kfuzztest_constraint __constraint_##arg_type##_##field \
62-
__attribute__((section(".kfuzztest_constraint"), \
63-
__used__)) = { \
64-
.input_type = "struct " #arg_type, \
65-
.field_name = #field, \
66-
.value1 = (uintptr_t)val1, \
67-
.value2 = (uintptr_t)val2, \
68-
.type = tpe, \
69-
}
62+
__attribute__((section(".kfuzztest_constraint"), \
63+
__used__)) = { \
64+
.input_type = "struct " #arg_type, \
65+
.field_name = #field, \
66+
.value1 = (uintptr_t)val1, \
67+
.value2 = (uintptr_t)val2, \
68+
.type = tpe, \
69+
}
7070

7171
#define DEFINE_ANNOTATION(arg_type, field, linked_field, attribute) \
7272
static struct kfuzztest_annotation __annotation_##arg_type##_##field \
73-
__attribute__((section(".kfuzztest_annotation"), \
74-
__used__)) = { \
75-
.input_type = "struct " #arg_type, \
76-
.field_name = #field, \
77-
.linked_field_name = #linked_field, \
78-
.attrib = attribute, \
79-
}
73+
__attribute__((section(".kfuzztest_annotation"), \
74+
__used__)) = { \
75+
.input_type = "struct " #arg_type, \
76+
.field_name = #field, \
77+
.linked_field_name = #linked_field, \
78+
.attrib = attribute, \
79+
}
8080

8181
#endif /* COMMON_H */

tools/android/jni/sandbox_test.c

Lines changed: 32 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,55 @@
11
#define GOOS_linux 1
22
#define SYZ_SANDBOX_ANDROID_UNTRUSTED_APP 1
33
#define SYZ_USE_TMP_DIR 1
4-
#define fail(...) do { dprintf(2, __VA_ARGS__); dprintf(2, "\n"); perror("errno"); exit(1); } while(0)
5-
#define error(...) do { dprintf(2, __VA_ARGS__); } while(0)
6-
#define debug(...) do { dprintf(2, __VA_ARGS__); } while(0)
4+
#define fail(...) \
5+
do { \
6+
dprintf(2, __VA_ARGS__); \
7+
dprintf(2, "\n"); \
8+
perror("errno"); \
9+
exit(1); \
10+
} while (0)
11+
#define error(...) \
12+
do { \
13+
dprintf(2, __VA_ARGS__); \
14+
} while (0)
15+
#define debug(...) \
16+
do { \
17+
dprintf(2, __VA_ARGS__); \
18+
} while (0)
719

820
#include <stdlib.h>
921
#include <string.h>
1022

1123
void doexit(int status)
1224
{
13-
exit(status);
25+
exit(status);
1426
}
1527

16-
static void loop() {
17-
exit(system("id"));
28+
static void loop()
29+
{
30+
exit(system("id"));
1831
}
1932

2033
static void use_temporary_dir(void)
2134
{
2235
#if SYZ_SANDBOX_ANDROID_UNTRUSTED_APP
23-
char tmpdir_template[] = "/data/data/syzkaller/syzkaller.XXXXXX";
36+
char tmpdir_template[] = "/data/data/syzkaller/syzkaller.XXXXXX";
2437
#else
25-
char tmpdir_template[] = "./syzkaller.XXXXXX";
38+
char tmpdir_template[] = "./syzkaller.XXXXXX";
2639
#endif
27-
char* tmpdir = mkdtemp(tmpdir_template);
28-
if (!tmpdir)
29-
fail("failed to mkdtemp");
30-
if (chmod(tmpdir, 0777))
31-
fail("failed to chmod");
32-
if (chdir(tmpdir))
33-
fail("failed to chdir");
40+
char* tmpdir = mkdtemp(tmpdir_template);
41+
if (!tmpdir)
42+
fail("failed to mkdtemp");
43+
if (chmod(tmpdir, 0777))
44+
fail("failed to chmod");
45+
if (chdir(tmpdir))
46+
fail("failed to chdir");
3447
}
3548

36-
37-
3849
#include "executor/common_linux.h"
3950

40-
int main() {
41-
use_temporary_dir();
42-
do_sandbox_android_untrusted_app();
51+
int main()
52+
{
53+
use_temporary_dir();
54+
do_sandbox_android_untrusted_app();
4355
}

tools/syz-declextract/testdata/cover.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@
88
#define COVER_IOCTL3 3
99
#define COVER_IOCTL4 4
1010

11-
static void cover_helper(int cmd) {
11+
static void cover_helper(int cmd)
12+
{
1213
int tmp = 0;
1314
tmp++;
1415
switch (cmd) {
@@ -20,7 +21,8 @@ static void cover_helper(int cmd) {
2021
}
2122
}
2223

23-
SYSCALL_DEFINE1(cover, int cmd) {
24+
SYSCALL_DEFINE1(cover, int cmd)
25+
{
2426
int tmp = 0;
2527
tmp++;
2628
switch (cmd) {
Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
SYSCALL cover func:__do_sys_cover loc:22 coverage:75 access:unknown manual_desc:false auto_desc:true file:cover.c subsystem:kernel
2-
SYSCALL cover$COVER_IOCTL1 func:__do_sys_cover loc:7 coverage:100 access:unknown manual_desc:false auto_desc:true file:cover.c subsystem:kernel
3-
SYSCALL cover$COVER_IOCTL2 func:__do_sys_cover loc:7 coverage:67 access:unknown manual_desc:false auto_desc:true file:cover.c subsystem:kernel
4-
SYSCALL cover$COVER_IOCTL3 func:__do_sys_cover loc:15 coverage:100 access:unknown manual_desc:false auto_desc:true file:cover.c subsystem:kernel
5-
SYSCALL cover$COVER_IOCTL4 func:__do_sys_cover loc:16 coverage:80 access:unknown manual_desc:false auto_desc:true file:cover.c subsystem:kernel
1+
SYSCALL cover func:__do_sys_cover loc:24 coverage:75 access:unknown manual_desc:false auto_desc:true file:cover.c subsystem:kernel
2+
SYSCALL cover$COVER_IOCTL1 func:__do_sys_cover loc:8 coverage:67 access:unknown manual_desc:false auto_desc:true file:cover.c subsystem:kernel
3+
SYSCALL cover$COVER_IOCTL2 func:__do_sys_cover loc:8 coverage:100 access:unknown manual_desc:false auto_desc:true file:cover.c subsystem:kernel
4+
SYSCALL cover$COVER_IOCTL3 func:__do_sys_cover loc:17 coverage:84 access:unknown manual_desc:false auto_desc:true file:cover.c subsystem:kernel
5+
SYSCALL cover$COVER_IOCTL4 func:__do_sys_cover loc:18 coverage:100 access:unknown manual_desc:false auto_desc:true file:cover.c subsystem:kernel

tools/syz-declextract/testdata/cover.c.json

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
{
44
"name": "__do_sys_cover",
55
"file": "cover.c",
6-
"start_line": 23,
7-
"end_line": 37,
6+
"start_line": 24,
7+
"end_line": 39,
88
"scopes": [
99
{
1010
"arg": -1,
@@ -28,25 +28,25 @@
2828
"values": [
2929
"COVER_IOCTL1"
3030
],
31-
"start_line": 27,
32-
"end_line": 29
31+
"start_line": 29,
32+
"end_line": 31
3333
},
3434
{
3535
"arg": 0,
3636
"values": [
3737
"COVER_IOCTL2"
3838
],
39-
"start_line": 29,
40-
"end_line": 31
39+
"start_line": 31,
40+
"end_line": 33
4141
},
4242
{
4343
"arg": 0,
4444
"values": [
4545
"COVER_IOCTL3",
4646
"COVER_IOCTL4"
4747
],
48-
"start_line": 31,
49-
"end_line": 35,
48+
"start_line": 33,
49+
"end_line": 37,
5050
"calls": [
5151
"cover_helper"
5252
],
@@ -73,7 +73,7 @@
7373
"name": "cover_helper",
7474
"file": "cover.c",
7575
"start_line": 11,
76-
"end_line": 21,
76+
"end_line": 22,
7777
"is_static": true,
7878
"scopes": [
7979
{
@@ -84,16 +84,16 @@
8484
"values": [
8585
"COVER_IOCTL3"
8686
],
87-
"start_line": 15,
88-
"end_line": 17
87+
"start_line": 16,
88+
"end_line": 18
8989
},
9090
{
9191
"arg": 0,
9292
"values": [
9393
"COVER_IOCTL4"
9494
],
95-
"start_line": 17,
96-
"end_line": 20
95+
"start_line": 18,
96+
"end_line": 21
9797
}
9898
]
9999
}
Lines changed: 52 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
// Copyright 2024 syzkaller project authors. All rights reserved.
22
// Use of this source code is governed by Apache 2 LICENSE that can be found in the LICENSE file.
33

4-
#include "include/fs.h"
54
#include "include/uapi/file_operations.h"
5+
#include "include/fs.h"
66
#include "include/uapi/unused_ioctl.h"
77

88
enum {
@@ -13,21 +13,33 @@ enum {
1313
config_foo
1414
};
1515

16-
static void foo_open() {}
17-
static void foo_read() {}
18-
static void foo_write() {}
19-
static void foo_mmap() {}
20-
static void foo_mmap2() {}
16+
static void foo_open()
17+
{
18+
}
19+
static void foo_read()
20+
{
21+
}
22+
static void foo_write()
23+
{
24+
}
25+
static void foo_mmap()
26+
{
27+
}
28+
static void foo_mmap2()
29+
{
30+
}
2131

22-
static void foo_ioctl2(unsigned int cmd, unsigned long arg) {
32+
static void foo_ioctl2(unsigned int cmd, unsigned long arg)
33+
{
2334
switch (cmd) {
2435
case FOO_IOCTL6:
2536
case FOO_IOCTL7:
2637
default:
2738
}
2839
}
2940

30-
static void foo_ioctl(void* file, unsigned int cmd, unsigned long arg) {
41+
static void foo_ioctl(void* file, unsigned int cmd, unsigned long arg)
42+
{
3143
switch (cmd) {
3244
case FOO_IOCTL1:
3345
case FOO_IOCTL2:
@@ -42,41 +54,50 @@ static void foo_ioctl(void* file, unsigned int cmd, unsigned long arg) {
4254
}
4355

4456
const struct file_operations foo = {
45-
.open = foo_open,
46-
.read = foo_read,
47-
.write = foo_write,
48-
.unlocked_ioctl = foo_ioctl,
49-
// Such code happens after macro expansion,
50-
// we want to extract the first function name.
51-
.mmap = ((config_foo) ? foo_mmap : foo_mmap2),
57+
.open = foo_open,
58+
.read = foo_read,
59+
.write = foo_write,
60+
.unlocked_ioctl = foo_ioctl,
61+
// Such code happens after macro expansion,
62+
// we want to extract the first function name.
63+
.mmap = ((config_foo) ? foo_mmap : foo_mmap2),
5264
};
5365

54-
static void proc_open() {}
55-
static void proc_read() {}
56-
static void proc_write() {}
57-
static void proc_ioctl(void* file, unsigned int cmd, unsigned long arg) {}
66+
static void proc_open()
67+
{
68+
}
69+
static void proc_read()
70+
{
71+
}
72+
static void proc_write()
73+
{
74+
}
75+
static void proc_ioctl(void* file, unsigned int cmd, unsigned long arg)
76+
{
77+
}
5878

5979
const struct file_operations proc_ops[] = {
60-
{
61-
.open = proc_open,
62-
.read_iter = proc_read,
63-
.write_iter = proc_write,
64-
},
65-
{
66-
.open = proc_open,
67-
.unlocked_ioctl = proc_ioctl,
68-
},
80+
{
81+
.open = proc_open,
82+
.read_iter = proc_read,
83+
.write_iter = proc_write,
84+
},
85+
{
86+
.open = proc_open,
87+
.unlocked_ioctl = proc_ioctl,
88+
},
6989
};
7090

71-
#define UNUSED_IOCTL2 _IO('c', 2)
91+
#define UNUSED_IOCTL2 _IO('c', 2)
7292

73-
static void unused_ioctl(void* file, unsigned int cmd, unsigned long arg) {
93+
static void unused_ioctl(void* file, unsigned int cmd, unsigned long arg)
94+
{
7495
switch (cmd) {
7596
case UNUSED_IOCTL1:
7697
case UNUSED_IOCTL2:
7798
}
7899
}
79100

80101
const struct file_operations unused = {
81-
.unlocked_ioctl = unused_ioctl,
102+
.unlocked_ioctl = unused_ioctl,
82103
};

0 commit comments

Comments
 (0)