Changeset 56 in MondoRescue


Ignore:
Timestamp:
Oct 9, 2005, 1:47:23 AM (19 years ago)
Author:
bcornec
Message:

asprintf for newt-specific.c (first step)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/mondo/mondo/common/newt-specific.c

    r45 r56  
    262262        /*@ end vars **************************************************** */
    263263
    264         tmp = malloc(MAX_NEWT_COMMENT_LEN);
    265264        set_signals(FALSE);     // link to external func
    266265        g_exiting = TRUE;
     
    270269            log_msg(2, "mastermind %d is exiting", (int) getpid());
    271270            kill(g_main_pid, SIGTERM);
    272             paranoid_free(tmp);
    273271            finish(1);
    274272        }
     
    278276                log_msg(2, "non-m/m %d is exiting", (int) getpid());
    279277                kill(g_main_pid, SIGTERM);
    280                 paranoid_free(tmp);
    281278                finish(1);
    282279            }
     
    286283        if (already_exiting) {
    287284            log_msg(3, "...I'm already exiting. Give me time, Julian!");
    288             paranoid_free(tmp);
    289285            finish(1);
    290286        }
     
    297293        kill_anything_like_this("partimagehack");
    298294        sync();
    299         sprintf(tmp, "umount %s", g_tmpfs_mountpt);
     295        asprintf(&tmp, "umount %s", g_tmpfs_mountpt);
    300296        chdir("/");
    301297        for (i = 0; i < 10 && run_program_and_log_output(tmp, 5); i++) {
     
    304300            run_program_and_log_output(tmp, 5);
    305301        }
     302        paranoid_free(tmp);
    306303
    307304        if (g_erase_tmpdir_and_scratchdir[0]) {
     
    349346            log_msg(3, "FYI - g_main_pid is blank");
    350347        }
    351         paranoid_free(tmp);
    352348        finish(254);
    353349    }
     
    419415        int i = 0;
    420416
    421         malloc_string(command);
    422         malloc_string(tmp);
    423417        assert_string_is_neither_NULL_nor_zerolength(filename);
    424418        assert(grep_for_me != NULL);
    425419
    426420        if (!does_file_exist(filename)) {
    427             paranoid_free(command);
    428             paranoid_free(tmp);
    429421            return;
    430422        }
    431423        if (grep_for_me[0] != '\0') {
    432             sprintf(command, "cat %s | grep \"%s\" | tail -n%d", filename,
     424            asprintf(&command, "cat %s | grep \"%s\" | tail -n%d", filename,
    433425                    grep_for_me, g_noof_log_lines);
    434426        } else {
    435             sprintf(command, "cat %s | tail -n%d", filename,
     427            asprintf(&command, "cat %s | tail -n%d", filename,
    436428                    g_noof_log_lines);
    437429        }
     
    447439                    strip_spaces(err_log_lines[i]);
    448440                    if (!strncmp(err_log_lines[i], "root:", 5)) {
    449                         strcpy(tmp, err_log_lines[i] + 6);
     441                        asprintf(&tmp, "%s", err_log_lines[i] + 6);
    450442                        strcpy(err_log_lines[i], tmp);
     443                        paranoid_free(tmp);
    451444                    }
    452445                    if (feof(fin)) {
     
    459452        refresh_log_screen();
    460453        paranoid_free(command);
    461         paranoid_free(tmp);
    462454    }
    463455
     
    479471        char *output;
    480472
    481         malloc_string(output);
    482473
    483474        va_start(args, fmt);
    484         vsprintf(output, fmt, args);
     475        vasprintf(&output, fmt, args);
    485476        log_msg(0, output);
    486         output[80] = '\0';
     477        if (strlen(output > 80)) {
     478            output[80] = '\0';
     479        }
    487480        va_end(args);
    488481        i = (int) strlen(output);
Note: See TracChangeset for help on using the changeset viewer.