Ignore:
Timestamp:
Aug 18, 2009, 3:13:54 PM (15 years ago)
Author:
Bruno Cornec
Message:

r3335@localhost: bruno | 2009-08-08 23:04:12 +0200

  • Change mr_asprintf to avoid the need of pointer and be consistent with the other mr_mem functions
File:
1 edited

Legend:

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

    r2323 r2324  
    108108{
    109109    char *tmp = NULL;
    110     char *comment = NULL;
    111110    bool is_this_a_ramdisk = FALSE;
    112111
    113112    mr_asprintf(tmp, "%s", where_is_root_mounted());
    114     mr_asprintf(comment, "root is currently mounted at %s\n", tmp);
    115     log_msg(0, comment);
    116     mr_free(comment);
     113    log_msg(0, "root is currently mounted at %s\n", tmp);
    117114
    118115#ifdef __FreeBSD__
     
    221218        mr_asprintf(command, "cdcontrol -f %s eject", dev);
    222219    } else {
    223         mr_asprintf(command, "camcontrol eject `echo %s | sed 's|/dev/||'`",
    224                 dev);
     220        mr_asprintf(command, "camcontrol eject `echo %s | sed 's|/dev/||'`", dev);
    225221    }
    226222#else
     
    500496{
    501497    /*@ buffers ************************ */
    502     char *comment = NULL;
    503498    char *tmp = NULL;
    504499    char *cdr_exe = NULL;
     
    532527    } else {
    533528        strcpy(cdrw_device, tmp);
    534         mr_asprintf(comment, "Found CDRW device - %s", cdrw_device);
    535         log_it(comment);
     529        log_it("Found CDRW device - %s", cdrw_device);
    536530        strcpy(g_cdrw_drive_is_here, cdrw_device);
    537         mr_free(comment);
    538531        mr_free(tmp);
    539532        mr_free(cdr_exe);
     
    876869    }
    877870
    878     mr_asprintf(tmp, "%s", call_program_and_get_last_line_of_output
    879             ("dvdrecord -scanbus 2> /dev/null | grep \") '\" | grep -n \"\" | grep DVD | cut -d':' -f1")
     871    mr_asprintf(tmp, "%s", call_program_and_get_last_line_of_output("dvdrecord -scanbus 2> /dev/null | grep \") '\" | grep -n \"\" | grep DVD | cut -d':' -f1")
    880872        );
    881873    log_msg(5, "tmp = '%s'", tmp);
    882874    if (!tmp[0])
    883875        mr_free(tmp);
    884         mr_asprintf(tmp, "%s", call_program_and_get_last_line_of_output
    885                 ("cdrecord -scanbus 2> /dev/null | grep \") '\" | grep -n \"\" | grep DVD | cut -d':' -f1")
     876        mr_asprintf(tmp, "%s", call_program_and_get_last_line_of_output ("cdrecord -scanbus 2> /dev/null | grep \") '\" | grep -n \"\" | grep DVD | cut -d':' -f1")
    886877            );
    887878    if (tmp[0]) {
     
    10901081    malloc_string(incoming);
    10911082    assert(device_raw != NULL);
    1092 //  assert_string_is_neither_NULL_nor_zerolength(device_raw);
    10931083    if (device_raw[0] != '/' && !strstr(device_raw, ":/")) {
    10941084        log_msg(1, "%s needs to have a '/' prefixed - I'll do it",
     
    13721362                log_msg(1, "FIXME - hacking bkpinfo->isodir from '%s' to %s/isodir", bkpinfo->isodir, bkpinfo->tmpdir);
    13731363                mr_free(bkpinfo->isodir);
    1374                 mr_asprintf(p, "%s/isodir", bkpinfo->tmpdir);
    1375                 bkpinfo->isodir = p;
     1364                mr_asprintf(bkpinfo->isodir, "%s/isodir", bkpinfo->tmpdir);
    13761365            }
    13771366        }
     
    13871376                cd_number_i_want);
    13881377        mds = media_descriptor_string(bkpinfo->backup_media_type);
    1389         mr_asprintf(tmp, "Insisting on %s #%d", mds, cd_number_i_want);
     1378        log_msg(3, "Insisting on %s #%d", mds, cd_number_i_want);
    13901379        mr_asprintf(request, "Please insert %s #%d and press Enter.", mds, cd_number_i_want);
    13911380        mr_free(mds);
    1392         log_msg(3, tmp);
    1393         mr_free(tmp);
    13941381
    13951382        while (what_number_cd_is_this() != cd_number_i_want) {
     
    17311718            mr_asprintf(command, "mount | grep \"%s \" | cut -d' ' -f3", bkpinfo->nfs_mount);
    17321719            mr_free(bkpinfo->isodir);
    1733             mr_asprintf(p, "%s", call_program_and_get_last_line_of_output(command));
    1734             bkpinfo->isodir = p;
     1720            mr_asprintf(bkpinfo->isodir, "%s", call_program_and_get_last_line_of_output(command));
    17351721            mr_free(command);
    17361722
     
    17721758        mr_free(bkpinfo->isodir);
    17731759        if (is_this_device_mounted(bkpinfo->nfs_mount)) {
    1774             mr_asprintf(p, "%s", call_program_and_get_last_line_of_output("mount | grep \":\" | cut -d' ' -f3 | head -n1"));
    1775             bkpinfo->isodir = p;
     1760            mr_asprintf(bkpinfo->isodir, "%s", call_program_and_get_last_line_of_output("mount | grep \":\" | cut -d' ' -f3 | head -n1"));
    17761761
    17771762        } else {
    1778             mr_asprintf(p, "%s/nfsdir", bkpinfo->tmpdir);
    1779             bkpinfo->isodir = p;
     1763            mr_asprintf(bkpinfo->isodir, "%s/nfsdir", bkpinfo->tmpdir);
    17801764            mr_asprintf(command, "mkdir -p %s", bkpinfo->isodir);
    17811765            run_program_and_log_output(command, 5);
     
    17901774        }
    17911775        if (!is_this_device_mounted(bkpinfo->nfs_mount)) {
    1792             popup_and_OK
    1793                 ("Please mount that partition before you try to backup to or restore from it.");
     1776            popup_and_OK("Please mount that partition before you try to backup to or restore from it.");
    17941777            finish(1);
    17951778        }
     
    21522135        fatal_error("I couldn't figure out the scratchdir!");
    21532136    }
    2154     mr_asprintf(sz, "%s/mondo.scratch.%d", tmp, (int) (random() % 32768));
    21552137    mr_free(bkpinfo->scratchdir);
    2156     bkpinfo->scratchdir = sz;
     2138    mr_asprintf(bkpinfo->scratchdir , "%s/mondo.scratch.%d", tmp, (int) (random() % 32768));
    21572139    log_it("bkpinfo->scratchdir is being set to %s", bkpinfo->scratchdir);
    21582140
     
    22282210
    22292211    assert(bkpinfo != NULL);
    2230 //  log_it("Asking what_number_cd_is_this");
     2212    //  log_it("Asking what_number_cd_is_this");
    22312213    if (g_ISO_restore_mode) {
    22322214        mr_asprintf(tmp, "mount | grep iso9660 | awk '{print $3;}'");
    2233 
    22342215        mr_asprintf(mountdev, "%s%s", call_program_and_get_last_line_of_output(tmp), "/archives/THIS-CD-NUMBER");
    22352216        cd_number = atoi(last_line_of_file(mountdev));
    2236         paranoid_free(mountdev);
    2237         paranoid_free(tmp);
     2217        mr_free(mountdev);
     2218        mr_free(tmp);
    22382219
    22392220        return (cd_number);
     
    22422223    mr_asprintf(mountdev, "%s", bkpinfo->media_device);
    22432224    if (!mountdev[0]) {
    2244         log_it
    2245             ("(what_number_cd_is_this) Warning - media_device unknown. Finding out...");
     2225        log_it("(what_number_cd_is_this) Warning - media_device unknown. Finding out...");
    22462226        find_cdrom_device(bkpinfo->media_device, FALSE);
    22472227    }
     
    22532233        }
    22542234    }
    2255     paranoid_free(mountdev);
     2235    mr_free(mountdev);
    22562236
    22572237    cd_number = atoi(last_line_of_file(MNT_CDROM "/archives/THIS-CD-NUMBER"));
Note: See TracChangeset for help on using the changeset viewer.