Ignore:
Timestamp:
Aug 18, 2009, 5:28:18 PM (15 years ago)
Author:
Bruno Cornec
Message:

r3369@localhost: bruno | 2009-08-18 16:57:27 +0200

  • Transform bout 100 strcpy in dyn. allocation. Quality is improving
  • function figure_out_kernel_path_interactively_if_necessary now return a dynamically allocated string
  • mondoarchive checked with valgrind in text an newt modes
File:
1 edited

Legend:

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

    r2332 r2334  
    7878    newtPushHelpLine
    7979        ("   Add one of the following unallocated RAID partitions to this RAID device.");
    80     mr_asprintf(&tmp, "%-26s %s", "Device", "Size");
     80    mr_asprintf(tmp, "%-26s %s", "Device", "Size");
    8181    headerMsg = newtLabel(1, 1, tmp);
    8282    partitionsListbox =
     
    104104
    105105            items = disklist->entries;
    106             strcpy(disklist->el[items].device,
    107                    unallocated_raid_partitions->el[currline].device);
     106            strcpy(disklist->el[items].device, unallocated_raid_partitions->el[currline].device);
    108107            disklist->el[items].index = index;
    109108            disklist->entries = ++items;
     
    154153
    155154    /** buffers **********************************************************/
    156     char drive_to_add[MAX_STR_LEN];
    157     char mountpoint_str[MAX_STR_LEN];
    158     char size_str[MAX_STR_LEN];
    159     char device_str[MAX_STR_LEN];
    160     char format_str[MAX_STR_LEN];
     155    char *drive_to_add = NULL;
     156    char *mountpoint_str = NULL;
     157    char *size_str = NULL;
     158    char *device_str = NULL;
     159    char *format_str = NULL;
    161160
    162161    /** pointers *********************************************************/
     
    171170    assert(keylist != NULL);
    172171
    173     strcpy(device_str, "/dev/");
    174     strcpy(mountpoint_str, "/");
     172    mr_asprintf(device_str, "/dev/");
     173    mr_asprintf(mountpoint_str, "/");
     174    mr_asprintf(size_str, "");
    175175#ifdef __FreeBSD__
    176     strcpy(format_str, "ufs");
     176    mr_asprintf(format_str, "ufs");
    177177#else
    178     strcpy(format_str, "ext3");
     178    mr_asprintf(format_str, "ext3");
    179179#endif
    180     size_str[0] = '\0';
    181180    newtOpenWindow(20, 5, 48, 10, "Add entry");
    182181    label0 = newtLabel(2, 1, "Device:    ");
     
    184183    label2 = newtLabel(2, 3, "Size (MB): ");
    185184    label3 = newtLabel(2, 4, "Format:    ");
    186     deviceComp =
    187         newtEntry(14, 1, device_str, 30, (void *) &device_here, 0);
    188     mountpointComp =
    189         newtEntry(14, 2, mountpoint_str, 30, (void *) &mountpoint_here, 0);
    190     formatComp =
    191         newtEntry(14, 4, format_str, 15, (void *) &format_here, 0);
     185    deviceComp = newtEntry(14, 1, device_str, 30, (void *) &device_here, 0);
     186    mountpointComp = newtEntry(14, 2, mountpoint_str, 30, (void *) &mountpoint_here, 0);
     187    formatComp = newtEntry(14, 4, format_str, 15, (void *) &format_here, 0);
    192188    sizeComp = newtEntry(14, 3, size_str, 10, (void *) &size_here, 0);
    193189    bOK = newtButton(5, 6, "  OK  ");
     
    201197    for (b_res = NULL; b_res != bOK && b_res != bCancel;) {
    202198        b_res = newtRunForm(myForm);
    203         strcpy(device_str, device_here);
    204         strcpy(mountpoint_str, mountpoint_here);
    205         strcpy(format_str, format_here);
    206         strcpy(size_str, size_here);
    207 //      log_it ("Originals = %s,%s,%s,%s", device_str, mountpoint_str, format_str, size_str);
     199        mr_free(device_str);
     200        mr_asprintf(device_str, "%s", device_here);
     201
     202        mr_free(mountpoint_str);
     203        mr_asprintf(mountpoint_str, "%s", mountpoint_here);
     204        mr_strip_spaces(mountpoint_str);
     205
     206        mr_free(format_str);
     207        mr_asprintf(format_str, "%s", format_here);
     208        mr_strip_spaces(format_str);
     209
     210        mr_free(size_str);
     211        mr_asprintf(size_str, "%s", size_here);
     212        mr_strip_spaces(size_str);
     213
    208214        strip_spaces(device_str);
    209         strip_spaces(mountpoint_str);
    210         strip_spaces(format_str);
    211         strip_spaces(size_str);
    212 //      log_it ("Modified = %s,%s,%s,%s", device_str, mountpoint_str, format_str, size_str);
    213215        if (b_res == bOK) {
    214216            if (device_str[strlen(device_str) - 1] == '/') {
     
    216218                b_res = NULL;
    217219            }
    218             if (size_of_specific_device_in_mountlist(mountlist, device_str)
    219                 >= 0) {
     220            if (size_of_specific_device_in_mountlist(mountlist, device_str) >= 0) {
    220221                popup_and_OK("Can't add this - you've got one already!");
    221222                b_res = NULL;
     
    229230        return;
    230231    }
    231     strcpy(drive_to_add, device_str);
     232    mr_asprintf(drive_to_add, "%s", device_str);
    232233    for (i = strlen(drive_to_add); isdigit(drive_to_add[i - 1]); i--);
    233234    num_to_add = atoi(drive_to_add + i);
    234     drive_to_add[i] = '\0';
     235    mr_free(drive_to_add);
     236
    235237    currline = mountlist->entries;
    236238    strcpy(mountlist->el[currline].device, device_str);
    237239    strcpy(mountlist->el[currline].mountpoint, mountpoint_str);
     240    mr_free(mountpoint_str);
     241
    238242    strcpy(mountlist->el[currline].format, format_str);
     243    mr_free(format_str);
     244
    239245    mountlist->el[currline].size = atol(size_str) * 1024L;
     246    mr_free(size_str);
     247
    240248    mountlist->entries++;
    241249    if (strstr(mountlist->el[currline].device, RAID_DEVICE_STUB)) {
    242         initiate_new_raidlist_entry(raidlist, mountlist, currline,
    243                                     device_str);
    244     }
     250        initiate_new_raidlist_entry(raidlist, mountlist, currline, device_str);
     251    }
     252    mr_free(device_str);
     253
    245254    redraw_mountlist(mountlist, keylist, listbox);
    246255}
     
    316325    /** buffers ***********************************************************/
    317326    char tmp = NULL;
    318 
    319 
    320 
     327    char *devname = NULL;
    321328
    322329    for (i = 0;
     
    324331         && strcmp(raidlist->el[i].volname, basename(raid_device)); i++);
    325332    if (i == raidlist->entries) {
    326         mr_asprintf(&tmp, "Cannot calc size of raid device %s - cannot find it in raidlist", raid_device);
    327         log_it(tmp);
    328         mr_free(tmp);
     333        log_it("Cannot calc size of raid device %s - cannot find it in raidlist", raid_device);
    329334        return (0);             // Isn't this more sensible than 999999999? If the raid dev !exists,
    330335        // then it has no size, right?
     
    338343        int k = 0, l = 0;
    339344        for (k = 0; k < raidrec->plex[j].subdisks; ++k) {
    340             char devname[64];
    341             strcpy(devname, raidrec->plex[j].sd[k].which_device);
     345            mr_asprintf(devname, "%s", raidrec->plex[j].sd[k].which_device);
    342346            for (l = 0; l < raidlist->disks.entries; ++l) {
    343347                if (!strcmp(devname, raidlist->disks.el[l].name)) {
     
    367371                }
    368372            }
     373            mr_free(devname);
    369374        }
    370375
     
    387392    }
    388393
    389     mr_asprintf(&tmp, "I have calculated %s's real size to be %ld", raid_device, (long) smallest_plex);
    390     log_it(tmp);
    391     mr_free(tmp);
     394    log_it("I have calculated %s's real size to be %ld", raid_device, (long) smallest_plex);
    392395    return (smallest_plex);
    393396#else
     
    406409    long sp = 0;
    407410
    408     /** buffers ***********************************************************/
    409     char tmp = NULL;
    410 
    411411    assert(mountlist != NULL);
    412412    assert(raidlist != NULL);
     
    417417         && strcmp(raidlist->el[i].raid_device, raid_device); i++);
    418418    if (i == raidlist->entries) {
    419         mr_asprintf(&tmp, "Cannot calc size of raid device %s - cannot find it in raidlist", raid_device);
    420         log_it(tmp);
    421         mr_free(tmp);
     419        log_it("Cannot calc size of raid device %s - cannot find it in raidlist", raid_device);
    422420        return (999999999);
    423421    }
     
    442440        total_size = smallest_partition * (noof_partitions - 1);
    443441    }
    444     mr_asprintf(&tmp, "I have calculated %s's real size to be %ld", raid_device, (long) total_size);
    445     log_it(tmp);
    446     mr_free(tmp);
     442    log_it("I have calculated %s's real size to be %ld", raid_device, (long) total_size);
    447443    return (total_size);
    448444#endif
     
    499495            }
    500496            p[i] = '\0';
    501             mr_free(sz);
    502497        }
    503498        if (!strcmp(p, "concat")) {
     
    568563            }
    569564            p[i] = '\0';
    570             mr_free(sz);
    571565        }
    572566        if (!strcmp(p, "linear")) {
     
    613607
    614608    /** buffers ***********************************************************/
    615     char *tmp = NULL;
    616 
    617609    assert(mountlist != NULL);
    618610    assert(raidlist != NULL);
     
    625617             pos++);
    626618        if (pos < mountlist->entries) {
    627             mr_asprintf(&tmp, "Deleting partition %s cos it was part of a now-defunct RAID", mountlist->el[pos].device);
    628             log_it(tmp);
    629             mr_free(tmp);
     619            log_it("Deleting partition %s cos it was part of a now-defunct RAID", mountlist->el[pos].device);
    630620
    631621            memcpy((void *) &mountlist->el[pos],
     
    662652    assert_string_is_neither_NULL_nor_zerolength(raid_device);
    663653
    664     mr_asprintf(&tmp, "Delete %s from RAID device %s - are you sure?", disklist->el[currline].device, raid_device);
     654    mr_asprintf(tmp, "Delete %s from RAID device %s - are you sure?", disklist->el[currline].device, raid_device);
    665655    res = ask_me_yes_or_no(tmp);
    666656    mr_free(tmp);
     
    699689    /** buffers ***********************************************************/
    700690    char *tmp = NULL;
    701     char device[MAX_STR_LEN];
     691    char *device = NULL;
    702692
    703693
     
    707697    assert(keylist != NULL);
    708698
    709     /* BERLIOS: Why isn't device initialized here ? what is expected */
    710     pos =
    711         which_raid_device_is_using_this_partition(raidlist,
    712                                                   mountlist->el[currline].
    713                                                   device);
     699    pos = which_raid_device_is_using_this_partition(raidlist, mountlist->el[currline].device);
    714700    if (pos >= 0) {
    715         mr_asprintf(&tmp, "Cannot delete %s: it is in use by RAID device %s", mountlist->el[currline].device, raidlist->el[pos].OSSWAP(raid_device, volname));
     701        mr_asprintf(tmp, "Cannot delete %s: it is in use by RAID device %s", mountlist->el[currline].device, raidlist->el[pos].OSSWAP(raid_device, volname));
    716702        popup_and_OK(tmp);
    717703        mr_free(tmp);
    718704        return;
    719705    }
    720     mr_asprintf(&tmp, "Delete %s - are you sure?", mountlist->el[currline].device);
     706    mr_asprintf(tmp, "Delete %s - are you sure?", mountlist->el[currline].device);
    721707    res = ask_me_yes_or_no(tmp);
    722708    mr_free(tmp);
     
    726712    }
    727713    if (strstr(mountlist->el[currline].device, RAID_DEVICE_STUB)) {
    728         strcpy(device, mountlist->el[currline].device);
     714        mr_asprintf(device, "%s", mountlist->el[currline].device);
    729715        delete_raidlist_entry(mountlist, raidlist, device);
    730716        for (currline = 0;
     
    732718             && strcmp(mountlist->el[currline].device, device);
    733719             currline++);
     720        mr_free(device);
     721
    734722        if (currline == mountlist->entries) {
    735723            log_it("Dev is gone. I can't delete it. Ho-hum");
     
    775763        return;
    776764    }
    777     mr_asprintf(&tmp, "Do you want me to delete %s's partitions, too?", device);
     765    mr_asprintf(tmp, "Do you want me to delete %s's partitions, too?", device);
    778766    delete_partitions_too = ask_me_yes_or_no(tmp);
    779767    if (delete_partitions_too) {
     
    788776                    if (!strcmp(raidlist->el[i].plex[x].sd[y].which_device,
    789777                                raidlist->disks.el[z].name)) {
    790                         strcpy(d.el[d.entries].name,
    791                                raidlist->disks.el[z].name);
    792                         strcpy(d.el[d.entries++].device,
    793                                raidlist->disks.el[z].device);
     778                        strcpy(d.el[d.entries].name, raidlist->disks.el[z].name);
     779                        strcpy(d.el[d.entries++].device, raidlist->disks.el[z].device);
    794780                    }
    795781                }
     
    844830
    845831    av = &raidrec->additional_vars;
    846     mr_asprintf(&tmp, "Delete %s - are you sure?", av->el[lino].label);
     832    mr_asprintf(tmp, "Delete %s - are you sure?", av->el[lino].label);
    847833    res = ask_me_yes_or_no(tmp);
    848834    mr_free(tmp);
     
    851837        if (!strcmp(av->el[lino].label, "persistent-superblock")
    852838            || !strcmp(av->el[lino].label, "chunk-size")) {
    853             mr_asprintf(&tmp, "%s must not be deleted. It would be bad.", av->el[lino].label);
     839            mr_asprintf(tmp, "%s must not be deleted. It would be bad.", av->el[lino].label);
    854840            popup_and_OK(tmp);
    855841            mr_free(tmp);
     
    920906                if (!warned_already) {
    921907                    warned_already = TRUE;
    922                     mr_asprintf(&tmp1, "Too many lines. Displaying first %d entries only. Close a directory to see more.", ARBITRARY_MAXIMUM);
     908                    mr_asprintf(tmp1, "Too many lines. Displaying first %d entries only. Close a directory to see more.", ARBITRARY_MAXIMUM);
    923909                    popup_and_OK(tmp1);
    924910                    mr_free(tmp1);
    925911                }
    926912            } else {
    927                 strcpy(g_strings_of_flist_window[lines_in_flist_window],
    928                        current_filename);
     913                strcpy(g_strings_of_flist_window[lines_in_flist_window], current_filename);
    929914                g_is_path_selected[lines_in_flist_window] = node->selected;
    930915                lines_in_flist_window++;
     
    941926                (g_strings_of_flist_window[i],
    942927                 g_strings_of_flist_window[i - 1]) < 0) {
    943                 mr_asprintf(&tmp1, g_strings_of_flist_window[i]);
    944                 strcpy(g_strings_of_flist_window[i],
    945                        g_strings_of_flist_window[i - 1]);
     928                mr_asprintf(tmp1, "%s", g_strings_of_flist_window[i]);
     929                strcpy(g_strings_of_flist_window[i], g_strings_of_flist_window[i - 1]);
    946930                strcpy(g_strings_of_flist_window[i - 1], tmp1);
    947931                mr_free(tmp1);
     
    10481032    void *curr_choice;
    10491033    void *keylist[ARBITRARY_MAXIMUM];
    1050 
    1051     /** buffers ***********************************************************/
    1052     char *tmp = NULL;
    10531034
    10541035    /** bool **************************************************************/
     
    10981079                indexno = 0;
    10991080            }
    1100             mr_asprintf(&tmp, "You selected '%s'", g_strings_of_flist_window[indexno]);
    1101             log_it(tmp);
    1102             mr_free(tmp);
     1081            log_it("You selected '%s'", g_strings_of_flist_window[indexno]);
    11031082
    11041083            if (b_res == bMore) {
     
    11931172
    11941173  /** buffers ***********************************************************/
    1195     char device_str[MAX_STR_LEN];
    1196     char mountpoint_str[MAX_STR_LEN];
    1197     char size_str[MAX_STR_LEN];
    1198     char format_str[MAX_STR_LEN];
     1174    char *device_str = NULL;
     1175    char *mountpoint_str = NULL;
     1176    char *size_str = NULL;
     1177    char *format_str = NULL;
    11991178    char *tmp = NULL;
    1200     char device_used_to_be[MAX_STR_LEN];
    1201     char mountpt_used_to_be[MAX_STR_LEN];
     1179    char *device_used_to_be = NULL;
     1180    char *mountpt_used_to_be = NULL;
    12021181
    12031182    /** pointers **********************************************************/
     
    12171196    memcpy((void *) &bkp_raidlist, (void *) raidlist,
    12181197           sizeof(struct raidlist_itself));
    1219     strcpy(device_str, mountlist->el[currline].device);
    1220     strcpy(device_used_to_be, mountlist->el[currline].device);
    1221     strcpy(mountpoint_str, mountlist->el[currline].mountpoint);
    1222     strcpy(mountpt_used_to_be, mountlist->el[currline].mountpoint);
    1223     strcpy(format_str, mountlist->el[currline].format);
    1224     sprintf(size_str, "%lld", mountlist->el[currline].size / 1024L);
     1198    mr_asprintf(device_str, "%s", mountlist->el[currline].device);
     1199    mr_asprintf(device_used_to_be, "%s", mountlist->el[currline].device);
     1200    mr_asprintf(mountpoint_str, "%s", mountlist->el[currline].mountpoint);
     1201    mr_asprintf(mountpt_used_to_be, "%s", mountlist->el[currline].mountpoint);
     1202    mr_asprintf(format_str, "%s", mountlist->el[currline].format);
     1203    mr_asprintf(size_str, "%lld", mountlist->el[currline].size / 1024L);
    12251204    newtOpenWindow(20, 5, 48, 10, "Edit entry");
    12261205    label0 = newtLabel(2, 1, "Device:");
     
    12281207    label2 = newtLabel(2, 3, "Size (MB): ");
    12291208    label3 = newtLabel(2, 4, "Format:    ");
    1230     deviceComp =
    1231         newtEntry(14, 1, device_str, 30, (void *) &device_here, 0);
    1232     mountpointComp =
    1233         newtEntry(14, 2, mountpoint_str, 30, (void *) &mountpoint_here, 0);
    1234     formatComp =
    1235         newtEntry(14, 4, format_str, 15, (void *) &format_here, 0);
     1209    deviceComp = newtEntry(14, 1, device_str, 30, (void *) &device_here, 0);
     1210    mountpointComp = newtEntry(14, 2, mountpoint_str, 30, (void *) &mountpoint_here, 0);
     1211    formatComp = newtEntry(14, 4, format_str, 15, (void *) &format_here, 0);
    12361212    if (strstr(mountlist->el[currline].device, RAID_DEVICE_STUB)
    12371213        || !strcmp(mountlist->el[currline].mountpoint, "image")) {
     
    12531229    for (b_res = NULL; b_res != bOK && b_res != bCancel;) {
    12541230        b_res = newtRunForm(myForm);
    1255         strcpy(device_str, device_here);
    1256         strip_spaces(device_str);
    1257         strcpy(mountpoint_str, mountpoint_here);
    1258         strip_spaces(mountpoint_str);
    1259         strcpy(format_str, format_here);
    1260         strip_spaces(format_str);
     1231        mr_free(device_str);
     1232        mr_asprintf(device_str, "%s", device_here);
     1233        mr_strip_spaces(device_str);
     1234
     1235        mr_free(mountpoint_str);
     1236        mr_asprintf(mountpoint_str, "%s", mountpoint_here);
     1237        mr_strip_spaces(mountpoint_str);
     1238
     1239        mr_free(format_str);
     1240        mr_asprintf(format_str, "%s", format_here);
     1241        mr_strip_spaces(format_str);
     1242
    12611243        if (b_res == bOK && strstr(device_str, RAID_DEVICE_STUB)
    12621244            && strstr(device_used_to_be, RAID_DEVICE_STUB)
     
    12731255        if (!strstr(mountlist->el[currline].device, RAID_DEVICE_STUB)
    12741256            && strcmp(mountlist->el[currline].mountpoint, "image")) {
    1275             strcpy(size_str, size_here);
    1276             strip_spaces(size_str);
     1257            mr_free(size_str);
     1258            mr_asprintf(size_str, "%s", size_here);
     1259            mr_strip_spaces(size_str);
    12771260        } else {
    1278             sprintf(size_str, "%ld",
    1279                     calculate_raid_device_size(mountlist, raidlist,
    1280                                                mountlist->el[currline].
    1281                                                device) / 1024);
     1261            mr_asprintf(size_str, "%ld", calculate_raid_device_size(mountlist, raidlist, mountlist->el[currline].device) / 1024);
    12821262            newtLabelSetText(sizeComp, size_str);
    12831263        }
     
    12961276                                                 device);
    12971277                if (j < 0) {
    1298                     mr_asprintf(&tmp, "/etc/raidtab does not have an entry for %s; please delete it and add it again", mountlist->el[currline].device);
     1278                    mr_asprintf(tmp, "/etc/raidtab does not have an entry for %s; please delete it and add it again", mountlist->el[currline].device);
    12991279                    popup_and_OK(tmp);
    13001280                    mr_free(tmp);
     
    13101290    newtPopHelpLine();
    13111291    newtPopWindow();
     1292    mr_free(mountpt_used_to_be);
     1293
    13121294    if (b_res == bCancel) {
    13131295        memcpy((void *) raidlist, (void *) &bkp_raidlist,
    13141296               sizeof(struct raidlist_itself));
     1297        mr_free(device_str);
     1298        mr_free(device_used_to_be);
     1299        mr_free(format_str);
     1300        mr_free(size_str);
    13151301        return;
    13161302    }
    13171303    strcpy(mountlist->el[currline].device, device_str);
    13181304    strcpy(mountlist->el[currline].mountpoint, mountpoint_str);
     1305    mr_free(mountpoint_str);
     1306
    13191307    strcpy(mountlist->el[currline].format, format_str);
     1308    mr_free(format_str);
     1309
    13201310    if (strcmp(mountlist->el[currline].mountpoint, "image")) {
    13211311        if (strstr(mountlist->el[currline].device, RAID_DEVICE_STUB)) {
     
    13271317        }
    13281318    }
     1319    mr_free(size_str);
    13291320    newtListboxSetEntry(listbox, (long) keylist[currline],
    13301321                        mountlist_entry_to_string(mountlist, currline));
     
    13321323    if (strstr(mountlist->el[currline].device, RAID_DEVICE_STUB)
    13331324        && !strstr(device_used_to_be, RAID_DEVICE_STUB)) {
    1334         initiate_new_raidlist_entry(raidlist, mountlist, currline,
    1335                                     device_str);
     1325        initiate_new_raidlist_entry(raidlist, mountlist, currline, device_str);
    13361326    }
    13371327    /* if moving from RAID to non-RAID then do funky stuff */
     
    13501340#ifndef __FreeBSD__             /* It works fine under FBSD. */
    13511341    else if (strcmp(device_used_to_be, device_str)) {
    1352         popup_and_OK
    1353             ("You are renaming a RAID device as another RAID device. I don't like it but I'll allow it.");
     1342        popup_and_OK("You are renaming a RAID device as another RAID device. I don't like it but I'll allow it.");
    13541343    }
    13551344#endif
     1345    mr_free(device_str);
     1346    mr_free(device_used_to_be);
     1347
    13561348    redraw_mountlist(mountlist, keylist, listbox);
    13571349}
     
    13761368    for (i = 0; i < raidlist->disks.entries; ++i) {
    13771369        if (!strcmp(raidlist->disks.el[i].device, temp)) {
    1378             strcpy(raidrec->sd[raidrec->subdisks].which_device,
    1379                    raidlist->disks.el[i].name);
     1370            strcpy(raidrec->sd[raidrec->subdisks].which_device, raidlist->disks.el[i].name);
    13801371            found = TRUE;
    13811372        }
     
    14941485                switch (raidrec->plex[i].raidlevel) {
    14951486                case -1:
    1496                     mr_asprintf(&raidlevel, "concat");
     1487                    mr_asprintf(raidlevel, "concat");
    14971488                    break;
    14981489                case 0:
    1499                     mr_asprintf(&raidlevel, "striped");
     1490                    mr_asprintf(raidlevel, "striped");
    15001491                    break;
    15011492                case 5:
    1502                     mr_asprintf(&raidlevel, "raid5");
     1493                    mr_asprintf(raidlevel, "raid5");
    15031494                    break;
    15041495                default:
    1505                     mr_asprintf(&raidlevel, "raid%i", raidrec->plex[i].raidlevel);
     1496                    mr_asprintf(raidlevel, "raid%i", raidrec->plex[i].raidlevel);
    15061497                    break;
    15071498                }
    15081499
    15091500                if (raidrec->plex[i].raidlevel == -1) {
    1510                     mr_asprintf(&chunksize, "N/A");
     1501                    mr_asprintf(chunksize, "N/A");
    15111502                } else {
    1512                     mr_asprintf(&chunksize, "%dk", raidrec->plex[i].stripesize);
     1503                    mr_asprintf(chunksize, "%dk", raidrec->plex[i].stripesize);
    15131504                }
    15141505                snprintf(pname, 64, "%s.p%i", raidrec->volname, i);
     
    15401531
    15411532        if (b_res == bDelete) {
    1542             mr_asprintf(&msg, "Are you sure you want to delete %s.p%i?", raidrec->volname, currline2);
     1533            mr_asprintf(msg, "Are you sure you want to delete %s.p%i?", raidrec->volname, currline2);
    15431534            res = ask_me_yes_or_no(msg);
    15441535            mr_free(msg);
     
    15781569    /** buffers ***********************************************************/
    15791570    char *title_of_editraidForm_window;
    1580     char *sz_raid_level;
     1571    char *sz_raid_level = NULL;
    15811572    char *sz_data_disks = NULL;
    15821573    char *sz_spare_disks = NULL;
     
    16001591    assert(raidrec != NULL);
    16011592
    1602     malloc_string(title_of_editraidForm_window);
    1603     malloc_string(sz_raid_level);
    1604 
    16051593    bkp_raidrec = mr_malloc(sizeof(struct raid_device_record));
    16061594    log_it("Started edit_raidlist_entry");
    16071595
    16081596    memcpy((void *) bkp_raidrec, (void *) raidrec, sizeof(struct raid_device_record));
    1609     sprintf(title_of_editraidForm_window, "%s", raidrec->raid_device);
     1597    mr_asprintf(title_of_editraidForm_window, "%s", raidrec->raid_device);
    16101598    log_msg(2, "Opening newt window");
    16111599    newtOpenWindow(20, 5, 40, 14, title_of_editraidForm_window);
    16121600    for (;;) {
    16131601        log_msg(2, "Main loop");
    1614         sprintf(title_of_editraidForm_window, "Edit %s",
    1615                 raidrec->raid_device);
    1616         strcpy(sz_raid_level,
    1617                turn_raid_level_number_to_string(raidrec->raid_level));
     1602        mr_free(title_of_editraidForm_window);
     1603        mr_asprintf(title_of_editraidForm_window, "Edit %s", raidrec->raid_device);
     1604        mr_asprintf(sz_raid_level, "%s", turn_raid_level_number_to_string(raidrec->raid_level));
    16181605        /* Those 4 strings are allocated by the function  */
    16191606        sz_data_disks = number_of_disks_as_string(raidrec->data_disks.entries, "data");
     
    16661653    newtPopWindow();
    16671654    mountlist->el[currline].size = calculate_raid_device_size(mountlist, raidlist, raidrec->raid_device);
    1668     paranoid_free(title_of_editraidForm_window);
    1669     paranoid_free(sz_raid_level);
     1655    mr_free(title_of_editraidForm_window);
     1656    mr_free(sz_raid_level);
    16701657    paranoid_free(bkp_raidrec);
    16711658#endif
     
    17151702
    17161703    char *p = NULL;
     1704    char *tmp = NULL;
     1705    char *entry = NULL;
    17171706
    17181707    struct mountlist_itself *unallocparts;
     
    17301719    for (;;) {
    17311720        int i;
    1732         char headerstr[MAX_STR_LEN];
    1733         char tmp[64];
    1734         snprintf(headerstr, MAX_STR_LEN, "%-24s %s", "Subdisk", "Device");
    1735 
    17361721
    17371722        switch (raidrec->raidlevel) {
    17381723        case -1:
    1739             strcpy(tmp, "concat");
     1724            mr_asprintf(tmp, "concat");
    17401725            break;
    17411726        case 0:
    1742             strcpy(tmp, "striped");
     1727            mr_asprintf(tmp, "striped");
    17431728            break;
    17441729        case 5:
    1745             strcpy(tmp, "raid5");
     1730            mr_asprintf(tmp, "raid5");
    17461731            break;
    17471732        default:
    1748             sprintf(tmp, "unknown (%i)", raidrec->raidlevel);
     1733            mr_asprintf(tmp, "unknown (%i)", raidrec->raidlevel);
    17491734            break;
    17501735        }
    17511736        bLevel = newtCompactButton(2, 2, " RAID level ");
    17521737        sLevel = newtLabel(19, 2, tmp);
     1738        mr_free(tmp);
    17531739
    17541740        if (raidrec->raidlevel >= 0) {
    1755             sprintf(tmp, "%ik", raidrec->stripesize);
     1741            mr_asprintf(tmp, "%ik", raidrec->stripesize);
    17561742            bStripeSize = newtCompactButton(2, 4, " Stripe size ");
    17571743        } else {
    1758             strcpy(tmp, "N/A");
     1744            mr_asprintf(tmp, "N/A");
    17591745            bStripeSize = newtLabel(2, 4, "Stripe size:");
    17601746        }
    17611747        sStripeSize = newtLabel(19, 4, tmp);
     1748        mr_free(tmp);
    17621749
    17631750        bOK = newtCompactButton(2, 16, "  OK  ");
     
    17681755
    17691756
    1770         //  plexesListbox = newtListbox (2, 7, 9, NEWT_FLAG_SCROLL | NEWT_FLAG_RETURNEXIT);
    1771         //  plexesHeader  = newtLabel (2, 6, headerstr);
    17721757        unallocListbox =
    17731758            newtListbox(2, 7, 7, NEWT_FLAG_SCROLL | NEWT_FLAG_RETURNEXIT);
     
    17851770                                                 raidlist);
    17861771        for (i = 0; i < ARBITRARY_MAXIMUM; ++i) {
    1787             char entry[MAX_STR_LEN];
    17881772            keylist[i] = (void *) i;
    17891773            if (i < raidrec->subdisks) {
    1790                 snprintf(entry, MAX_STR_LEN, "%-17s",
    1791                          find_dev_entry_for_raid_device_name(raidlist,
    1792                                                              raidrec->
    1793                                                              sd[i].
    1794                                                              which_device));
     1774                mr_asprintf(entry, "%-17s", find_dev_entry_for_raid_device_name(raidlist, raidrec->sd[i].which_device));
    17951775                newtListboxAppendEntry(allocListbox, entry, keylist[i]);
     1776                mr_free(entry);
    17961777            }
    17971778            if (i < unallocparts->entries) {
    1798                 snprintf(entry, MAX_STR_LEN, "%-17s",
    1799                          unallocparts->el[i].device);
     1779                mr_asprintf(entry, "%-17s", unallocparts->el[i].device);
    18001780                newtListboxAppendEntry(unallocListbox, entry, keylist[i]);
     1781                mr_free(entry);
    18011782            }
    18021783        }
     
    18481829            choose_raid_level(raidrec);
    18491830        } else if (b_res == bStripeSize) {
    1850             char *tmp = NULL;
    1851 
    18521831            mr_asprintf(tmp, "%i", raidrec->stripesize);
    18531832            p = popup_and_get_string("Stripe size", "Please enter the stripe size in kilobytes.", tmp);
     
    19731952    bCancel = newtCompactButton(i += 12, 17, "Cancel");
    19741953    bOK = newtCompactButton(i += 12, 17, "  OK  ");
    1975     mr_asprintf(&tmp, "%-24s %-24s %-8s  %s", "Device", "Mountpoint", "Format", "Size (MB)");
     1954    mr_asprintf(tmp, "%-24s %-24s %-8s  %s", "Device", "Mountpoint", "Format", "Size (MB)");
    19761955    headerMsg = newtLabel(2, 1, tmp);
    19771956    flawsLabelA = newtLabel(2, 13, flaws_str_A);
     
    22382217#ifdef __FreeBSD__
    22392218    for (i = 0; i < raidlist->entries; i++) {
    2240         mr_asprintf(&vdev, "/dev/vinum/%s", raidlist->el[i].volname);
     2219        mr_asprintf(vdev, "/dev/vinum/%s", raidlist->el[i].volname);
    22412220        res = strcmp(device, vdev);
    22422221        mr_free(vdev);
     
    23652344    raidrec = &raidlist->el[pos_in_raidlist];
    23662345    initialize_raidrec(raidrec);
    2367     strcpy(raidrec->OSSWAP(raid_device, volname),
    2368            OSSWAP(device, basename(device)));
     2346    strcpy(raidrec->OSSWAP(raid_device, volname), OSSWAP(device, basename(device)));
    23692347#ifndef __FreeBSD__
    23702348    choose_raid_level(raidrec);
     
    26182596                                                   char *new_dev)
    26192597{
    2620     /** buffers ********************************************************/
    2621     char *tmp = NULL;
    2622 
    26232598    /** int ************************************************************/
    26242599    int pos = 0;
     
    26312606    pos = which_raid_device_is_using_this_partition(raidlist, old_dev);
    26322607    if (pos < 0) {
    2633         mr_asprintf(&tmp, "No need to rejig %s in raidlist: it's not listed.", old_dev);
    2634         log_it(tmp);
    2635         mr_free(tmp);
     2608        log_it("No need to rejig %s in raidlist: it's not listed.", old_dev);
    26362609    } else {
    26372610        if ((j =
     
    26392612                                         OSSWAP(el[pos].data_disks, disks),
    26402613                                         old_dev)) >= 0) {
    2641             strcpy(raidlist->OSSWAP(el[pos].data_disks, disks).el[j].
    2642                    device, new_dev);
     2614            strcpy(raidlist->OSSWAP(el[pos].data_disks, disks).el[j].device, new_dev);
    26432615        } else
    26442616            if ((j =
     
    26472619                                                    spares),
    26482620                                             old_dev)) >= 0) {
    2649             strcpy(raidlist->OSSWAP(el[pos].spare_disks, spares).el[j].
    2650                    device, new_dev);
     2621            strcpy(raidlist->OSSWAP(el[pos].spare_disks, spares).el[j].device, new_dev);
    26512622        }
    26522623#ifndef __FreeBSD__
     
    26652636#endif
    26662637        else {
    2667             mr_asprintf(&tmp, "%s is supposed to be listed in this raid dev but it's not...", old_dev);
    2668             log_it(tmp);
    2669             mr_free(tmp);
     2638            log_it("%s is supposed to be listed in this raid dev but it's not...", old_dev);
    26702639        }
    26712640    }
Note: See TracChangeset for help on using the changeset viewer.