Changeset 2263


Ignore:
Timestamp:
Jul 12, 2009, 2:04:33 AM (10 years ago)
Author:
bruno
Message:

r3204@localhost: bruno | 2009-07-06 19:26:34 +0200

  • Replace sprintf by mr_asprintf in libmondo-fifo.c
File:
1 edited

Legend:

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

    r2217 r2263  
    7171                             long internal_tape_block_size)
    7272{
    73     char sz_dir[32];
    7473    char keych;
    75     char *tmp;
    76     char *command;
     74    char *sz_dir = NULL;
     75    char *tmp = NULL;
     76    char *command = NULL;
    7777    FILE *fres;
    7878    int bufsize;                // in megabytes
     
    8181    int wise_lower_limit;
    8282
    83     malloc_string(tmp);
    84     malloc_string(command);
    8583    assert_string_is_neither_NULL_nor_zerolength(device);
    8684    assert(direction == 'w' || direction == 'r');
    87     sprintf(sz_dir, "%c", direction);
    8885    wise_upper_limit = (am_I_in_disaster_recovery_mode()? 8 : 32);
    8986    wise_lower_limit = 1;       // wise_upper_limit/2 + 1;
     
    9188    for (bufsize = wise_upper_limit, res = -1;
    9289         res != 0 && bufsize >= wise_lower_limit; bufsize--) {
    93         sprintf(tmp,
     90        mr_asprintf(&tmp,
    9491                "dd if=/dev/zero bs=1024 count=16k 2> /dev/null | buffer -o /dev/null -s %ld -m %d%c",
    9592                internal_tape_block_size, bufsize, 'm');
    9693        res = run_program_and_log_output(tmp, 2);
     94        mr_free(tmp);
    9795    }
    9896    if (!res) {
    9997        bufsize++;
    100         sprintf(tmp, "Negotiated max buffer of %d MB ", bufsize);
     98        mr_asprintf(&tmp, "Negotiated max buffer of %d MB ", bufsize);
    10199        log_to_screen(tmp);
     100        mr_free(tmp);
    102101    } else {
    103102        bufsize = 0;
     
    121120    }
    122121    log_msg(2, "Calling buffer --- command = '%s'", g_sz_call_to_buffer);
     122    mr_asprintf(&sz_dir, "%c", direction);
    123123    fres = popen(g_sz_call_to_buffer, sz_dir);
     124    mr_free(sz_dir);
     125
    124126    if (fres) {
    125127        log_msg(2, "Successfully opened ('%c') tape device %s", direction,
     
    130132    }
    131133    sleep(2);
    132     sprintf(tmp, "ps %s | grep \"%s\"", ps_options, g_sz_call_to_buffer);
     134    mr_asprintf(&tmp, "ps %s | grep \"%s\"", ps_options, g_sz_call_to_buffer);
    133135    if (run_program_and_log_output(tmp, 2)) {
    134136        log_msg(2, "Warning - I think I failed to open tape, actually.");
    135137    }
     138    mr_free(tmp);
    136139    g_tape_buffer_size_MB = bufsize;
    137     tmp[30] = '\0';
    138     sprintf(command, "ps %s | grep buffer | grep -v grep", ps_options);
     140    mr_asprintf(&command, "ps %s | grep buffer | grep -v grep", ps_options);
    139141    if (run_program_and_log_output(command, 1)) {
    140142        fres = NULL;
     
    143145        log_to_screen("Buffer successfully started.");
    144146    }
     147    mr_free(command);
    145148
    146     paranoid_free(command);
    147     paranoid_free(tmp);
    148149    return (fres);
    149150}
Note: See TracChangeset for help on using the changeset viewer.