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

r3327@localhost: bruno | 2009-08-04 00:17:46 +0200
popup_and_get_string and build_partition_name now return an allocated string

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/2.2.10/mondo/src/mondorestore/mondo-prep.c

    r2299 r2316  
    14571457
    14581458    /** buffers *********************************************************/
    1459     char *device_str;
     1459    char *device_str = NULL;
    14601460    char *format;
    14611461    char *tmp = NULL;
     
    14661466    assert_string_is_neither_NULL_nor_zerolength(drivename);
    14671467
    1468     malloc_string(device_str);
    14691468    malloc_string(format);
    14701469
     
    14831482    if (!pout_to_fdisk) {
    14841483        log_to_screen("Cannot call parted2fdisk to configure %s", drivename);
    1485         paranoid_free(device_str);
    14861484        paranoid_free(format);
    14871485        return (1);
     
    14891487#endif
    14901488    for (current_devno = 1; current_devno < 99; current_devno++) {
    1491         build_partition_name(device_str, drivename, current_devno);
     1489        device_str = build_partition_name(drivename, current_devno);
    14921490        lino = find_device_in_mountlist(mountlist, device_str);
    14931491
     
    15181516                    }
    15191517                    mr_free(command);
    1520                     paranoid_free(device_str);
     1518                    mr_free(device_str);
    15211519                    paranoid_free(format);
    15221520                    return r;
     
    15471545                }
    15481546            } else {
     1547                mr_free(device_str);
    15491548                continue;
    15501549            }
    15511550#else
     1551            mr_free(device_str);
    15521552            continue;
    15531553#endif
     
    16061606            log_to_screen
    16071607                ("You must leave at least one partition spare as the Extended partition.");
    1608             paranoid_free(device_str);
     1608            mr_free(device_str);
    16091609            paranoid_free(format);
    16101610            return (1);
     
    16271627        }
    16281628#endif
     1629        mr_free(device_str);
    16291630
    16301631        previous_devno = current_devno;
     
    16661667        }
    16671668    }
    1668     paranoid_free(device_str);
    16691669    paranoid_free(format);
    16701670    return (retval);
     
    16901690    /** buffers **********************************************************/
    16911691    char *program = NULL;
    1692     char *partition_name;
     1692    char *partition_name = NULL;
    16931693    char *tmp = NULL;
    16941694    char *output = NULL;
     
    17011701    /** end ***************************************************************/
    17021702
    1703     malloc_string(partition_name);
    1704 
    17051703    assert_string_is_neither_NULL_nor_zerolength(drive);
    17061704    assert(format != NULL);
     
    17141712        mr_free(tmp);
    17151713
    1716         paranoid_free(partition_name);
    17171714        return (0);
    17181715    }
    1719     build_partition_name(partition_name, drive, partno);
     1716    partition_name = build_partition_name(drive, partno);
    17201717    if (partsize <= 0) {
    17211718        mr_asprintf(&tmp, "Partitioning device %s (max size)", partition_name);
     
    17311728        log_to_screen(tmp);
    17321729        mr_free(tmp);
    1733         paranoid_free(partition_name);
     1730        mr_free(partition_name);
    17341731        return (1);
    17351732    }
     
    17491746            if (partno == 5) {
    17501747                if (prev_partno >= 4) {
    1751                     log_to_screen
    1752                         ("You need to leave at least one partition free, for 'extended/logical'");
    1753                     paranoid_free(partition_name);
     1748                    log_to_screen("You need to leave at least one partition free, for 'extended/logical'");
     1749                    mr_free(partition_name);
    17541750                    paranoid_free(output);
    17551751                    return (1);
     
    17761772    log_it(tmp);
    17771773    mr_free(tmp);
     1774
    17781775    log_it("---fdisk command---");
    17791776    log_it(output);
     
    18671864    }
    18681865    mr_free(program);
     1866    mr_free(partition_name);
    18691867    paranoid_free(output);
    18701868
    18711869    g_current_progress++;
    18721870    log_it("partition_device() --- leaving");
    1873     paranoid_free(partition_name);
    18741871    return (retval);
    18751872}
     
    19791976{
    19801977    /** buffers *********************************************************/
    1981     char *partition;
     1978    char *partition = NULL;
    19821979    char *command = NULL;
    19831980    char *output = NULL;
    19841981    char *tmp = NULL;
    1985     char *partcode;
     1982    char *partcode = NULL;
    19861983
    19871984    /** pointers *********************************************************/
     
    19971994    assert(format != NULL);
    19981995
    1999     malloc_string(partition);
    2000     malloc_string(partcode);
    2001 
    2002     build_partition_name(partition, drive, partno);
     1996    partition = build_partition_name(drive, partno);
    20031997    p = (char *) strrchr(partition, '/');
    20041998    if (strcmp(format, "swap") == 0) {
    2005         strcpy(partcode, "82");
     1999        mr_asprintf(&partcode, "82");
    20062000    } else if (strcmp(format, "vfat") == 0) {
    20072001        if (partsize / 1024 > 8192) {
    2008             strcpy(partcode, "c");
     2002            mr_asprintf(&partcode, "c");
    20092003        } else {
    2010             strcpy(partcode, "b");
     2004            mr_asprintf(&partcode, "b");
    20112005        }
    20122006    } else if (strcmp(format, "ext2") == 0
     
    20162010               || strcmp(format, "xfs") == 0
    20172011               || strcmp(format, "jfs") == 0) {
    2018         strcpy(partcode, "83");
     2012        mr_asprintf(&partcode, "83");
    20192013    } else if (strcmp(format, "minix") == 0) {
    2020         strcpy(partcode, "81");
     2014        mr_asprintf(&partcode, "81");
    20212015    } else if (strcmp(format, "vmfs3") == 0) {
    2022         strcpy(partcode, "fb");
     2016        mr_asprintf(&partcode, "fb");
    20232017    } else if (strcmp(format, "vmkcore") == 0) {
    2024         strcpy(partcode, "fc");
     2018        mr_asprintf(&partcode, "fc");
    20252019    } else if (strcmp(format, "raid") == 0) {
    2026         strcpy(partcode, "fd");
     2020        mr_asprintf(&partcode, "fd");
    20272021    } else if (strcmp(format, "ntfs") == 0) {
    2028         strcpy(partcode, "7");
     2022        mr_asprintf(&partcode, "7");
    20292023    } else if ((strcmp(format, "ufs") == 0)
    20302024               || (strcmp(format, "ffs") == 0)) {   /* raid autodetect */
    2031         strcpy(partcode, "a5");
     2025        mr_asprintf(&partcode, "a5");
    20322026    } else if (strcmp(format, "lvm") == 0) {
    2033         strcpy(partcode, "8e");
     2027        mr_asprintf(&partcode, "8e");
    20342028    } else if (format[0] == '\0') { /* LVM physical partition */
    2035         partcode[0] = '\0';
     2029        mr_asprintf(&partcode, "");
    20362030    } else if (strlen(format) >= 1 && strlen(format) <= 2) {
    2037         strcpy(partcode, format);
     2031        mr_asprintf(&partcode, format);
    20382032    } else {
    20392033        /* probably an image */
     
    20422036        mr_free(tmp);
    20432037#ifdef __FreeBSD__
    2044         strcpy(partcode, format);   // was a5
     2038        mr_asprintf(&partcode, format); // was a5
    20452039#else
    2046         strcpy(partcode, format);   // was 83
     2040        mr_asprintf(&partcode, format); // was 83
    20472041#endif
    20482042    }
    20492043    log_msg(1, tmp, "Setting %s's type to %s (%s)", partition, format, partcode);
    2050     if (partcode[0] != '\0' && strcmp(partcode, "83")) {    /* no need to set type if 83: 83 is default */
     2044    mr_free(partition);
     2045
     2046    if (partcode != NULL && strcmp(partcode, "83")) {   /* no need to set type if 83: 83 is default */
    20512047
    20522048        if (pout_to_fdisk) {
     
    21042100    }
    21052101
    2106     paranoid_free(partition);
    2107     paranoid_free(partcode);
    2108 
     2102    mr_free(partcode);
    21092103    return (res);
    21102104}
Note: See TracChangeset for help on using the changeset viewer.