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/common/libmondo-files.c

    r2289 r2296  
    7171        mr_free(command);
    7272    } else {
    73         mr_asprintf(&tmp, "File '%s' not found; cannot calc checksum",
    74                 filename);
     73        mr_asprintf(&tmp, "File '%s' not found; cannot calc checksum", filename);
    7574        log_it(tmp);
    7675        mr_free(tmp);
     
    143142    assert_string_is_neither_NULL_nor_zerolength(filename);
    144143    if (!does_file_exist(filename)) {
    145         mr_asprintf(&tmp,
    146                 "%s does not exist, so I cannot found the number of lines in it",
    147                 filename);
     144        mr_asprintf(&tmp, "%s does not exist, so I cannot found the number of lines in it", filename);
    148145        log_it(tmp);
    149146        mr_free(tmp);
     
    358355            return (NULL);      // forget it :)
    359356        }
    360         mr_asprintf(&command,
    361                 "file %s 2> /dev/null | cut -d':' -f1 2> /dev/null",
    362                 incoming);
     357        mr_asprintf(&command, "file %s 2> /dev/null | cut -d':' -f1 2> /dev/null", incoming);
    363358        strcpy(incoming,
    364359               call_program_and_get_last_line_of_output(command));
     
    459454         && !strstr(err_log_lines[i], "% done"); i--);
    460455    if (i < 0) {
    461         mr_asprintf(&command,
    462                 "tail -n3 %s | grep -Fi \"%c\" | tail -n1 | awk '{print $0;}'",
    463                 filename, '%');
     456        mr_asprintf(&command, "tail -n3 %s | grep -Fi \"%c\" | tail -n1 | awk '{print $0;}'", filename, '%');
    464457        strcpy(lastline,
    465458               call_program_and_get_last_line_of_output(command));
     
    512505
    513506    if (!does_file_exist(filename)) {
    514         mr_asprintf(&tmp, "Tring to get last line of nonexistent file (%s)",
    515                 filename);
     507        mr_asprintf(&tmp, "Tring to get last line of nonexistent file (%s)", filename);
    516508        log_it(tmp);
    517509        mr_free(tmp);
     
    630622                time_remaining =
    631623                    time_taken * 100 / (long) (percentage) - time_taken;
    632                 mr_asprintf(&tmp,
    633                         "%02d%% done   %02d:%02d taken   %02d:%02d remaining  %-37s\r",
    634                         percentage, (int) (time_taken / 60),
    635                         (int) (time_taken % 60),
    636                         (int) (time_remaining / 60),
    637                         (int) (time_remaining % 60), curr_fname);
     624                mr_asprintf(&tmp, "%02d%% done   %02d:%02d taken   %02d:%02d remaining  %-37s\r", percentage, (int) (time_taken / 60), (int) (time_taken % 60), (int) (time_remaining / 60), (int) (time_remaining % 60), curr_fname);
    638625                log_to_screen(tmp);
    639626                mr_free(tmp);
     
    758745
    759746    mr_asprintf(&mountlist, "%s/mountlist.txt", tmpdir);
    760     mr_asprintf(&command,
    761             "grep \"%s \" %s/mountlist.txt | head -n1 | awk '{print $4}'",
    762             dev, tmpdir);
     747    mr_asprintf(&command, "grep \"%s \" %s/mountlist.txt | head -n1 | awk '{print $4}'", dev, tmpdir);
    763748    mr_free(mountlist);
    764749
     
    837822                log_msg(4, "%s --> %ld K", fname, file_len_K);
    838823            }
    839             mr_asprintf(&comment,
    840                     "After adding %s, scratchL+%ld now equals %ld", fname,
    841                     file_len_K, scratchL);
     824            mr_asprintf(&comment, "After adding %s, scratchL+%ld now equals %ld", fname, file_len_K, scratchL);
    842825            log_msg(4, comment);
    843826            mr_free(comment);
     
    10601043        find_and_store_mondoarchives_home(g_mondo_home);
    10611044    }
    1062     mr_asprintf(&command, CP_BIN " --parents -pRdf %s %s", g_mondo_home,
    1063             bkpinfo->scratchdir);
     1045    mr_asprintf(&command, CP_BIN " --parents -pRdf %s %s", g_mondo_home, bkpinfo->scratchdir);
    10641046
    10651047    log_msg(4, "command = %s", command);
     
    10711053    }
    10721054
    1073     mr_asprintf(&command, "cp -f %s/LAST-FILELIST-NUMBER %s", bkpinfo->tmpdir,
    1074             bkpinfo->scratchdir);
     1055    mr_asprintf(&command, "cp -f %s/LAST-FILELIST-NUMBER %s", bkpinfo->tmpdir, bkpinfo->scratchdir);
    10751056    res = run_program_and_log_output(command, FALSE);
    10761057    mr_free(command);
     
    10991080
    11001081    if (bkpinfo->postnuke_tarball[0]) {
    1101         mr_asprintf(&command, "cp -f %s %s/post-nuke.tgz",
    1102                 bkpinfo->postnuke_tarball, bkpinfo->tmpdir);
     1082        mr_asprintf(&command, "cp -f %s %s/post-nuke.tgz", bkpinfo->postnuke_tarball, bkpinfo->tmpdir);
    11031083        res = run_program_and_log_output(command, FALSE);
    11041084        mr_free(command);
     
    11501130    }
    11511131    *(p++) = '\0';
    1152     mr_asprintf(&nfs_server_ipaddr, tmp);
    1153     mr_asprintf(&nfs_mount, p);
     1132    mr_asprintf(&nfs_server_ipaddr, "%s", tmp);
     1133    mr_asprintf(&nfs_mount, "%s", p);
    11541134    mr_free(tmp);
    11551135
    11561136    /* BERLIOS : there is a bug #67 here as it only considers the first NIC */
    1157     mr_asprintf(&command,
    1158             "ifconfig | tr '\n' '#' | sed s/##// | tr '#' ' ' | tr '' '\n' | head -n1 | cut -d' ' -f1");
     1137    mr_asprintf(&command, "ifconfig | tr '\n' '#' | sed s/##// | tr '#' ' ' | tr '' '\n' | head -n1 | cut -d' ' -f1");
    11591138    mr_asprintf(&nfs_dev, "%s", call_program_and_get_last_line_of_output(command));
    11601139    mr_free(command);
    11611140
    1162     mr_asprintf(&command,
    1163             "%s", "ifconfig | tr '\n' '#' | sed s/##// | tr '#' ' ' | tr '' '\\n' | head -n1 | tr -s '\t' ' ' | cut -d' ' -f7 | cut -d':' -f2");
     1141    mr_asprintf(&command, "%s", "ifconfig | tr '\n' '#' | sed s/##// | tr '#' ' ' | tr '' '\\n' | head -n1 | tr -s '\t' ' ' | cut -d' ' -f7 | cut -d':' -f2");
    11641142    mr_asprintf(&nfs_client_ipaddr, "%s", call_program_and_get_last_line_of_output(command));
    11651143    mr_free(command);
    11661144
    1167     mr_asprintf(&command,
    1168             "%s", "ifconfig | tr '\n' '#' | sed s/##// | tr '#' ' ' | tr '' '\\n' | head -n1 | tr -s '\t' ' ' | cut -d' ' -f9 | cut -d':' -f2");
     1145    mr_asprintf(&command, "%s", "ifconfig | tr '\n' '#' | sed s/##// | tr '#' ' ' | tr '' '\\n' | head -n1 | tr -s '\t' ' ' | cut -d' ' -f9 | cut -d':' -f2");
    11691146    mr_asprintf(&nfs_client_netmask, "%s", call_program_and_get_last_line_of_output(command));
    11701147    mr_free(command);
    11711148
    1172     mr_asprintf(&command,
    1173             "%s", "ifconfig | tr '\n' '#' | sed s/##// | tr '#' ' ' | tr '' '\\n' | head -n1 | tr -s '\t' ' ' | cut -d' ' -f8 | cut -d':' -f2");
     1149    mr_asprintf(&command, "%s", "ifconfig | tr '\n' '#' | sed s/##// | tr '#' ' ' | tr '' '\\n' | head -n1 | tr -s '\t' ' ' | cut -d' ' -f8 | cut -d':' -f2");
    11741150    mr_asprintf(&nfs_client_broadcast, "%s", call_program_and_get_last_line_of_output(command));
    11751151    mr_free(command);
    11761152
    1177     mr_asprintf(&command,
    1178             "%s", "route -n | grep '^0.0.0.0' | awk '{print $2}'");
     1153    mr_asprintf(&command, "%s", "route -n | grep '^0.0.0.0' | awk '{print $2}'");
    11791154    mr_asprintf(&nfs_client_defgw, "%s", call_program_and_get_last_line_of_output(command));
    11801155    mr_free(command);
     
    11951170    if (!strncmp(nfs_dev, "bond", 4) || !strncmp(nfs_dev, "alb", 3) || !strncmp(nfs_dev, "aft", 3)) {
    11961171        log_to_screen("Found bonding device %s; looking for corresponding ethN slave device\n", nfs_dev);
    1197         mr_asprintf(&command,
    1198                 "%s", "ifconfig %s | awk '{print $5}' | head -n1", nfs_dev);
     1172        mr_asprintf(&command, "%s", "ifconfig %s | awk '{print $5}' | head -n1", nfs_dev);
    11991173        mr_asprintf(&mac_addr, "%s", call_program_and_get_last_line_of_output(command));
    12001174        mr_free(command);
     
    12041178        mr_free(nfs_dev);
    12051179
    1206         mr_asprintf(&nfs_dev, call_program_and_get_last_line_of_output(command));
     1180        mr_asprintf(&nfs_dev, "%s", call_program_and_get_last_line_of_output(command));
    12071181        mr_free(command);
    12081182
     
    13131287        mr_free(mds);
    13141288    } else if (scratchLL > 4) {
    1315         mr_asprintf(&tmp,
    1316                 "Your backup will occupy one meeeeellion media! (maybe %s)",
    1317                 number_to_text((int) (scratchLL + 1)));
     1289        mr_asprintf(&tmp, "Your backup will occupy one meeeeellion media! (maybe %s)", number_to_text((int) (scratchLL + 1)));
    13181290    } else {
    1319         mr_asprintf(&tmp, "Your backup will occupy approximately %s media.",
    1320                 number_to_text((int) (scratchLL + 1)));
     1291        mr_asprintf(&tmp, "Your backup will occupy approximately %s media.", number_to_text((int) (scratchLL + 1)));
    13211292    }
    13221293    if (!bkpinfo->image_devs[0] && (scratchLL < 50)) {
Note: See TracChangeset for help on using the changeset viewer.