Ignore:
Timestamp:
Jul 23, 2009, 2:53:30 PM (15 years ago)
Author:
Bruno Cornec
Message:
  • Replace sprintf by mr_asprintf in mondo-rstr-compare.c
  • All mr_asprintf call should be on one line (for quality script) and use a string as second param
  • Improve quality script
File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/2.2.10/mondo/src/mondorestore/mondo-prep.c

    r2291 r2296  
    7979        make_list_of_drives_in_mountlist(mountlist, drivelist);
    8080        for (lino = 0; lino < drivelist->entries; lino++) {
    81             mr_asprintf(&command,
    82                     "dd if=%s bs=512 count=1 2> /dev/null | grep \"%s\"",
    83                     drivelist->el[lino].device, MONDO_WAS_HERE);
     81            mr_asprintf(&command, "dd if=%s bs=512 count=1 2> /dev/null | grep \"%s\"", drivelist->el[lino].device, MONDO_WAS_HERE);
    8482            res = run_program_and_log_output(command, 1);
    8583            mr_free(command);
     
    260258        strcpy(vgremove_sz, "vgremove");
    261259    }
    262     mr_asprintf(&tmp1,
    263             "for i in `%s | cut -d\"'\" -f2 | sort -r` ; do echo \"Shutting down lv $i\" >> %s ; %s -f $i; done", lvscan_sz, MONDO_LOGFILE, lvremove_sz);
     260    mr_asprintf(&tmp1, "for i in `%s | cut -d\"'\" -f2 | sort -r` ; do echo \"Shutting down lv $i\" >> %s ; %s -f $i; done", lvscan_sz, MONDO_LOGFILE, lvremove_sz);
    264261    run_program_and_log_output(tmp1, 5);
    265262    mr_free(tmp1);
     
    521518                            new_mountlist->entries++;
    522519                        } else {
    523                             mr_asprintf(&tmp,
    524                                     "Not adding %s to mountlist: it's already there",
    525                                     p);
     520                            mr_asprintf(&tmp, "Not adding %s to mountlist: it's already there", p);
    526521                            log_it(tmp);
    527522                            mr_free(tmp);
     
    647642    mr_asprintf(&strtmp, "%s", program);
    648643    paranoid_free(program);
    649     mr_asprintf(&program, "%s --spare-devices=%d", strtmp,
    650          raidlist->el[i].spare_disks.entries);
     644    mr_asprintf(&program, "%s --spare-devices=%d", strtmp, raidlist->el[i].spare_disks.entries);
    651645    paranoid_free(strtmp);
    652646  }
     
    747741
    748742            /* format raid partition */
    749             mr_asprintf(&program,
    750                     "for plex in `vinum lv -r %s | grep '^P' | tr '\t' ' ' | tr -s ' ' | cut -d' ' -f2`; do echo $plex; done > /tmp/plexes", basename(device));
     743            mr_asprintf(&program, "for plex in `vinum lv -r %s | grep '^P' | tr '\t' ' ' | tr -s ' ' | cut -d' ' -f2`; do echo $plex; done > /tmp/plexes", basename(device));
    751744            system(program);
    752745            if (g_fprep) {
     
    914907
    915908    assert(mountlist != NULL);
    916     mr_asprintf(&tmp, "format_everything (mountlist, interactively = %s",
    917             (interactively) ? "true" : "false");
     909    mr_asprintf(&tmp, "format_everything (mountlist, interactively = %s", (interactively) ? "true" : "false");
    918910    log_it(tmp);
    919911    mr_free(tmp);
     
    943935            if (interactively) {
    944936                // ask user if we should format the current device
    945                 mr_asprintf(&tmp, "Shall I format %s (%s) ?", me->device,
    946                         me->mountpoint);
     937                mr_asprintf(&tmp, "Shall I format %s (%s) ?", me->device, me->mountpoint);
    947938                do_it = ask_me_yes_or_no(tmp);
    948939                mr_free(tmp);
     
    14251416    mr_free(command);
    14261417
    1427     mr_asprintf(&command, "disklabel -R %s /tmp/disklabel",
    1428             canonical_name(drivename));
     1418    mr_asprintf(&command, "disklabel -R %s /tmp/disklabel", canonical_name(drivename));
    14291419    retval += run_program_and_log_output(command, TRUE);
    14301420    mr_free(command);
     
    15711561            file = open(drivename, O_WRONLY);
    15721562            if (file != -1) {
    1573                 mr_asprintf(&tmp,
    1574                         "Warning - unable to open %s for wiping it's partition table",
    1575                         drivename);
     1563                mr_asprintf(&tmp, "Warning - unable to open %s for wiping it's partition table", drivename);
    15761564                log_to_screen(tmp);
    15771565                mr_free(tmp);
     
    15801568            for (i = 0; i < 512; i++) {
    15811569                if (!write(file, "\0", 1)) {
    1582                     mr_asprintf(&tmp, "Warning - unable to write to %s",
    1583                             drivename);
     1570                    mr_asprintf(&tmp, "Warning - unable to write to %s", drivename);
    15841571                    log_to_screen(tmp);
    15851572                    mr_free(tmp);
     
    16421629    if (pout_to_fdisk) {
    16431630// mark relevant partition as bootable
    1644         mr_asprintf(&tmp, "a\n%s\n",
    1645                 call_program_and_get_last_line_of_output
    1646                 ("make-me-bootable /tmp/mountlist.txt dummy"));
     1631        mr_asprintf(&tmp, "a\n%s\n", call_program_and_get_last_line_of_output("make-me-bootable /tmp/mountlist.txt dummy"));
    16471632        fput_string_one_char_at_a_time(pout_to_fdisk, tmp);
    16481633        mr_free(tmp);
     
    17391724
    17401725    if (is_this_device_mounted(partition_name)) {
    1741         mr_asprintf(&tmp, "%s is mounted, and should not be partitioned",
    1742                 partition_name);
     1726        mr_asprintf(&tmp, "%s is mounted, and should not be partitioned", partition_name);
    17431727        log_to_screen(tmp);
    17441728        mr_free(tmp);
     
    20502034    } else {
    20512035        /* probably an image */
    2052         mr_asprintf(&tmp,
    2053                 "Unknown format ('%s') - using supplied string anyway",
    2054                 format);
     2036        mr_asprintf(&tmp, "Unknown format ('%s') - using supplied string anyway", format);
    20552037        mvaddstr_and_log_it(g_currentY++, 0, tmp);
    20562038        mr_free(tmp);
Note: See TracChangeset for help on using the changeset viewer.