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/common/libmondo-mountlist.c

    r2306 r2316  
    5959    /*@ buffers ******************************************************** */
    6060    char tmp = NULL;
    61     char device[MAX_STR_LEN];
     61    char *device = NULL;
    6262    char mountpoint[MAX_STR_LEN];
    6363
     
    9090    /* check DD */
    9191    for (cur_sp_no = 'a'; cur_sp_no < 'z'; ++cur_sp_no) {
    92         sprintf(device, "%s%c", drive, cur_sp_no);
    93         if (find_device_in_mountlist(mountlist, device) >= 0)
     92        mr_asprintf(&device, "%s%c", drive, cur_sp_no);
     93        if (find_device_in_mountlist(mountlist, device) >= 0) {
    9494            foundsome = TRUE;
     95        }
     96        mr_free(device);
    9597    }
    9698    if (foundsome) {
    9799        for (cur_sp_no = 'a'; cur_sp_no < 'z'; ++cur_sp_no) {
    98             sprintf(device, "%s%c", drive, cur_sp_no);
     100            mr_asprintf(&device, "%s%c", drive, cur_sp_no);
    99101            pos = find_device_in_mountlist(mountlist, device);
    100102            if (pos < 0) {
     103                mr_free(device);
    101104                continue;
    102105            }
     
    156159                res++;
    157160            }
     161            mr_free(device);
     162
    158163            amount_allocated += mountlist->el[pos].size / 1024L;
    159164            prev_sp_no = cur_sp_no;
     
    163168    npos = pos = 0;
    164169    for (curr_part_no = 1; curr_part_no < 99; curr_part_no++) {
    165         build_partition_name(device, drive, curr_part_no);
     170        device = build_partition_name(drive, curr_part_no);
    166171        pos = find_device_in_mountlist(mountlist, device);
    167172        npos = 0;
    168173        for (cur_sp_no = 'a'; cur_sp_no <= 'h'; cur_sp_no++) {
    169             sprintf(device, "%ss%i%c", device, curr_part_no, cur_sp_no);
    170             if (find_device_in_mountlist(mountlist, device) >= 0)
     174            mr_asprintf(&tmp, "%ss%i%c", device, curr_part_no, cur_sp_no);
     175            if (find_device_in_mountlist(mountlist, tmp) >= 0) {
    171176                npos++;
    172         }
     177            }
     178            mr_free(tmp);
     179        }
     180        mr_free(device);
     181
    173182        if (((pos >= 0) || npos) && foundsome) {
    174183            mr_strcat(flaws_str, " %s has both DD and PC-style partitions.", drive);
     
    176185        }
    177186
    178         build_partition_name(device, drive, curr_part_no);
     187        device = build_partition_name(drive, curr_part_no);
    179188        strcpy(mountpoint, mountlist->el[pos].mountpoint);
    180189        if (pos > 0 && !npos) {
     
    256265            /* Check subpartitions */
    257266            for (cur_sp_no = 'a'; cur_sp_no < 'z'; ++cur_sp_no) {
    258                 sprintf(device, "%ss%d%c", drive, curr_part_no, cur_sp_no);
     267                mr_free(device);
     268                mr_asprintf(device, "%ss%d%c", drive, curr_part_no, cur_sp_no);
    259269                pos = find_device_in_mountlist(mountlist, device);
    260270                if (pos < 0) {
     
    321331            }
    322332        }
     333        mr_free(device);
    323334
    324335        /* OK, continue with main loop */
     
    380391    mr_asprintf(&flaws_str, "%s", "");
    381392
    382     malloc_string(device);
    383393    prev_part_no = 0;
    384394
     
    391401        log_msg(1, tmp);
    392402        mr_free(tmp);
    393         goto endoffunc;
     403        return(flaws_str);
    394404    } else {
    395405        mr_asprintf(&tmp, "%s is %ld MB", drive, physical_drive_size);
     
    399409
    400410    for (curr_part_no = 1; curr_part_no < 99; curr_part_no++) {
    401         build_partition_name(device, drive, curr_part_no);
     411        device = build_partition_name(drive, curr_part_no);
    402412        pos = find_device_in_mountlist(mountlist, device);
    403413        if (pos < 0) {
     
    441451        }
    442452        if (device_copies > 1) {
    443             mr_asprintf(&tmp, " %s %s's.", number_to_text(device_copies),
    444                     device);
     453            mr_asprintf(&tmp, " %s %s's.", number_to_text(device_copies), device);
    445454            if (!strstr(flaws_str, tmp)) {
    446455                log_it(tmp);
     
    482491        amount_allocated += mountlist->el[pos].size / 1024L;
    483492        prev_part_no = curr_part_no;
     493        mr_free(device);
    484494    }
    485495
     
    499509        mr_free(tmp);
    500510    }
    501 
    502   endoffunc:
    503     paranoid_free(device);
    504511
    505512    if (res) {
Note: See TracChangeset for help on using the changeset viewer.