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-files.c

    r2323 r2324  
    4848    static char output[MAX_STR_LEN];
    4949    char *command = NULL;
    50     char *tmp = NULL;
    5150
    5251    /*@ pointers **************************************************** */
     
    7170        mr_free(command);
    7271    } else {
    73         mr_asprintf(tmp, "File '%s' not found; cannot calc checksum", filename);
    74         log_it(tmp);
    75         mr_free(tmp);
     72        log_it("File '%s' not found; cannot calc checksum", filename);
    7673    }
    7774    if (p) {
     
    129126    char *command = NULL;
    130127    char incoming[MAX_STR_LEN];
    131     char *tmp = NULL;
    132128
    133129    /*@ long ******************************************************** */
     
    142138    assert_string_is_neither_NULL_nor_zerolength(filename);
    143139    if (!does_file_exist(filename)) {
    144         mr_asprintf(tmp, "%s does not exist, so I cannot found the number of lines in it", filename);
    145         log_it(tmp);
    146         mr_free(tmp);
     140        log_it("%s does not exist, so I cannot found the number of lines in it", filename);
    147141        return (0);
    148142    }
     
    251245            fprintf(fout, "%s\n", incoming);
    252246        } else {
    253             mr_asprintf(tmp, "Excluding '%s'-nonexistent\n", incoming);
    254             log_it(tmp);
    255             mr_free(tmp);
     247            log_it("Excluding '%s'-nonexistent\n", incoming);
    256248        }
    257249    }
     
    354346        }
    355347        mr_asprintf(command, "file %s 2> /dev/null | cut -d':' -f1 2> /dev/null", incoming);
    356         strcpy(incoming,
    357                call_program_and_get_last_line_of_output(command));
     348        strcpy(incoming, call_program_and_get_last_line_of_output(command));
    358349        mr_free(command);
    359350    }
     
    361352    {
    362353        mr_asprintf(command, "dirname %s 2> /dev/null", incoming);
    363         strcpy(incoming,
    364                call_program_and_get_last_line_of_output(command));
     354        strcpy(incoming, call_program_and_get_last_line_of_output(command));
    365355        mr_free(command);
    366356    }
     
    453443    if (i < 0) {
    454444        mr_asprintf(command, "tail -n3 %s | grep -Fi \"%c\" | tail -n1 | awk '{print $0;}'", filename, '%');
    455         strcpy(lastline,
    456                call_program_and_get_last_line_of_output(command));
     445        strcpy(lastline, call_program_and_get_last_line_of_output(command));
    457446        mr_free(command);
    458447        if (!lastline[0]) {
     
    495484    static char output[MAX_STR_LEN];
    496485    char *command = NULL;
    497     char *tmp = NULL;
    498486
    499487    /*@ pointers **************************************************** */
     
    503491
    504492    if (!does_file_exist(filename)) {
    505         mr_asprintf(tmp, "Tring to get last line of nonexistent file (%s)", filename);
    506         log_it(tmp);
    507         mr_free(tmp);
     493        log_it("Tring to get last line of nonexistent file (%s)", filename);
    508494        output[0] = '\0';
    509495        return (output);
     
    618604                /*              printf("%0d%% done      \r",percentage); */
    619605            } else {
    620                 time_remaining =
    621                     time_taken * 100 / (long) (percentage) - time_taken;
    622                 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);
    623                 log_to_screen(tmp);
    624                 mr_free(tmp);
     606                time_remaining = time_taken * 100 / (long) (percentage) - time_taken;
     607                log_to_screen("%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);
    625608            }
    626609            sync();
     
    820803                log_msg(4, "%s --> %ld K", fname, file_len_K);
    821804            }
    822             mr_asprintf(comment, "After adding %s, scratchL+%ld now equals %ld", fname, file_len_K, scratchL);
    823             log_msg(4, comment);
    824             mr_free(comment);
     805            log_msg(4, "After adding %s, scratchL+%ld now equals %ld", fname, file_len_K, scratchL);
    825806            if (feof(fin)) {
    826807                break;
     
    920901    /*@ buffers *** */
    921902    char *command = NULL;
    922     char *errorstr = NULL;
    923903    int res = 0;
    924904
     
    928908
    929909    if (res) {
    930         mr_asprintf(errorstr, "Please install '%s'. I cannot find it on your system.", fname);
    931         log_to_screen(errorstr);
    932         mr_free(errorstr);
     910        log_to_screen("Please install '%s'. I cannot find it on your system.", fname);
    933911        log_to_screen("There may be hyperlink at http://www.mondorescue.com which");
    934912        log_to_screen("will take you to the relevant (missing) package.");
     
    10311009    char *command = NULL;
    10321010    char tmp[MAX_STR_LEN];
    1033     char old_pwd[MAX_STR_LEN];
    10341011    int res = 0;
    10351012
     
    11241101    p = strchr(tmp, ':');
    11251102    if (!p) {
    1126         fatal_error
    1127             ("NFS mount doesn't have a colon in it, e.g. 192.168.1.4:/home/nfs");
     1103        fatal_error("NFS mount doesn't have a colon in it, e.g. 192.168.1.4:/home/nfs");
    11281104    }
    11291105    *(p++) = '\0';
     
    12291205
    12301206
    1231 
    1232 
    1233 
    1234 
    12351207/**
    12361208 * Determine the approximate number of media that the backup will take up,
Note: See TracChangeset for help on using the changeset viewer.