Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 6f0eb8f0 authored by Nick Kralevich's avatar Nick Kralevich Committed by android-build-merger
Browse files

Merge "dumpstate: convert sprintfs to snprintfs" into nyc-dev

am: 853f8f9c

* commit '853f8f9c':
  dumpstate: convert sprintfs to snprintfs

Change-Id: Ie88fe46faad244e6d080e063a2d7d9a94a71cd45
parents 2dff6590 853f8f9c
Loading
Loading
Loading
Loading
+4 −4
Original line number Diff line number Diff line
@@ -124,7 +124,7 @@ void do_mountinfo(int pid, const char *name) {

    // Gets the the content of the /proc/PID/ns/mnt link, so only unique mount points
    // are added.
    sprintf(path, "/proc/%d/ns/mnt", pid);
    snprintf(path, sizeof(path), "/proc/%d/ns/mnt", pid);
    char linkname[PATH_MAX];
    ssize_t r = readlink(path, linkname, PATH_MAX);
    if (r == -1) {
@@ -135,7 +135,7 @@ void do_mountinfo(int pid, const char *name) {

    if (mount_points.find(linkname) == mount_points.end()) {
        // First time this mount point was found: add it
        sprintf(path, "/proc/%d/mountinfo", pid);
        snprintf(path, sizeof(path), "/proc/%d/mountinfo", pid);
        if (add_zip_entry(ZIP_ROOT_DIR + path, path)) {
            mount_points.insert(linkname);
        } else {
@@ -1050,7 +1050,7 @@ int main(int argc, char *argv[]) {
    char last_id[PROPERTY_VALUE_MAX];
    property_get("dumpstate.last_id", last_id, "0");
    id = strtoul(last_id, NULL, 10) + 1;
    sprintf(last_id, "%lu", id);
    snprintf(last_id, sizeof(last_id), "%lu", id);
    property_set("dumpstate.last_id", last_id);
    MYLOGI("dumpstate id: %lu\n", id);

@@ -1315,7 +1315,7 @@ int main(int argc, char *argv[]) {
        /* check if user changed the suffix using system properties */
        char key[PROPERTY_KEY_MAX];
        char value[PROPERTY_VALUE_MAX];
        sprintf(key, "dumpstate.%d.name", getpid());
        snprintf(key, sizeof(key), "dumpstate.%d.name", getpid());
        property_get(key, value, "");
        bool change_suffix= false;
        if (value[0]) {
+10 −10
Original line number Diff line number Diff line
@@ -187,7 +187,7 @@ static void for_each_tid_helper(int pid, const char *cmdline, void *arg) {
    char taskpath[255];
    for_each_tid_func *func = (for_each_tid_func *) arg;

    sprintf(taskpath, "/proc/%d/task", pid);
    snprintf(taskpath, sizeof(taskpath), "/proc/%d/task", pid);

    if (!(d = opendir(taskpath))) {
        printf("Failed to open %s (%s)\n", taskpath, strerror(errno));
@@ -209,7 +209,7 @@ static void for_each_tid_helper(int pid, const char *cmdline, void *arg) {
        if (tid == pid)
            continue;

        sprintf(commpath,"/proc/%d/comm", tid);
        snprintf(commpath, sizeof(commpath), "/proc/%d/comm", tid);
        memset(comm, 0, sizeof(comm));
        if ((fd = TEMP_FAILURE_RETRY(open(commpath, O_RDONLY | O_CLOEXEC))) < 0) {
            strcpy(comm, "N/A");
@@ -243,7 +243,7 @@ void show_wchan(int pid, int tid, const char *name) {

    memset(buffer, 0, sizeof(buffer));

    sprintf(path, "/proc/%d/wchan", tid);
    snprintf(path, sizeof(path), "/proc/%d/wchan", tid);
    if ((fd = TEMP_FAILURE_RETRY(open(path, O_RDONLY | O_CLOEXEC))) < 0) {
        printf("Failed to open '%s' (%s)\n", path, strerror(errno));
        return;
@@ -308,7 +308,7 @@ void show_showtime(int pid, const char *name) {

    memset(buffer, 0, sizeof(buffer));

    sprintf(path, "/proc/%d/stat", pid);
    snprintf(path, sizeof(path), "/proc/%d/stat", pid);
    if ((fd = TEMP_FAILURE_RETRY(open(path, O_RDONLY | O_CLOEXEC))) < 0) {
        printf("Failed to open '%s' (%s)\n", path, strerror(errno));
        return;
@@ -396,8 +396,8 @@ void do_showmap(int pid, const char *name) {
    char title[255];
    char arg[255];

    sprintf(title, "SHOW MAP %d (%s)", pid, name);
    sprintf(arg, "%d", pid);
    snprintf(title, sizeof(title), "SHOW MAP %d (%s)", pid, name);
    snprintf(arg, sizeof(arg), "%d", pid);
    run_command(title, 10, SU_PATH, "root", "showmap", "-q", arg, NULL);
}

@@ -1191,8 +1191,8 @@ void update_progress(int delta) {
        int new_total = weight_total * 1.2;
        MYLOGD("Adjusting total weight from %d to %d\n", weight_total, new_total);
        weight_total = new_total;
        sprintf(key, "dumpstate.%d.max", getpid());
        sprintf(value, "%d", weight_total);
        snprintf(key, sizeof(key), "dumpstate.%d.max", getpid());
        snprintf(value, sizeof(value), "%d", weight_total);
        int status = property_set(key, value);
        if (status) {
            MYLOGE("Could not update max weight by setting system property %s to %s: %d\n",
@@ -1200,8 +1200,8 @@ void update_progress(int delta) {
        }
    }

    sprintf(key, "dumpstate.%d.progress", getpid());
    sprintf(value, "%d", progress);
    snprintf(key, sizeof(key), "dumpstate.%d.progress", getpid());
    snprintf(value, sizeof(value), "%d", progress);

    if (progress % 100 == 0) {
        // We don't want to spam logcat, so only log multiples of 100.