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

r3342@localhost: bruno | 2009-08-14 00:46:51 +0200

  • Another round of strcpy suppressions
  • find_home_of_exe() now allocates memory which has to be freed by the caller
  • Supress useless sz_last_suffix()
  • mr_getline now has the same interface as the other mr_mem functions
  • valgrind and compiler warnings fixes
File:
1 edited

Legend:

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

    r2325 r2331  
    256256
    257257    log_to_screen("I am looking for your tape streamer. Please wait.");
    258     if (find_home_of_exe("cdrecord")) {
    259         mr_asprintf(&cdr_exe, "cdrecord");
    260     } else {
    261         mr_asprintf(&cdr_exe, "dvdrecord");
    262     }
     258    tmp = find_home_of_exe("cdrecord");
     259    if (tmp) {
     260        mr_asprintf(cdr_exe, "cdrecord");
     261    } else {
     262        mr_asprintf(cdr_exe, "dvdrecord");
     263    }
     264    mr_free(tmp);
     265
    263266    mr_asprintf(command, "%s -scanbus 2> /dev/null | grep -i tape | wc -l", cdr_exe);
    264     mr_asprintf(&tmp, "%s", call_program_and_get_last_line_of_output(command));
     267    mr_asprintf(tmp, "%s", call_program_and_get_last_line_of_output(command));
    265268    mr_free(command);
    266269
     
    269272        mr_asprintf(&dev, "%s", VANILLA_SCSI_TAPE);
    270273        mr_free(tmp);
     274        mr_free(tmp);
    271275        return(dev);
    272276    }
     
    274278
    275279    mr_asprintf(command, "%s -scanbus 2> /dev/null | tr -s '\t' ' ' | grep \"[0-9]*,[0-9]*,[0-9]*\" | grep -v \"[0-9]*) \\*\" | grep -i TAPE | cut -d' ' -f2 | head -n1", cdr_exe);
    276     mr_asprintf(&tmp, "%s", call_program_and_get_last_line_of_output(command));
     280    mr_asprintf(tmp, "%s", call_program_and_get_last_line_of_output(command));
    277281    mr_free(command);
    278282
     
    280284        log_it("Could not find tape device");
    281285        mr_free(tmp);
    282         return(dev);
     286        return(NULL);
    283287    }
    284288    mr_free(tmp);
     289
    285290    mr_asprintf(command, "%s -scanbus 2> /dev/null | tr -s '\t' ' ' | grep \"[0-9]*,[0-9]*,[0-9]*\" | grep -v \"[0-9]*) \\*\" | grep -i TAPE | cut -d' ' -f3 | cut -d')' -f1 | head -n1", cdr_exe);
    286291    mr_free(cdr_exe);
    287292
    288     mr_asprintf(&tmp, "%s", call_program_and_get_last_line_of_output(command));
     293    mr_asprintf(tmp, "%s", call_program_and_get_last_line_of_output(command));
    289294    mr_free(command);
    290 
    291295
    292296    mr_asprintf(dev, "%s", "/dev/st");
    293297    mr_strcat(dev, tmp);            // e.g. '/dev/st0' becomes '/dev/stN'
    294298    mr_free(tmp);
     299
    295300    res = 0;
    296301    if (!mt_says_tape_exists(dev)) {
     
    321326    }
    322327
    323     mr_asprintf(&tmp, call_program_and_get_last_line_of_output("cdrecord -scanbus 2> /dev/null | tr -s '\t' ' ' | grep \"[0-9]*,[0-9]*,[0-9]*\" | grep -v \"[0-9]*) \\*\" | grep -i TAPE | awk '{for(i=1; i<NF; i++) { if (index($i, \"GB\")>0) { print $i;};};};'"));
     328    mr_asprintf(tmp, "%s", call_program_and_get_last_line_of_output(" cdrecord -scanbus 2> /dev/null | tr -s '\t' ' ' |  grep \"[0-9]*,[0-9]*,[0-9]*\" | grep -v \"[0-9]*) \\*\" | grep -i TAPE | awk '{for(i=1; i<NF; i++) { if (index($i, \"GB\")>0) { print $i;};};};'"));
    324329
    325330    if (mt_says_tape_exists(dev)) {
     
    328333        log_it("Turning %s", dev);
    329334        mr_free(tmp);
    330         mr_asprintf(&tmp, (strrchr(dev, '/') != NULL) ? strrchr(dev, '/') : dev);
     335        mr_asprintf(tmp, "%s", (strrchr(dev, '/') != NULL) ? strrchr(dev, '/') : dev);
    331336        mr_free(dev);
    332337        mr_asprintf(&dev, "/dev/os%s", tmp);
     
    342347    log_it("res=%d; dev=%s", res, dev);
    343348
    344     if (res) {
     349    if (dev) {
     350        log_it("At this new point, dev = %s and res = %d", dev, res);
     351    } else {
     352        log_it("At this new point, dev is NULL and res = %d", dev, res);
    345353        mr_free(tmp);
    346         return (dev);
     354        return(NULL);
    347355    }
    348356
     
    351359    }
    352360    mr_free(tmp);
    353     return (NULL);
     361    return(dev);
    354362}
    355363
Note: See TracChangeset for help on using the changeset viewer.