Build with -Wall

This commit is contained in:
topjohnwu 2019-04-29 21:26:43 -04:00
parent 8d68ebb074
commit 00a9f18a1e
8 changed files with 25 additions and 26 deletions

View File

@ -1,5 +1,5 @@
APP_ABI := armeabi-v7a x86 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} -D__MVSTR=${MAGISK_VERSION} -D__MCODE=${MAGISK_VER_CODE}
APP_LDFLAGS := -flto APP_LDFLAGS := -flto
APP_CPPFLAGS := -std=c++17 APP_CPPFLAGS := -std=c++17

View File

@ -207,7 +207,7 @@ void node_entry::create_module_tree(const char *module) {
void node_entry::clone_skeleton() { void node_entry::clone_skeleton() {
DIR *dir; DIR *dir;
struct dirent *entry; struct dirent *entry;
struct node_entry *dummy; node_entry *dummy;
// Clone the structure // Clone the structure
auto full_path = get_path(); auto full_path = get_path();

View File

@ -422,8 +422,8 @@ void LZ4FEncoder::write_header() {
FilterOutStream::write(outbuf, write); FilterOutStream::write(outbuf, write);
} }
LZ4Decoder::LZ4Decoder() : init(false), buf_off(0), total(0), block_sz(0), LZ4Decoder::LZ4Decoder() : outbuf(new char[LZ4_UNCOMPRESSED]), buf(new char[LZ4_COMPRESSED]),
outbuf(new char[LZ4_UNCOMPRESSED]), buf(new char[LZ4_COMPRESSED]) {} init(false), block_sz(0), buf_off(0), total(0) {}
LZ4Decoder::~LZ4Decoder() { LZ4Decoder::~LZ4Decoder() {
delete[] outbuf; delete[] outbuf;
@ -476,8 +476,8 @@ uint64_t LZ4Decoder::finalize() {
return total; return total;
} }
LZ4Encoder::LZ4Encoder() : init(false), buf_off(0), out_total(0), in_total(0), LZ4Encoder::LZ4Encoder() : outbuf(new char[LZ4_COMPRESSED]), buf(new char[LZ4_UNCOMPRESSED]),
outbuf(new char[LZ4_COMPRESSED]), buf(new char[LZ4_UNCOMPRESSED]) {} init(false), buf_off(0), out_total(0), in_total(0) {}
LZ4Encoder::~LZ4Encoder() { LZ4Encoder::~LZ4Encoder() {
delete[] outbuf; delete[] outbuf;

View File

@ -165,7 +165,7 @@ void magisk_cpio::backup(const char *orig) {
res = lhs->first.compare(rhs->first); res = lhs->first.compare(rhs->first);
} else if (lhs == o.entries.end()) { } else if (lhs == o.entries.end()) {
res = 1; res = 1;
} else if (rhs == entries.end()) { } else {
res = -1; res = -1;
} }

View File

@ -17,7 +17,7 @@
// 0x18000020 = FLAG_ACTIVITY_NEW_TASK|FLAG_ACTIVITY_MULTIPLE_TASK|FLAG_INCLUDE_STOPPED_PACKAGES // 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]) if (to->command[0])
return to->command; return to->command;
if (to->shell[0]) if (to->shell[0])
@ -25,21 +25,21 @@ static inline const char *get_command(const struct su_request *to) {
return DEFAULT_SHELL; 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", sprintf(user, "%d",
info->cfg[SU_MULTIUSER_MODE] == MULTIUSER_MODE_USER info->cfg[SU_MULTIUSER_MODE] == MULTIUSER_MODE_USER
? info->uid / 100000 ? info->uid / 100000
: 0); : 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", sprintf(uid, "%d",
info->cfg[SU_MULTIUSER_MODE] == MULTIUSER_MODE_OWNER_MANAGED info->cfg[SU_MULTIUSER_MODE] == MULTIUSER_MODE_OWNER_MANAGED
? info->uid % 100000 ? info->uid % 100000
: info->uid); : 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]; char component[128];
sprintf(component, "%s/a.m", info->str[SU_MANAGER].data()); sprintf(component, "%s/a.m", info->str[SU_MANAGER].data());
char user[8]; char user[8];
@ -62,7 +62,7 @@ static void silent_run(const char **args, struct su_info *info) {
exec_command(exec); exec_command(exec);
} }
void app_log(struct su_context *ctx) { void app_log(su_context *ctx) {
char fromUid[8]; char fromUid[8];
get_uid(fromUid, ctx->info); get_uid(fromUid, ctx->info);
@ -88,7 +88,7 @@ void app_log(struct su_context *ctx) {
silent_run(cmd, ctx->info); silent_run(cmd, ctx->info);
} }
void app_notify(struct su_context *ctx) { void app_notify(su_context *ctx) {
char fromUid[8]; char fromUid[8];
get_uid(fromUid, ctx->info); get_uid(fromUid, ctx->info);
@ -104,7 +104,7 @@ void app_notify(struct su_context *ctx) {
silent_run(cmd, ctx->info); 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[] = { const char *cmd[] = {
START_ACTIVITY, "request", START_ACTIVITY, "request",
"--es", "socket", socket, "--es", "socket", socket,
@ -113,7 +113,7 @@ void app_connect(const char *socket, struct su_info *info) {
silent_run(cmd, 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_key_token(fd, "uid", info->uid);
write_string_be(fd, "eof"); write_string_be(fd, "eof");
} }

View File

@ -83,7 +83,6 @@ static void pump_async(int input, int output) {
*/ */
int pts_open(char *slave_name, size_t slave_name_size) { int pts_open(char *slave_name, size_t slave_name_size) {
int fdm; int fdm;
char sn_tmp[256];
// Open master ptmx device // Open master ptmx device
fdm = open("/dev/ptmx", O_RDWR); fdm = open("/dev/ptmx", O_RDWR);

View File

@ -60,16 +60,16 @@ struct su_request : public su_req_base {
} __attribute__((packed)); } __attribute__((packed));
struct su_context { struct su_context {
struct su_info *info; su_info *info;
struct su_request req; su_request req;
pid_t pid; pid_t pid;
}; };
// connect.c // connect.c
void app_log(struct su_context *ctx); void app_log(su_context *ctx);
void app_notify(struct su_context *ctx); void app_notify(su_context *ctx);
void app_connect(const char *socket, struct su_info *info); void app_connect(const char *socket, su_info *info);
void socket_send_request(int fd, struct su_info *info); void socket_send_request(int fd, su_info *info);
#endif #endif

View File

@ -26,8 +26,8 @@ static pthread_mutex_t cache_lock = PTHREAD_MUTEX_INITIALIZER;
static su_info *cache; static su_info *cache;
su_info::su_info(unsigned uid) : su_info::su_info(unsigned uid) :
uid(uid), access(DEFAULT_SU_ACCESS), _lock(PTHREAD_MUTEX_INITIALIZER), uid(uid), count(0), access(DEFAULT_SU_ACCESS), mgr_st({}), ref(0),
count(0), ref(0), timestamp(0), mgr_st({}) {} timestamp(0), _lock(PTHREAD_MUTEX_INITIALIZER) {}
su_info::~su_info() { su_info::~su_info() {
pthread_mutex_destroy(&_lock); 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); 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; su_info *info = nullptr;
// Get from cache or new instance // Get from cache or new instance
@ -235,7 +235,7 @@ void su_daemon_handler(int client, struct ucred *credential) {
// Abort upon any error occurred // Abort upon any error occurred
log_cb.ex = exit; log_cb.ex = exit;
struct su_context ctx = { su_context ctx = {
.info = info, .info = info,
.pid = credential->pid .pid = credential->pid
}; };