Tweak enum

This commit is contained in:
topjohnwu 2018-02-11 17:23:36 +08:00
parent 49ecba2476
commit 40b6fe03c2
4 changed files with 12 additions and 11 deletions

View File

@ -25,7 +25,7 @@ int is_daemon_init = 0, seperate_vendor = 0;
static void *request_handler(void *args) { static void *request_handler(void *args) {
int client = *((int *) args); int client = *((int *) args);
free(args); free(args);
client_request req = read_int(client); int req = read_int(client);
struct ucred credential; struct ucred credential;
get_client_cred(client, &credential); get_client_cred(client, &credential);

View File

@ -11,7 +11,7 @@
extern int is_daemon_init, seperate_vendor; extern int is_daemon_init, seperate_vendor;
// Commands require connecting to daemon // Commands require connecting to daemon
typedef enum { enum {
DO_NOTHING = 0, DO_NOTHING = 0,
LAUNCH_MAGISKHIDE, LAUNCH_MAGISKHIDE,
STOP_MAGISKHIDE, STOP_MAGISKHIDE,
@ -25,10 +25,10 @@ typedef enum {
POST_FS_DATA, POST_FS_DATA,
LATE_START, LATE_START,
TEST TEST
} client_request; };
// Return codes for daemon // Return codes for daemon
typedef enum { enum {
DAEMON_ERROR = -1, DAEMON_ERROR = -1,
DAEMON_SUCCESS = 0, DAEMON_SUCCESS = 0,
ROOT_REQUIRED, ROOT_REQUIRED,
@ -36,7 +36,7 @@ typedef enum {
HIDE_NOT_ENABLED, HIDE_NOT_ENABLED,
HIDE_ITEM_EXIST, HIDE_ITEM_EXIST,
HIDE_ITEM_NOT_EXIST, HIDE_ITEM_NOT_EXIST,
} daemon_response; };
// daemon.c // daemon.c

View File

@ -113,7 +113,7 @@ int rm_list(char *proc) {
return HIDE_NOT_ENABLED; return HIDE_NOT_ENABLED;
} }
daemon_response ret = DAEMON_ERROR; int ret = DAEMON_ERROR;
char *line; char *line;
int do_rm = 0; int do_rm = 0;
struct vector *new_list = xmalloc(sizeof(*new_list)); struct vector *new_list = xmalloc(sizeof(*new_list));

View File

@ -110,7 +110,7 @@ int magiskhide_main(int argc, char *argv[]) {
if (argc < 2) { if (argc < 2) {
usage(argv[0]); usage(argv[0]);
} }
client_request req = DO_NOTHING; int req = DO_NOTHING;
if (strcmp(argv[1], "--enable") == 0) { if (strcmp(argv[1], "--enable") == 0) {
req = LAUNCH_MAGISKHIDE; req = LAUNCH_MAGISKHIDE;
} else if (strcmp(argv[1], "--disable") == 0) { } else if (strcmp(argv[1], "--disable") == 0) {
@ -129,11 +129,8 @@ int magiskhide_main(int argc, char *argv[]) {
if (req == ADD_HIDELIST || req == RM_HIDELIST) { if (req == ADD_HIDELIST || req == RM_HIDELIST) {
write_string(fd, argv[2]); write_string(fd, argv[2]);
} }
daemon_response code = read_int(fd); int code = read_int(fd);
switch (code) { switch (code) {
case DAEMON_ERROR:
fprintf(stderr, "Error occured in daemon...\n");
return code;
case DAEMON_SUCCESS: case DAEMON_SUCCESS:
break; break;
case ROOT_REQUIRED: case ROOT_REQUIRED:
@ -151,6 +148,10 @@ int magiskhide_main(int argc, char *argv[]) {
case HIDE_ITEM_NOT_EXIST: case HIDE_ITEM_NOT_EXIST:
fprintf(stderr, "Process [%s] does not exist in hide list\n", argv[2]); fprintf(stderr, "Process [%s] does not exist in hide list\n", argv[2]);
return code; return code;
case DAEMON_ERROR:
default:
fprintf(stderr, "Error occured in daemon...\n");
return code;
} }
if (req == LS_HIDELIST) { if (req == LS_HIDELIST) {