Skip to content

Commit 172c51a

Browse files
authored
improve: cleanup headers and code (#324)
This commit removes unused headers and resolves some variable typing issues, or notes to the next people that might run static analyzers in them.
1 parent 709cb9d commit 172c51a

36 files changed

Lines changed: 163 additions & 197 deletions

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
.clangd
2+
.clang-format
23
.gradle
34
.idea
45
.vscode

loader/src/common/daemon.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
11
#include <stdio.h>
22
#include <stdlib.h>
33
#include <stdbool.h>
4-
#include <sys/socket.h>
4+
#include <string.h>
5+
#include <errno.h>
56

67
#include <linux/un.h>
8+
#include <sys/socket.h>
79

810
#include "logging.h"
11+
#include "misc.h"
912
#include "socket_utils.h"
1013

1114
#include "daemon.h"
@@ -20,7 +23,7 @@ int rezygiskd_connect(uint8_t retry) {
2023
.sun_path = { 0 }
2124
};
2225

23-
/*
26+
/*
2427
INFO: Application must assume that sun_path can hold _POSIX_PATH_MAX characters.
2528
2629
Sources:

loader/src/common/elf_util.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
#include <stdlib.h>
2-
#include <stdint.h>
32
#include <stdbool.h>
3+
#include <stdint.h>
44
#include <string.h>
5+
56
#include <fcntl.h>
7+
#include <sys/auxv.h>
68
#include <sys/mman.h>
79
#include <sys/stat.h>
8-
#include <sys/auxv.h>
910

1011
#include <unistd.h>
1112

@@ -736,7 +737,7 @@ ElfW(Addr) getSymbOffset(ElfImg *img, const char *name, unsigned char *sym_type)
736737
This function is based on AOSP's (Android Open Source Project) code, and resolves the
737738
indirect symbol, leading to the correct, most appropriate for the hardware, symbol.
738739
739-
SOURCES:
740+
SOURCES:
740741
- https://android.googlesource.com/platform/bionic/+/refs/tags/android-16.0.0_r1/linker/linker.cpp#2594
741742
- https://android.googlesource.com/platform/bionic/+/tags/android-16.0.0_r1/libc/bionic/bionic_call_ifunc_resolver.cpp#41
742743
*/

loader/src/common/misc.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#include <stdio.h>
2+
23
#include <sys/utsname.h>
34

45
#include "logging.h"

loader/src/common/socket_utils.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
#include <stdlib.h>
2+
#include <string.h>
23
#include <errno.h>
3-
#include <sys/socket.h>
44

55
#include <unistd.h>
6+
#include <sys/socket.h>
67

78
#include "logging.h"
89

loader/src/include/daemon.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@
55

66
#include <unistd.h>
77

8-
#include "misc.h"
9-
108
enum rezygiskd_actions {
119
ZygoteInjected,
1210
GetProcessFlags,
@@ -73,4 +71,4 @@ bool rezygiskd_update_mns(enum mount_namespace_state nms_state, char *buf, size_
7371

7472
bool rezygiskd_remove_module(size_t index);
7573

76-
#endif /* DAEMON_H */
74+
#endif /* DAEMON_H */

loader/src/include/elf_util.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,8 @@
11
#ifndef ELF_UTIL_H
22
#define ELF_UTIL_H
33

4-
#include <stdbool.h>
5-
#include <string.h>
64
#include <link.h>
75
#include <sys/types.h>
8-
#include <pthread.h>
96

107
#define SHT_GNU_HASH 0x6ffffff6
118

loader/src/include/logging.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
#ifndef LOGGING_H
22
#define LOGGING_H
33

4-
#include <android/log.h>
5-
64
#include <errno.h>
75
#include <string.h>
86

7+
#include <android/log.h>
8+
99
#include "misc.h"
1010

1111
#ifndef LOG_TAG
@@ -26,4 +26,4 @@
2626
#define LOGF(...) __android_log_print(ANDROID_LOG_FATAL, LOG_TAG, __VA_ARGS__)
2727
#define PLOGE(fmt, args...) LOGE(fmt " failed with %d: %s", ##args, errno, strerror(errno))
2828

29-
#endif /* LOGGING_H */
29+
#endif /* LOGGING_H */

loader/src/include/socket_utils.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33

44
#include <stdint.h>
55

6+
#include <sys/types.h>
7+
68
ssize_t write_loop(int fd, const void *buf, size_t count);
79

810
ssize_t read_loop_offset(int fd, void *buf, size_t len, off_t off);
@@ -12,7 +14,7 @@ ssize_t read_loop(int fd, void *buf, size_t len);
1214
int read_fd(int fd);
1315

1416
ssize_t write_string(int fd, const char *str);
15-
17+
1618
char *read_string(int fd);
1719

1820
#define write_func_def(type) \
@@ -30,4 +32,4 @@ read_func_def(uint32_t);
3032
write_func_def(size_t);
3133
read_func_def(size_t);
3234

33-
#endif /* SOCKET_UTILS_H */
35+
#endif /* SOCKET_UTILS_H */

loader/src/injector/art_method.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
#define ART_METHOD_H
33

44
#include <stdbool.h>
5-
#include <stdint.h>
65
#include <stddef.h>
6+
#include <stdint.h>
77

88
#include <jni.h>
99

0 commit comments

Comments
 (0)