mirror of
https://github.com/topjohnwu/Magisk.git
synced 2025-12-03 12:21:53 +00:00
Migrate exec function to C++ arrays
This commit is contained in:
@@ -115,29 +115,15 @@ static struct node_entry *insert_child(struct node_entry *p, struct node_entry *
|
||||
* setenvs *
|
||||
***********/
|
||||
|
||||
static void set_path(struct vector *v) {
|
||||
static void set_path() {
|
||||
char buffer[512];
|
||||
for (int i = 0; environ[i]; ++i) {
|
||||
if (strncmp(environ[i], "PATH=", 5) == 0) {
|
||||
sprintf(buffer, "PATH="BBPATH":%s", environ[i] + 5);
|
||||
vec_push_back(v, strdup(buffer));
|
||||
} else {
|
||||
vec_push_back(v, strdup(environ[i]));
|
||||
}
|
||||
}
|
||||
vec_push_back(v, NULL);
|
||||
sprintf(buffer, BBPATH ":%s", getenv("PATH"));
|
||||
setenv("PATH", buffer, 1);
|
||||
}
|
||||
|
||||
static void set_mirror_path(struct vector *v) {
|
||||
for (int i = 0; environ[i]; ++i) {
|
||||
if (strncmp(environ[i], "PATH=", 5) == 0) {
|
||||
vec_push_back(v, strdup("PATH="BBPATH":/sbin:"MIRRDIR"/system/bin:"
|
||||
MIRRDIR"/system/xbin:"MIRRDIR"/vendor/bin"));
|
||||
} else {
|
||||
vec_push_back(v, strdup(environ[i]));
|
||||
}
|
||||
}
|
||||
vec_push_back(v, NULL);
|
||||
static void set_mirror_path() {
|
||||
setenv("PATH", BBPATH ":/sbin:" MIRRDIR "/system/bin:"
|
||||
MIRRDIR "/system/xbin:" MIRRDIR "/vendor/bin", 1);
|
||||
}
|
||||
|
||||
/***********
|
||||
|
||||
@@ -82,7 +82,7 @@ static void *logcat_thread(void *args) {
|
||||
char line[4096];
|
||||
while (1) {
|
||||
// Start logcat
|
||||
log_pid = exec_array(0, &log_fd, NULL, (char **) vec_entry(&log_cmd));
|
||||
log_pid = exec_array(0, &log_fd, NULL, (const char **) vec_entry(&log_cmd));
|
||||
FILE *logs = fdopen(log_fd, "r");
|
||||
while (fgets(line, sizeof(line), logs)) {
|
||||
if (line[0] == '-')
|
||||
@@ -103,7 +103,7 @@ static void *logcat_thread(void *args) {
|
||||
|
||||
LOGI("magisklogd: logcat output EOF");
|
||||
// Clear buffer
|
||||
log_pid = exec_array(0, NULL, NULL, (char **) vec_entry(&clear_cmd));
|
||||
log_pid = exec_array(0, NULL, NULL, (const char **) vec_entry(&clear_cmd));
|
||||
waitpid(log_pid, NULL, 0);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user