File | Lines added | Lines deleted |
---|---|---|
README.md | 41 | 0 |
tests/func-ptr.c | 13 | 0 |
tests/main.c | 35 | 0 |
tests/util.c | 9 | 0 |
File README.md changed (mode: 100644) (index bcbe6b2..dc5d766) | |||
... | ... | functions: | |
8 | 8 | - functions declared as `extern` which are used only locally and thus can be | - functions declared as `extern` which are used only locally and thus can be |
9 | 9 | made `static`. | made `static`. |
10 | 10 | ||
11 | Example | ||
12 | ------- | ||
13 | |||
14 | Input: | ||
15 | |||
16 | ```c | ||
17 | static void firstStatic(void); | ||
18 | static void secondStatic(void); | ||
19 | |||
20 | void firstExtern(void); | ||
21 | |||
22 | extern void secondExtern(void); | ||
23 | |||
24 | static void firstStatic(void) { } | ||
25 | static void secondStatic(void) { } | ||
26 | |||
27 | void firstExtern(void) { } | ||
28 | void secondExtern(void) { } | ||
29 | |||
30 | int | ||
31 | main(void) | ||
32 | { | ||
33 | firstExtern(); | ||
34 | secondStatic(); | ||
35 | return 0; | ||
36 | } | ||
37 | ``` | ||
38 | |||
39 | Run command: | ||
40 | |||
41 | ```sh | ||
42 | bin/unused-funcs main.c -- | ||
43 | ``` | ||
44 | |||
45 | Output (paths are truncated): | ||
46 | |||
47 | ``` | ||
48 | .../main.c:20:firstExtern:can be made static | ||
49 | .../main.c:25:secondExtern:unused | ||
50 | ``` | ||
51 | |||
11 | 52 | Building | Building |
12 | 53 | -------- | -------- |
13 | 54 |
File tests/func-ptr.c added (mode: 100644) (index 0000000..25fea85) | |||
1 | void | ||
2 | func(void) | ||
3 | { | ||
4 | } | ||
5 | |||
6 | int | ||
7 | main(void) | ||
8 | { | ||
9 | void (*f)(void) = func; | ||
10 | void (*f2)(void) = &func; | ||
11 | f(); | ||
12 | return 0; | ||
13 | } |
File tests/main.c added (mode: 100644) (index 0000000..cbca7dc) | |||
1 | static void firstStatic(void); | ||
2 | |||
3 | static void secondStatic(void); | ||
4 | |||
5 | void firstExtern(void); | ||
6 | |||
7 | extern void secondExtern(void); | ||
8 | |||
9 | static void | ||
10 | firstStatic(void) | ||
11 | { | ||
12 | } | ||
13 | |||
14 | static void | ||
15 | secondStatic(void) | ||
16 | { | ||
17 | } | ||
18 | |||
19 | void | ||
20 | firstExtern(void) | ||
21 | { | ||
22 | } | ||
23 | |||
24 | void | ||
25 | secondExtern(void) | ||
26 | { | ||
27 | } | ||
28 | |||
29 | int | ||
30 | main(void) | ||
31 | { | ||
32 | firstExtern(); | ||
33 | secondStatic(); | ||
34 | return 0; | ||
35 | } |
File tests/util.c added (mode: 100644) (index 0000000..d1be9e9) | |||
1 | extern void firstExtern(void); | ||
2 | void secondExtern(void); | ||
3 | |||
4 | void | ||
5 | thirdExtern(void) | ||
6 | { | ||
7 | firstExtern(); | ||
8 | secondExtern(); | ||
9 | } |