From 00a9f18a1e14a7e151d9f18310cf4209a47112e4 Mon Sep 17 00:00:00 2001 From: topjohnwu Date: Mon, 29 Apr 2019 21:26:43 -0400 Subject: [PATCH] Build with -Wall --- native/jni/Application.mk | 2 +- native/jni/core/bootstages.cpp | 2 +- native/jni/magiskboot/compress.cpp | 8 ++++---- native/jni/magiskboot/ramdisk.cpp | 2 +- native/jni/su/connect.cpp | 16 ++++++++-------- native/jni/su/pts.cpp | 1 - native/jni/su/su.h | 12 ++++++------ native/jni/su/su_daemon.cpp | 8 ++++---- 8 files changed, 25 insertions(+), 26 deletions(-) diff --git a/native/jni/Application.mk b/native/jni/Application.mk index ee8363d2f..a3f7a5990 100644 --- a/native/jni/Application.mk +++ b/native/jni/Application.mk @@ -1,5 +1,5 @@ APP_ABI := armeabi-v7a x86 -APP_CFLAGS := -Oz -fomit-frame-pointer -flto \ +APP_CFLAGS := -Wall -Oz -fomit-frame-pointer -flto \ -D__MVSTR=${MAGISK_VERSION} -D__MCODE=${MAGISK_VER_CODE} APP_LDFLAGS := -flto APP_CPPFLAGS := -std=c++17 diff --git a/native/jni/core/bootstages.cpp b/native/jni/core/bootstages.cpp index a2f2c3b2a..84bd15e9f 100644 --- a/native/jni/core/bootstages.cpp +++ b/native/jni/core/bootstages.cpp @@ -207,7 +207,7 @@ void node_entry::create_module_tree(const char *module) { void node_entry::clone_skeleton() { DIR *dir; struct dirent *entry; - struct node_entry *dummy; + node_entry *dummy; // Clone the structure auto full_path = get_path(); diff --git a/native/jni/magiskboot/compress.cpp b/native/jni/magiskboot/compress.cpp index 7a50f1069..936b3bda0 100644 --- a/native/jni/magiskboot/compress.cpp +++ b/native/jni/magiskboot/compress.cpp @@ -422,8 +422,8 @@ void LZ4FEncoder::write_header() { FilterOutStream::write(outbuf, write); } -LZ4Decoder::LZ4Decoder() : init(false), buf_off(0), total(0), block_sz(0), -outbuf(new char[LZ4_UNCOMPRESSED]), buf(new char[LZ4_COMPRESSED]) {} +LZ4Decoder::LZ4Decoder() : outbuf(new char[LZ4_UNCOMPRESSED]), buf(new char[LZ4_COMPRESSED]), +init(false), block_sz(0), buf_off(0), total(0) {} LZ4Decoder::~LZ4Decoder() { delete[] outbuf; @@ -476,8 +476,8 @@ uint64_t LZ4Decoder::finalize() { return total; } -LZ4Encoder::LZ4Encoder() : init(false), buf_off(0), out_total(0), in_total(0), -outbuf(new char[LZ4_COMPRESSED]), buf(new char[LZ4_UNCOMPRESSED]) {} +LZ4Encoder::LZ4Encoder() : outbuf(new char[LZ4_COMPRESSED]), buf(new char[LZ4_UNCOMPRESSED]), +init(false), buf_off(0), out_total(0), in_total(0) {} LZ4Encoder::~LZ4Encoder() { delete[] outbuf; diff --git a/native/jni/magiskboot/ramdisk.cpp b/native/jni/magiskboot/ramdisk.cpp index d613f59a0..07a6ac3e7 100644 --- a/native/jni/magiskboot/ramdisk.cpp +++ b/native/jni/magiskboot/ramdisk.cpp @@ -165,7 +165,7 @@ void magisk_cpio::backup(const char *orig) { res = lhs->first.compare(rhs->first); } else if (lhs == o.entries.end()) { res = 1; - } else if (rhs == entries.end()) { + } else { res = -1; } diff --git a/native/jni/su/connect.cpp b/native/jni/su/connect.cpp index fca409354..f68997f18 100644 --- a/native/jni/su/connect.cpp +++ b/native/jni/su/connect.cpp @@ -17,7 +17,7 @@ // 0x18000020 = FLAG_ACTIVITY_NEW_TASK|FLAG_ACTIVITY_MULTIPLE_TASK|FLAG_INCLUDE_STOPPED_PACKAGES -static inline const char *get_command(const struct su_request *to) { +static inline const char *get_command(const su_request *to) { if (to->command[0]) return to->command; if (to->shell[0]) @@ -25,21 +25,21 @@ static inline const char *get_command(const struct su_request *to) { return DEFAULT_SHELL; } -static inline void get_user(char *user, struct su_info *info) { +static inline void get_user(char *user, su_info *info) { sprintf(user, "%d", info->cfg[SU_MULTIUSER_MODE] == MULTIUSER_MODE_USER ? info->uid / 100000 : 0); } -static inline void get_uid(char *uid, struct su_info *info) { +static inline void get_uid(char *uid, su_info *info) { sprintf(uid, "%d", info->cfg[SU_MULTIUSER_MODE] == MULTIUSER_MODE_OWNER_MANAGED ? info->uid % 100000 : info->uid); } -static void silent_run(const char **args, struct su_info *info) { +static void silent_run(const char **args, su_info *info) { char component[128]; sprintf(component, "%s/a.m", info->str[SU_MANAGER].data()); char user[8]; @@ -62,7 +62,7 @@ static void silent_run(const char **args, struct su_info *info) { exec_command(exec); } -void app_log(struct su_context *ctx) { +void app_log(su_context *ctx) { char fromUid[8]; get_uid(fromUid, ctx->info); @@ -88,7 +88,7 @@ void app_log(struct su_context *ctx) { silent_run(cmd, ctx->info); } -void app_notify(struct su_context *ctx) { +void app_notify(su_context *ctx) { char fromUid[8]; get_uid(fromUid, ctx->info); @@ -104,7 +104,7 @@ void app_notify(struct su_context *ctx) { silent_run(cmd, ctx->info); } -void app_connect(const char *socket, struct su_info *info) { +void app_connect(const char *socket, su_info *info) { const char *cmd[] = { START_ACTIVITY, "request", "--es", "socket", socket, @@ -113,7 +113,7 @@ void app_connect(const char *socket, struct su_info *info) { silent_run(cmd, info); } -void socket_send_request(int fd, struct su_info *info) { +void socket_send_request(int fd, su_info *info) { write_key_token(fd, "uid", info->uid); write_string_be(fd, "eof"); } diff --git a/native/jni/su/pts.cpp b/native/jni/su/pts.cpp index 2b8243b35..7fa7fec5e 100644 --- a/native/jni/su/pts.cpp +++ b/native/jni/su/pts.cpp @@ -83,7 +83,6 @@ static void pump_async(int input, int output) { */ int pts_open(char *slave_name, size_t slave_name_size) { int fdm; - char sn_tmp[256]; // Open master ptmx device fdm = open("/dev/ptmx", O_RDWR); diff --git a/native/jni/su/su.h b/native/jni/su/su.h index c4a38f72d..4d7822c02 100644 --- a/native/jni/su/su.h +++ b/native/jni/su/su.h @@ -60,16 +60,16 @@ struct su_request : public su_req_base { } __attribute__((packed)); struct su_context { - struct su_info *info; - struct su_request req; + su_info *info; + su_request req; pid_t pid; }; // connect.c -void app_log(struct su_context *ctx); -void app_notify(struct su_context *ctx); -void app_connect(const char *socket, struct su_info *info); -void socket_send_request(int fd, struct su_info *info); +void app_log(su_context *ctx); +void app_notify(su_context *ctx); +void app_connect(const char *socket, su_info *info); +void socket_send_request(int fd, su_info *info); #endif diff --git a/native/jni/su/su_daemon.cpp b/native/jni/su/su_daemon.cpp index f2fa0dfe2..3d69bddda 100644 --- a/native/jni/su/su_daemon.cpp +++ b/native/jni/su/su_daemon.cpp @@ -26,8 +26,8 @@ static pthread_mutex_t cache_lock = PTHREAD_MUTEX_INITIALIZER; static su_info *cache; su_info::su_info(unsigned uid) : - uid(uid), access(DEFAULT_SU_ACCESS), _lock(PTHREAD_MUTEX_INITIALIZER), - count(0), ref(0), timestamp(0), mgr_st({}) {} + uid(uid), count(0), access(DEFAULT_SU_ACCESS), mgr_st({}), ref(0), + timestamp(0), _lock(PTHREAD_MUTEX_INITIALIZER) {} su_info::~su_info() { pthread_mutex_destroy(&_lock); @@ -90,7 +90,7 @@ static void database_check(su_info *info) { validate_manager(info->str[SU_MANAGER], uid / 100000, &info->mgr_st); } -static struct su_info *get_su_info(unsigned uid) { +static su_info *get_su_info(unsigned uid) { su_info *info = nullptr; // Get from cache or new instance @@ -235,7 +235,7 @@ void su_daemon_handler(int client, struct ucred *credential) { // Abort upon any error occurred log_cb.ex = exit; - struct su_context ctx = { + su_context ctx = { .info = info, .pid = credential->pid };