Ignore:
Timestamp:
Jun 29, 2009, 7:19:14 PM (15 years ago)
Author:
Bruno Cornec
Message:

r3144@localhost: bruno | 2009-06-26 12:18:08 +0200

  • Remove mr_string.c|.h useless and in de=uplication with mr_str.c|.h
  • Solve with valgrind's help some memroy leak (harmless mostly)
  • Solve a seg fault at end, when unallocating a bkpinfo member after the strcuture disallocation !
  • after mr_strtok, memory ssociated with the token needs to be free
  • Adds a new function free_newt_stuff to free newt related allocated memory
  • Do not exit if mr_free is unsuccessful, and only warn when debug > 8
File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/2.2.9/mondo/src/common/libmondo-devices.c

    r2226 r2241  
    24062406{
    24072407    /*@ buffer ***************************************************** */
    2408     char *list_drives_cmd;
     2408    char *list_drives_cmd = NULL;
    24092409    char *current_drive;
    24102410
     
    24182418    /*@ end vars *************************************************** */
    24192419
    2420     malloc_string(list_drives_cmd);
    24212420    malloc_string(current_drive);
    24222421
     
    24262425#endif
    24272426    assert(which_device != NULL);
    2428     //  sprintf (list_drives_cmd,
    2429     //       "fdisk -l | grep /dev | grep cyl | tr ':' ' ' | cut -d' ' -f2");
    2430 
    2431     sprintf(list_drives_cmd,
     2427
     2428    mr_asprintf(&list_drives_cmd,
    24322429            "parted2fdisk -l 2>/dev/null | grep \"/dev/.*:\" | tr -s ':' ' ' | tr -s ' ' '\n' | grep /dev/; echo %s",
    24332430            where_is_root_mounted());
     
    24362433    if (!(pdrives = popen(list_drives_cmd, "r"))) {
    24372434        log_OS_error("Unable to open list of drives");
    2438         paranoid_free(list_drives_cmd);
     2435        mr_free(list_drives_cmd);
    24392436        paranoid_free(current_drive);
    24402437        return ('\0');
    24412438    }
     2439    mr_free(list_drives_cmd);
     2440
    24422441    for ((void)fgets(current_drive, MAX_STR_LEN, pdrives); !feof(pdrives);
    24432442         (void)fgets(current_drive, MAX_STR_LEN, pdrives)) {
     
    24602459    log_it("%d grubs and %d lilos\n", count_grubs, count_lilos);
    24612460    if (count_grubs && !count_lilos) {
     2461        paranoid_free(current_drive);
    24622462        return ('G');
    24632463    } else if (count_lilos && !count_grubs) {
     2464        paranoid_free(current_drive);
    24642465        return ('L');
    24652466    } else if (count_grubs == 1 && count_lilos == 1) {
    24662467        log_it("I'll bet you used to use LILO but switched to GRUB...");
     2468        paranoid_free(current_drive);
    24672469        return ('G');
    24682470    } else {
    24692471        // We need to look on each partition then
    2470         sprintf(list_drives_cmd,
     2472        mr_asprintf(&list_drives_cmd,
    24712473            "parted2fdisk -l 2>/dev/null | grep -E \"^/dev/\" | tr -s ':' ' ' | tr -s ' ' '\n' | grep /dev/");
    24722474        log_it("list_drives_cmd = %s", list_drives_cmd);
     
    24742476        if (!(pdrives = popen(list_drives_cmd, "r"))) {
    24752477            log_OS_error("Unable to open list of drives");
    2476             paranoid_free(list_drives_cmd);
     2478            mr_free(list_drives_cmd);
    24772479            paranoid_free(current_drive);
    24782480            return ('\0');
    24792481        }
     2482        mr_free(list_drives_cmd);
     2483
    24802484        for ((void)fgets(current_drive, MAX_STR_LEN, pdrives); !feof(pdrives);
    24812485            (void)fgets(current_drive, MAX_STR_LEN, pdrives)) {
     
    24972501        }
    24982502        log_it("%d grubs and %d lilos\n", count_grubs, count_lilos);
    2499         paranoid_free(list_drives_cmd);
    25002503        paranoid_free(current_drive);
    25012504        if (count_grubs && !count_lilos) {
Note: See TracChangeset for help on using the changeset viewer.