Changeset 2405


Ignore:
Timestamp:
Sep 17, 2009, 3:45:24 AM (10 years ago)
Author:
bruno
Message:

Removes some malloc_string static allocation

Location:
branches/2.2.10/mondo/src
Files:
14 edited

Legend:

Unmodified
Added
Removed
  • branches/2.2.10/mondo/src/common/libmondo-archive.c

    r2383 r2405  
    979979void *create_afio_files_in_background(void *inbuf)
    980980{
    981     long int archiving_set_no;
    982     char *archiving_filelist_fname;
    983     char *archiving_afioball_fname;
     981    long int archiving_set_no = 0L;
     982    char *archiving_filelist_fname = NULL;
     983    char *archiving_afioball_fname = NULL;
    984984    char *curr_xattr_list_fname = NULL;
    985985    char *curr_acl_list_fname = NULL;
     
    994994    int this_thread_no = g_current_thread_no++;
    995995
    996     malloc_string(archiving_filelist_fname);
    997     malloc_string(archiving_afioball_fname);
    998996    p_last_set_archived = (int *) inbuf;
    999997    p_archival_threads_running = (int *) (inbuf + 4);
     
    10021000    bkpinfo_bis = (struct s_bkpinfo *) (inbuf + BKPINFO_LOC_OFFSET);
    10031001
    1004     sprintf(archiving_filelist_fname, FILELIST_FNAME_RAW_SZ, bkpinfo->tmpdir, 0L);
    1005     for (archiving_set_no = 0; does_file_exist(archiving_filelist_fname);
    1006          sprintf(archiving_filelist_fname, FILELIST_FNAME_RAW_SZ, bkpinfo->tmpdir, archiving_set_no)) {
     1002    mr_asprintf(archiving_filelist_fname, FILELIST_FNAME_RAW_SZ, bkpinfo->tmpdir, 0L);
     1003
     1004    while (does_file_exist(archiving_filelist_fname)) {
    10071005        if (g_exiting) {
     1006            mr_free(archiving_filelist_fname);
    10081007            fatal_error("Execution run aborted (pthread)");
    10091008        }
    10101009        if (archiving_set_no >= MAX_NOOF_SETS_HERE) {
     1010            mr_free(archiving_filelist_fname);
    10111011            fatal_error("Maximum number of filesets exceeded. Adjust MAX_NOOF_SETS_HERE, please.");
    10121012        }
    10131013        if (!semaphore_p()) {
    10141014            log_msg(3, "P sem failed (pid=%d)", (int) getpid());
     1015            mr_free(archiving_filelist_fname);
    10151016            fatal_error("Cannot get semaphore P");
    10161017        }
     
    10201021        *p_next_set_to_archive = *p_next_set_to_archive + 1;
    10211022        if (!semaphore_v()) {
     1023            mr_free(archiving_filelist_fname);
    10221024            fatal_error("Cannot get semaphore V");
    10231025        }
    10241026
    10251027        /* backup this set of files */
    1026         sprintf(archiving_afioball_fname, AFIOBALL_FNAME_RAW_SZ, bkpinfo->tmpdir, archiving_set_no, bkpinfo->zip_suffix);
    1027         sprintf(archiving_filelist_fname, FILELIST_FNAME_RAW_SZ, bkpinfo->tmpdir, archiving_set_no);
     1028        mr_asprintf(archiving_afioball_fname, AFIOBALL_FNAME_RAW_SZ, bkpinfo->tmpdir, archiving_set_no, bkpinfo->zip_suffix);
     1029        mr_free(archiving_filelist_fname);
     1030        mr_asprintf(archiving_filelist_fname, FILELIST_FNAME_RAW_SZ, bkpinfo->tmpdir, archiving_set_no);
    10281031        if (!does_file_exist(archiving_filelist_fname)) {
    1029             log_msg(3,
    1030                     "%s[%d:%d] - well, I would archive %d, except that it doesn't exist. I'll stop now.",
    1031                     FORTY_SPACES, getpid(), this_thread_no,
    1032                     archiving_set_no);
     1032            log_msg(3, "[%d:%d] - well, I would archive %d, except that it doesn't exist. I'll stop now.", getpid(), this_thread_no, archiving_set_no);
    10331033            break;
    10341034        }
     
    10361036        mr_asprintf(tmp, AFIOBALL_FNAME_RAW_SZ, bkpinfo->tmpdir, archiving_set_no - ARCH_BUFFER_NUM, bkpinfo->zip_suffix);
    10371037        if (does_file_exist(tmp)) {
    1038             log_msg(4, "%s[%d:%d] - waiting for storer", FORTY_SPACES,
    1039                     getpid(), this_thread_no);
     1038            log_msg(4, "[%d:%d] - waiting for storer", getpid(), this_thread_no);
    10401039            while (does_file_exist(tmp)) {
    10411040                sleep(1);
     
    10451044        mr_free(tmp);
    10461045
    1047         log_msg(4, "%s[%d:%d] - EXATing %d...", FORTY_SPACES, getpid(),
    1048                 this_thread_no, archiving_set_no);
     1046        log_msg(4, "[%d:%d] - EXATing %d...", getpid(), this_thread_no, archiving_set_no);
     1047
    10491048        if (g_getfattr) {
    10501049            mr_asprintf(curr_xattr_list_fname, XATTR_LIST_FNAME_RAW_SZ, bkpinfo->tmpdir, archiving_set_no);
     
    10581057        }
    10591058
    1060         log_msg(4, "%s[%d:%d] - archiving %d...", FORTY_SPACES, getpid(),
    1061                 this_thread_no, archiving_set_no);
    1062         res =
    1063             archive_this_fileset(archiving_filelist_fname,
    1064                                  archiving_afioball_fname,
    1065                                  archiving_set_no);
     1059        log_msg(4, "[%d:%d] - archiving %d...", getpid(), this_thread_no, archiving_set_no);
     1060        res = archive_this_fileset(archiving_filelist_fname, archiving_afioball_fname, archiving_set_no);
     1061        mr_free(archiving_afioball_fname);
     1062
    10661063        retval += res;
    10671064
     
    10691066            log_to_screen("Errors occurred while archiving set %ld. Please review logs.", archiving_set_no);
    10701067        }
     1068
    10711069        if (!semaphore_p()) {
     1070            mr_free(archiving_filelist_fname);
    10721071            fatal_error("Cannot get semaphore P");
    10731072        }
     
    10801079
    10811080        if (!semaphore_v()) {
     1081            mr_free(archiving_filelist_fname);
    10821082            fatal_error("Cannot get semaphore V");
    10831083        }
    1084         log_msg(4, "%s[%d:%d] - archived %d OK", FORTY_SPACES, getpid(),
    1085                 this_thread_no, archiving_set_no);
     1084        log_msg(4, "[%d:%d] - archived %d OK", getpid(), this_thread_no, archiving_set_no);
    10861085        archiving_set_no++;
    1087     }
     1086
     1087        mr_free(archiving_filelist_fname);
     1088        mr_asprintf(archiving_filelist_fname, FILELIST_FNAME_RAW_SZ, bkpinfo->tmpdir, archiving_set_no);
     1089    }
     1090    mr_free(archiving_filelist_fname);
     1091
    10881092    if (!semaphore_p()) {
    10891093        fatal_error("Cannot get semaphore P");
     
    10931097        fatal_error("Cannot get semaphore V");
    10941098    }
    1095     log_msg(3, "%s[%d:%d] - exiting", FORTY_SPACES, getpid(),
    1096             this_thread_no);
    1097     paranoid_free(archiving_filelist_fname);
    1098     paranoid_free(archiving_afioball_fname);
     1099    log_msg(3, "[%d:%d] - exiting", getpid(), this_thread_no);
    10991100    pthread_exit(NULL);
    11001101}
     
    13271328    assert(bkpinfo != NULL);
    13281329    malloc_string(result_str);
    1329     transfer_block =
    1330         malloc(sizeof(struct s_bkpinfo) + BKPINFO_LOC_OFFSET + 64);
     1330    transfer_block = malloc(sizeof(struct s_bkpinfo) + BKPINFO_LOC_OFFSET + 64);
    13311331    memset((void *) transfer_block, 0,
    13321332           sizeof(struct s_bkpinfo) + BKPINFO_LOC_OFFSET + 64);
     
    16381638    char *message_to_screen = NULL;
    16391639    char *sz_blank_disk = NULL;
    1640     char *fnam;
    16411640    char *tmp2 = NULL;
    16421641    char *tmp3 = NULL;
     
    16451644
    16461645    malloc_string(old_pwd);
    1647     malloc_string(fnam);
    16481646    assert(bkpinfo != NULL);
    16491647    assert_string_is_neither_NULL_nor_zerolength(destfile);
     
    18791877    }
    18801878    paranoid_free(old_pwd);
    1881     paranoid_free(fnam);
    18821879    return (retval);
    18831880}
     
    25292526/**
    25302527 * Make sure the user has a valid CD-R(W) in the CD drive.
    2531  * @param cdrw_dev Set to the CD-R(W) device checked.
    2532  * @param keep_looping If TRUE, keep pestering user until they insist
    2533  * or insert a correct CD; if FALSE, only check once.
    2534  * @return 0 (there was an OK CD in the drive) or 1 (there wasn't).
    2535  */
    2536 int interrogate_disk_currently_in_cdrw_drive(char *cdrw_dev, bool keep_looping) {
    2537     int res = 0;
    2538     char *bkp = NULL;
     2528 * @return the CD-R(W) device checked or NULL
     2529 */
     2530char *interrogate_disk_currently_in_cdrw_drive(char *cdrw_dev) {
    25392531    char *cdrecord = NULL;
    2540 
    2541     mr_asprintf(bkp, "%s", cdrw_dev);
    2542     if (find_cdrw_device(cdrw_dev)) {
    2543         strcpy(cdrw_dev, bkp);
    2544     } else {
     2532    char *cdrw_dev = NULL;
     2533
     2534    cdrw_dev = find_cdrw_device();
     2535    if (cdrw_dev != NULL) {
    25452536        if (!system("which cdrecord > /dev/null 2> /dev/null")) {
    25462537            mr_asprintf(cdrecord, "cdrecord dev=%s -atip", cdrw_dev);
     
    25512542        }
    25522543        if (cdrecord != NULL) {
    2553             if (!keep_looping) {
    2554                 retract_CD_tray_and_defeat_autorun();
    2555                 res = run_program_and_log_output(cdrecord, 5);
    2556             } else {
    2557                 while ((res = run_program_and_log_output(cdrecord, 5))) {
    2558                     retract_CD_tray_and_defeat_autorun();
    2559                     if (ask_me_yes_or_no
    2560                         ("Unable to examine CD. Are you sure this is a valid CD-R(W) CD?"))
    2561                     {
    2562                         log_msg(1, "Well, he insisted...");
    2563                         break;
    2564                     }
    2565                 }
     2544            retract_CD_tray_and_defeat_autorun();
     2545            if (run_program_and_log_output(cdrecord, 5)) {
     2546                /* As it didn't work, return NULL */
     2547                mr_free(cdrw_dev);
    25662548            }
    25672549        }
    2568     }
    2569     mr_free(bkp);
    2570 
    2571     mr_free(cdrecord);
    2572     return (res);
     2550        mr_free(cdrecord);
     2551    }
     2552    return(cdrw_dev);
    25732553}
    25742554
     
    25862566    char *tmp = NULL;
    25872567    char *cdrom_dev = NULL;
    2588     char *cdrw_dev;
     2568    char *cdrw_dev = NULL;
    25892569    char *our_serial_str = NULL;
    25902570    bool ok_go_ahead_burn_it;
     
    25922572    int attempt_to_mount_returned_this = 999;
    25932573    char *mtpt = NULL;
    2594     char *szcdno;
    2595     char *szserfname;
    2596     char *szunmount;
     2574    char *szcdno = NULL;
     2575    char *szserfname = NULL;
     2576    char *szunmount = NULL;
    25972577    char *mds = NULL;
    2598 
    2599     malloc_string(cdrw_dev);
    2600     malloc_string(szcdno);
    2601     malloc_string(szserfname);
    2602     malloc_string(szunmount);
    26032578
    26042579    mds = media_descriptor_string(g_backup_media_type);
     
    26212596        mr_asprintf(tmp, "umount %s", cdrom_dev);
    26222597        run_program_and_log_output(tmp, 1);
    2623         sprintf(szcdno, "%s/archives/THIS-CD-NUMBER", mtpt);
    2624         sprintf(szserfname, "%s/archives/SERIAL-STRING", mtpt);
    2625         sprintf(szunmount, "umount %s", mtpt);
     2598        mr_asprintf(szcdno, "%s/archives/THIS-CD-NUMBER", mtpt);
     2599        mr_asprintf(szserfname, "%s/archives/SERIAL-STRING", mtpt);
     2600        mr_asprintf(szunmount, "umount %s", mtpt);
    26262601        cd_number = -1;
    26272602        mr_asprintf(tmp, "mount %s %s", cdrom_dev, mtpt);
     
    26292604        attempt_to_mount_returned_this = run_program_and_log_output(tmp, 1);
    26302605        mr_free(tmp);
     2606
    26312607        if (attempt_to_mount_returned_this) {
    26322608            log_msg(4, "Failed to mount %s at %s", cdrom_dev, mtpt);
    26332609            log_to_screen("If there's a CD/DVD in the drive, it's blank.");
    2634             /*
    2635                if (interrogate_disk_currently_in_cdrw_drive(cdrw_dev, FALSE))
    2636                {
    2637                ok_go_ahead_burn_it = FALSE;
    2638                log_to_screen("There isn't a writable CD/DVD in the drive.");
    2639                }
    2640                else
    2641                {
    2642                log_to_screen("Confirmed. There is a blank CD/DVD in the drive.");
    2643                }
    2644              */
    2645         } else if (!does_file_exist(szcdno)
    2646                    || !does_file_exist(szserfname)) {
     2610        } else if (!does_file_exist(szcdno) || !does_file_exist(szserfname)) {
    26472611            mds = media_descriptor_string(g_backup_media_type);
    2648             log_to_screen
    2649                 ("%s has data on it but it's probably not a Mondo CD.", mds);
     2612            log_to_screen("%s has data on it but it's probably not a Mondo CD.", mds);
    26502613            mr_free(mds);
    26512614        } else {
     
    26642627            // FIXME - should be able to use last_line_of_file(), surely?
    26652628        }
     2629        mr_free(szcdno);
     2630        mr_free(szserfname);
     2631
    26662632        run_program_and_log_output(szunmount, 1);
     2633        mr_free(szunmount);
     2634
    26672635        log_msg(2, "paafcd: cd_number = %d", cd_number);
    26682636        log_msg(2, "our serial str = %s; g_serial_string = %s", our_serial_str, g_serial_string);
     
    26862654        log_msg(2,
    26872655                "paafcd: Can't find CD-ROM drive. Perhaps it has a blank %s in it?", mds);
    2688         if (interrogate_disk_currently_in_cdrw_drive(cdrw_dev, FALSE)) {
     2656        cdrw_dev = interrogate_disk_currently_in_cdrw_drive();
     2657        if (cdrw_dev == NULL) {
    26892658            ok_go_ahead_burn_it = FALSE;
    26902659            log_to_screen("There isn't a writable %s in the drive.", mds);
    26912660        }
     2661        mr_free(cdrw_dev);
    26922662        mr_free(mds);
    26932663    }
     
    27092679
    27102680    mds = media_descriptor_string(g_backup_media_type);
    2711     log_msg(2,
    2712             "paafcd: OK, I assume I have a blank/reusable %s in the drive...", mds);
     2681    log_msg(2, "paafcd: OK, I assume I have a blank/reusable %s in the drive...", mds);
    27132682
    27142683    log_to_screen("Proceeding w/ %s in drive.", mds);
    27152684    mr_free(mds);
    27162685
    2717     paranoid_free(cdrw_dev);
    27182686    paranoid_free(mtpt);
    2719     paranoid_free(szcdno);
    2720     paranoid_free(szserfname);
    2721     paranoid_free(szunmount);
    27222687    if (pmountable) {
    27232688        if (attempt_to_mount_returned_this) {
     
    27292694
    27302695}
    2731 
    2732 
    2733 
    2734 
    2735 
    2736 
    27372696
    27382697
     
    27642723
    27652724/* @} - end of utilityGroup */
    2766 
    2767 
    2768 
    2769 
    2770 
    2771 
    27722725
    27732726
  • branches/2.2.10/mondo/src/common/libmondo-cli.c

    r2389 r2405  
    654654
    655655    /*@ buffers ** */
    656     char *tmp = NULL;
    657656    char *tmp1 = NULL;
    658657    char *tmp2 = NULL;
     
    668667
    669668    struct stat buf;
    670 
    671     malloc_string(tmp);
    672669
    673670    assert(bkpinfo != NULL);
     
    13771374        finish(0);
    13781375    }
    1379     mr_free(tmp);
    13801376
    13811377    if ((flag_set['L']) && (! bkpinfo->restore_data)) {
  • branches/2.2.10/mondo/src/common/libmondo-devices.c

    r2400 r2405  
    14071407    char *tmp = NULL;
    14081408    char *p = NULL;
    1409     char *tmp1 = NULL;
    14101409    char *mds = NULL;
    14111410    char *sz_size = NULL;
    14121411    char *command = NULL;
    14131412    char *comment = NULL;
    1414     char *prompt;
    14151413    int i;
    14161414    FILE *fin;
    14171415
    1418     malloc_string(prompt);
    1419     malloc_string(tmp1);
    14201416    assert(bkpinfo != NULL);
    14211417    bkpinfo->nonbootable_backup = FALSE;
     
    14561452        if (archiving_to_media) {
    14571453            if ((bkpinfo->backup_media_type != dvd) && (bkpinfo->backup_media_type != usb)) {
    1458                 if (ask_me_yes_or_no
    1459                     ("Is your computer a laptop, or does the CD writer incorporate BurnProof technology?"))
    1460                 {
     1454                if (ask_me_yes_or_no("Is your computer a laptop, or does the CD writer incorporate BurnProof technology?")) {
    14611455                    bkpinfo->manual_cd_tray = TRUE;
    14621456                }
    14631457            }
    1464             if ((bkpinfo->compression_level =
    1465                  which_compression_level()) == -1) {
     1458            if ((bkpinfo->compression_level = which_compression_level()) == -1) {
    14661459                log_to_screen("User has chosen not to backup the PC");
    14671460                finish(1);
     
    14951488            mr_free(comment);
    14961489
    1497             bkpinfo->cdrw_speed = atoi(tmp1);   // if DVD then this shouldn't ever be used anyway :)
     1490            bkpinfo->cdrw_speed = atoi(tmp);    // if DVD then this shouldn't ever be used anyway :)
     1491            mr_free(tmp);
    14981492
    14991493            mr_asprintf(comment, "How much data (in Megabytes) will each %s store?", mds);
     
    20222016    }
    20232017    paranoid_free(sz_size);
    2024     paranoid_free(tmp1);
    2025     paranoid_free(prompt);
    20262018    return (0);
    20272019}
  • branches/2.2.10/mondo/src/common/libmondo-filelist.c

    r2404 r2405  
    15071507    char *sz_filelist;
    15081508    char *exclude_paths = NULL;
    1509     char *tmp;
    15101509    int i;
    15111510    FILE *fout;
     
    15161515    char *tmp2 = NULL;
    15171516
    1518     malloc_string(tmp);
    1519     malloc_string(g_skeleton_filelist);
    15201517    mr_asprintf(sz_datefile,MONDO_CACHE"/difflevel.%d" , 0);
    15211518    if (!include_paths && !userdef_filelist) {
     
    15871584        log_msg(2, "Excluding paths = '%s'", exclude_paths);
    15881585        log_msg(2, "Generating skeleton filelist so that we can track our progress");
    1589         sprintf(g_skeleton_filelist, "%s/tmpfs/skeleton.txt", bkpinfo->tmpdir);
     1586        mr_asprintf(g_skeleton_filelist, "%s/tmpfs/skeleton.txt", bkpinfo->tmpdir);
    15901587        make_hole_for_file(g_skeleton_filelist);
    15911588        log_msg(4, "g_skeleton_entries = %ld", g_skeleton_entries);
     
    16311628    paranoid_free(sz_filelist);
    16321629    log_msg(2, "Freeing variables");
    1633     paranoid_free(tmp);
    1634     paranoid_free(g_skeleton_filelist);
     1630    mr_free(g_skeleton_filelist);
    16351631    log_msg(2, "Exiting");
    16361632    return (0);
  • branches/2.2.10/mondo/src/common/libmondo-fork.c

    r2392 r2405  
    9595 * @return Exit code of @c mkisofs (0 is success, anything else indicates failure).
    9696 */
    97 int
    98 eval_call_to_make_ISO(char *basic_call, char *isofile, int cd_no, char *what_i_am_doing) {
     97int eval_call_to_make_ISO(char *basic_call, char *isofile, int cd_no, char *what_i_am_doing) {
    9998
    10099    /*@ int's  *** */
     
    106105    char *ultimate_call = NULL;
    107106    char *tmp = NULL;
    108     char *incoming, *old_stderr;
    109107       
    110108    char *cd_number_str = NULL;
     
    119117    assert(bkpinfo != NULL);
    120118    assert_string_is_neither_NULL_nor_zerolength(isofile);
    121     malloc_string(incoming);
    122     malloc_string(old_stderr);
    123 
    124     incoming[0] = '\0';
    125     old_stderr[0] = '\0';
    126119
    127120    if ((bkpinfo->netfs_user) && (strstr(bkpinfo->netfs_proto,"nfs"))) {
     
    187180    }
    188181    mr_free(command);
    189     paranoid_free(incoming);
    190     paranoid_free(old_stderr);
    191182    return (retval);
    192183}
  • branches/2.2.10/mondo/src/common/libmondo-raid.c

    r2357 r2405  
    591591{
    592592    FILE *fin;
    593     char *tmp;
    594593    char *label;
    595594    char *value;
     
    597596    int v;
    598597
    599     malloc_string(tmp);
    600     malloc_string(label);
    601     malloc_string(value);
    602598    assert(raidlist != NULL);
    603599    assert_string_is_neither_NULL_nor_zerolength(fname);
     
    606602        log_it("Raidtab is very small or non-existent. Ignoring it.");
    607603        raidlist->entries = 0;
    608         paranoid_free(tmp);
    609         paranoid_free(label);
    610         paranoid_free(value);
    611604        return (0);
    612605    }
    613606    if (!(fin = fopen(fname, "r"))) {
    614607        log_it("Cannot open raidtab");
    615         paranoid_free(tmp);
    616         paranoid_free(label);
    617         paranoid_free(value);
    618608        return (1);
    619609    }
    620610    items = 0;
    621611    log_it("Loading raidtab...");
     612    malloc_string(label);
     613    malloc_string(value);
    622614    get_next_raidtab_line(fin, label, value);
    623615    while (!feof(fin)) {
     
    631623            v++;
    632624            get_next_raidtab_line(fin, label, value);
    633             log_it(tmp);
    634625        }
    635626        raidlist->el[items].additional_vars.entries = v;
     
    651642    log_msg(1, "Raidtab loaded successfully.");
    652643    log_msg(1, "%d RAID devices in raidtab", items);
    653     paranoid_free(tmp);
    654644    paranoid_free(label);
    655645    paranoid_free(value);
  • branches/2.2.10/mondo/src/common/libmondo-stream.c

    r2383 r2405  
    13151315    while (ctrl_chr != BLK_START_AN_AFIO_OR_SLICE) {
    13161316        res =
    1317             read_header_block_from_stream(&temp_size, temp_fname,
    1318                                           &ctrl_chr);
     1317            read_header_block_from_stream(&temp_size, temp_fname, &ctrl_chr);
    13191318        if (ctrl_chr == BLK_START_AN_AFIO_OR_SLICE) {
    13201319            break;
     
    13261325    while (ctrl_chr != BLK_START_FILE) {
    13271326        res =
    1328             read_header_block_from_stream(&temp_size, temp_fname,
    1329                                           &ctrl_chr);
     1327            read_header_block_from_stream(&temp_size, temp_fname, &ctrl_chr);
    13301328        if (ctrl_chr == BLK_START_FILE) {
    13311329            break;
     
    13481346    }
    13491347    while (strcmp(pA, pB)) {
    1350         log_msg(6, "Skipping %s (it's not %s)", temp_fname,
    1351                 the_file_I_was_reading);
     1348        log_msg(6, "Skipping %s (it's not %s)", temp_fname, the_file_I_was_reading);
    13521349        for (size = temp_size; size > 0; size -= bytes_to_write) {
    13531350            bytes_to_write =
     
    13571354        }
    13581355        res =
    1359             read_header_block_from_stream(&temp_size, temp_fname,
    1360                                           &ctrl_chr);
     1356            read_header_block_from_stream(&temp_size, temp_fname, &ctrl_chr);
    13611357        if (ctrl_chr != BLK_STOP_FILE) {
    13621358            wrong_marker(BLK_STOP_FILE, ctrl_chr);
    13631359        }
    13641360        res =
    1365             read_header_block_from_stream(&temp_size, temp_fname,
    1366                                           &ctrl_chr);
     1361            read_header_block_from_stream(&temp_size, temp_fname, &ctrl_chr);
    13671362        if (ctrl_chr != BLK_STOP_AN_AFIO_OR_SLICE) {
    13681363            wrong_marker(BLK_STOP_AN_AFIO_OR_SLICE, ctrl_chr);
    13691364        }
    13701365        res =
    1371             read_header_block_from_stream(&temp_size, temp_fname,
    1372                                           &ctrl_chr);
     1366            read_header_block_from_stream(&temp_size, temp_fname, &ctrl_chr);
    13731367        if (ctrl_chr != BLK_START_AN_AFIO_OR_SLICE) {
    13741368            wrong_marker(BLK_START_AN_AFIO_OR_SLICE, ctrl_chr);
    13751369        }
    13761370        res =
    1377             read_header_block_from_stream(&temp_size, temp_fname,
    1378                                           &ctrl_chr);
     1371            read_header_block_from_stream(&temp_size, temp_fname, &ctrl_chr);
    13791372        if (ctrl_chr != BLK_START_FILE) {
    13801373            wrong_marker(BLK_START_FILE, ctrl_chr);
     
    13931386        }
    13941387    }
    1395     log_msg(2, "Reading %s (it matches %s)", temp_fname,
    1396             the_file_I_was_reading);
     1388    log_msg(2, "Reading %s (it matches %s)", temp_fname, the_file_I_was_reading);
    13971389    paranoid_free(temp_fname);
    13981390    paranoid_free(datablock);
  • branches/2.2.10/mondo/src/common/libmondo-string.c

    r2400 r2405  
    202202    long outval;
    203203    int i;
    204     char *tmp;
    205204    char *tmp1 = NULL;
    206205    char ch;
     
    208207    assert_string_is_neither_NULL_nor_zerolength(incoming);
    209208
    210     malloc_string(tmp);
    211209    if (!incoming[0]) {
    212         free(tmp);
    213210        return (0);
    214211    }
     
    216213        fatal_error("Please use integers only. No decimal points.");
    217214    }
    218     strcpy(tmp, incoming);
    219     i = (int) strlen(tmp);
    220     if (tmp[i - 1] == 'B' || tmp[i - 1] == 'b') {
    221         tmp[i - 1] = '\0';
    222     }
    223     for (i = 0; i < (int) strlen(tmp) && isdigit(tmp[i]); i++);
    224     ch = tmp[i];
    225     tmp[i] = '\0';
    226     outval = atol(tmp);
    227     paranoid_free(tmp);
     215
     216    mr_asprintf(tmp1, "%s", incoming);
     217    i = (int) strlen(tmp1);
     218    if (tmp1[i - 1] == 'B' || tmp1[i - 1] == 'b') {
     219        tmp1[i - 1] = '\0';
     220    }
     221    for (i = 0; i < (int) strlen(tmp1) && isdigit(tmp1[i]); i++);
     222    ch = tmp1[i];
     223    tmp1[i] = '\0';
     224    outval = atol(tmp1);
     225    paranoid_free(tmp1);
     226
    228227    if (ch == 'g' || ch == 'G') {
    229228        outval = outval * 1024;
  • branches/2.2.10/mondo/src/common/libmondo-tools.c

    r2383 r2405  
    393393    char *mondo_mkisofs_sz = NULL;
    394394    char *command = NULL;
    395     char *mtpt;
    396395    char *hostname = NULL;
    397396    char *ip_address = NULL;
     
    413412    }
    414413
    415     malloc_string(mtpt);
    416414    bkpinfo->optimal_set_size =
    417415        (IS_THIS_A_STREAMING_BACKUP(bkpinfo->backup_media_type) ? 16 : 16) *
     
    700698    }
    701699    g_backup_media_type = bkpinfo->backup_media_type;
    702     paranoid_free(mtpt);
    703700    return (retval);
    704701}
  • branches/2.2.10/mondo/src/include/my-stuff.h

    r2382 r2405  
    344344#define ARCH_THREADS 2          ///< The number of simultaneous threads running afio in the background.
    345345#define ARCH_BUFFER_NUM (ARCH_THREADS*4)    // Number of permissible queued afio files
    346 #define FORTY_SPACES "                                         "    ///< 40 spaces.
    347     ///< Size of the tmpfs, in megabytes, to attempt to mount (to speed up Mondo).
    348 /*
    349 #define PPCFG_RAMDISK_SIZE 350
    350 */
    351 
    352346#define DO_MBR_PLEASE "/tmp/DO-MBR-PLEASE"
    353347
  • branches/2.2.10/mondo/src/mondorestore/mondo-prep.c

    r2383 r2405  
    6161{
    6262    char *command = NULL;
    63     char *tmp;
    6463    int lino;
    6564    int i;
     
    7271// If LVMs are present and a zero-and-reboot wasn't recently undertaken
    7372// then zero & insist on reboot.
    74     malloc_string(tmp);
    7573    buf = malloc(blocksize);
    7674    if (does_file_exist("/tmp/i-want-my-lvm"))  // FIXME - cheating :)
     
    9189        if (lino == drivelist->entries) {
    9290// zero & reboot
    93             log_to_screen
    94                 ("I am sorry for the inconvenience but I must ask you to reboot.");
    95             log_to_screen
    96                 ("I need to reset the Master Boot Record; in order to be");
    97             log_to_screen
    98                 ("sure the kernel notices, I must reboot after doing it.");
     91            log_to_screen("I am sorry for the inconvenience but I must ask you to reboot.");
     92            log_to_screen("I need to reset the Master Boot Record; in order to be");
     93            log_to_screen("sure the kernel notices, I must reboot after doing it.");
    9994            log_to_screen("Please hit 'Enter' to reboot.");
    10095            for (lino = 0; lino < drivelist->entries; lino++) {
     
    127122    }
    128123// Still here? Cool!
    129     paranoid_free(tmp);
    130124    log_msg(1, "Cool. I didn't have to wipe anything.");
    131125}
  • branches/2.2.10/mondo/src/mondorestore/mondo-rstr-compare.c

    r2357 r2405  
    4343
    4444  /** needs malloc *******/
    45     char *checksum_ptr = NULL;
    46     char *original_cksum_ptr = NULL;
    47     char *bigfile_fname_ptr = NULL;
    48     char *tmp_ptr = NULL;
    49     char *command_ptr = NULL;
    50 
    51     char *checksum, *bigfile_fname, *tmp, *command;
     45    char *checksum = NULL;
     46    char *original_cksum = NULL;
     47    char *bigfile_fname = NULL;
     48    char *tmp = NULL;
     49    char *command = NULL;
    5250
    5351    char *p;
     
    5654
    5755    struct s_filename_and_lstat_info biggiestruct;
    58 
    59     malloc_string(checksum);
    60     malloc_string(bigfile_fname);
    61     malloc_string(tmp);
    62     malloc_string(command);
    6356
    6457  /*********************************************************************
     
    8376    paranoid_fclose(fin);
    8477
    85     mr_asprintf(checksum_ptr, "%s", biggiestruct.checksum);
    86     mr_asprintf(bigfile_fname_ptr, "%s", biggiestruct.filename);
     78    mr_asprintf(checksum, "%s", biggiestruct.checksum);
     79    mr_asprintf(bigfile_fname, "%s", biggiestruct.filename);
    8780
    8881    log_msg(2, "biggiestruct.filename = %s", biggiestruct.filename);
     
    9083
    9184    if (!g_text_mode) {
    92         mr_asprintf(tmp_ptr, "Comparing %s", bigfile_fname_ptr);
    93         newtDrawRootText(0, 22, tmp_ptr);
    94         paranoid_free(tmp_ptr);
     85        mr_asprintf(tmp, "Comparing %s", bigfile_fname);
     86        newtDrawRootText(0, 22, tmp);
     87        paranoid_free(tmp);
    9588        newtRefresh();
    9689    }
    9790    if (!checksum[0]) {
    98         log_msg(2, "Warning - %s has no checksum", bigfile_fname_ptr);
    99     }
    100     if (!strncmp(bigfile_fname_ptr, "/dev/", 5)) {
    101         log_msg(2, "IGNORING %s as begining with /dev", bigfile_fname_ptr);
    102         mr_free(bigfile_fname_ptr);
     91        log_msg(2, "Warning - %s has no checksum", bigfile_fname);
     92    }
     93    if (!strncmp(bigfile_fname, "/dev/", 5)) {
     94        log_msg(2, "IGNORING %s as begining with /dev", bigfile_fname);
     95        mr_free(bigfile_fname);
    10396        return (1);
    10497    }
    10598
    106     mr_asprintf(command_ptr, "md5sum \"%s%s\" > /tmp/md5sum.txt 2> /tmp/errors", MNT_RESTORING, bigfile_fname_ptr);
    107     log_msg(2, command_ptr);
    108     i =  system(command_ptr);
    109     mr_free(command_ptr);
    110 
    111     mr_asprintf(tmp_ptr, "cat /tmp/errors >> %s 2> /dev/null", MONDO_LOGFILE);
    112     paranoid_system(tmp_ptr);
    113     paranoid_free(tmp_ptr);
     99    mr_asprintf(command, "md5sum \"%s%s\" > /tmp/md5sum.txt 2> /tmp/errors", MNT_RESTORING, bigfile_fname);
     100    log_msg(2, command);
     101    i =  system(command);
     102    mr_free(command);
     103
     104    mr_asprintf(tmp, "cat /tmp/errors >> %s 2> /dev/null", MONDO_LOGFILE);
     105    paranoid_system(tmp);
     106    paranoid_free(tmp);
    114107
    115108    if (i) {
     
    120113            log_msg(2,
    121114                    "Unable to open /tmp/md5sum.txt; can't get live checksum");
    122             mr_free(bigfile_fname_ptr);
     115            mr_free(bigfile_fname);
    123116            return (1);
    124117        } else {
    125             mr_getline(original_cksum_ptr, fin);
     118            mr_getline(original_cksum, fin);
    126119            paranoid_fclose(fin);
    127             p = strchr(original_cksum_ptr, ' ');
     120            p = strchr(original_cksum, ' ');
    128121            if (p) {
    129122                *p = '\0';
     
    131124        }
    132125    }
    133     mr_asprintf(tmp_ptr, "bigfile #%ld ('%s') ", bigfileno + 1, bigfile_fname_ptr);
    134     if ((original_cksum_ptr != NULL) && (strcmp(checksum_ptr, original_cksum_ptr) == 0)) {
    135         mr_strcat(tmp_ptr, " ... OK");
    136     } else {
    137         mr_strcat(tmp_ptr, "... changed");
     126    mr_asprintf(tmp, "bigfile #%ld ('%s') ", bigfileno + 1, bigfile_fname);
     127    if ((original_cksum != NULL) && (strcmp(checksum, original_cksum) == 0)) {
     128        mr_strcat(tmp, " ... OK");
     129    } else {
     130        mr_strcat(tmp, "... changed");
    138131        retval++;
    139132    }
    140     mr_free(checksum_ptr);
    141     mr_free(original_cksum_ptr);
    142 
    143     log_msg(1, tmp_ptr);
    144     paranoid_free(tmp_ptr);
     133    mr_free(checksum);
     134    mr_free(original_cksum);
     135
     136    log_msg(1, tmp);
     137    paranoid_free(tmp);
    145138
    146139    if (retval) {
     
    148141            fatal_error("Cannot openout changed.txt");
    149142        }
    150         fprintf(fout, "%s\n", bigfile_fname_ptr);
     143        fprintf(fout, "%s\n", bigfile_fname);
    151144        paranoid_fclose(fout);
    152145    }
    153     mr_free(bigfile_fname_ptr);
    154 
    155     paranoid_free(bigfile_fname);
    156     paranoid_free(checksum);
    157     paranoid_free(command);
    158     paranoid_free(tmp);
     146    mr_free(bigfile_fname);
    159147
    160148    return (retval);
  • branches/2.2.10/mondo/src/mondorestore/mondo-rstr-tools.c

    r2404 r2405  
    698698t_bkptype media_specified_by_user;
    699699
    700 malloc_string(tmp);
    701700//  assert_string_is_neither_NULL_nor_zerolength(cfg_file);
    702701assert(bkpinfo != NULL);
     
    10991098g_backup_media_type = bkpinfo->backup_media_type;
    11001099paranoid_free(value);
    1101 paranoid_free(tmp);
    11021100return (0);
    11031101
     
    14991497    char *command = NULL;
    15001498    char *boot_device = NULL;
    1501     char *rootdev;
    1502     char *rootdrive;
    1503     char *conffile;
    15041499    char *tmp = NULL;
    15051500    char *editor = NULL;
     
    15091504    bool done;
    15101505
    1511     malloc_string(rootdev);
    1512     malloc_string(rootdrive);
    1513     malloc_string(conffile);
    15141506    assert_string_is_neither_NULL_nor_zerolength(bd);
    15151507    mr_asprintf(boot_device, "%s", bd);
     
    16171609        mvaddstr_and_log_it(g_currentY++, 74, "Done.");
    16181610    }
    1619     paranoid_free(rootdev);
    1620     paranoid_free(rootdrive);
    1621     paranoid_free(conffile);
    16221611
    16231612    return (res);
     
    21902179
    21912180   /** malloc *****/
    2192     char *device;
    21932181    char *command = NULL;
    21942182    char *cfg_file = NULL;
    2195     char *mounted_cfgf_path;
    21962183    char *tmp = NULL;
    21972184    char *tmp1 = NULL;
    21982185    char *mountpt = NULL;
    2199     char *ramdisk_fname;
    22002186    char *mountlist_file = NULL;
    22012187    bool extract_mountlist_stub = FALSE;
     
    22052191
    22062192    assert(bkpinfo != NULL);
    2207     malloc_string(mounted_cfgf_path);
    2208     malloc_string(ramdisk_fname);
    2209     malloc_string(device);
    22102193    log_msg(2, "gcffa --- starting");
    22112194    log_to_screen("I'm thinking...");
    22122195    mr_asprintf(mountpt, "%s/mount.bootdisk", bkpinfo->tmpdir);
    2213     device[0] = '\0';
    22142196    chdir(bkpinfo->tmpdir);
    22152197    mr_asprintf(cfg_file, "%s", MONDO_CFG_FILE_STUB);
     
    23942376    }
    23952377    g_backup_media_type = bkpinfo->backup_media_type;
    2396     paranoid_free(device);
    2397     paranoid_free(mounted_cfgf_path);
    2398     paranoid_free(ramdisk_fname);
    23992378    return (retval);
    24002379}
  • branches/2.2.10/mondo/src/mondorestore/mondorestore.c

    r2395 r2405  
    10281028    char *tmp = NULL;
    10291029    char *bzip2_command = NULL;
    1030     char *ntfsprog_command;
    10311030    char *suffix = NULL;
    10321031    char *sz_devfile = NULL;
     
    10501049    ubuf = &the_utime_buf;
    10511050    assert(bkpinfo != NULL);
    1052 
    1053     malloc_string(ntfsprog_command);
    10541051
    10551052    pathname_of_last_file_restored[0] = '\0';
     
    12681265    mr_free(outfile_fname);
    12691266    paranoid_free(bigblk);
    1270     paranoid_free(ntfsprog_command);
    12711267
    12721268    return (retval);
     
    13071303    char *command = NULL;
    13081304    char *outfile_fname = NULL;
    1309     char *ntfsprog_command;
    13101305    char *sz_devfile = NULL;
    13111306    char *ntfsprog_fifo = NULL;
     
    13281323
    13291324    malloc_string(tmp);
    1330     malloc_string(ntfsprog_command);
    13311325    old_loglevel = g_loglevel;
    13321326    assert(bkpinfo != NULL);
     
    15161510
    15171511    paranoid_free(tmp);
    1518     paranoid_free(ntfsprog_command);
    15191512    g_loglevel = old_loglevel;
    15201513    return (retval);
     
    19291922 * @return 0 for success, nonzero for failure.
    19301923 */
    1931 int
    1932 restore_all_biggiefiles_from_CD(struct s_node *filelist)
    1933 {
     1924int restore_all_biggiefiles_from_CD(struct s_node *filelist) {
     1925
    19341926    int retval = 0;
    19351927    int res = 0;
Note: See TracChangeset for help on using the changeset viewer.