Changeset 21f1543 in mainline for uspace/app/fdisk/fdisk.c


Ignore:
Timestamp:
2015-10-21T10:09:01Z (9 years ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
ef9dac04
Parents:
852664b9
Message:

Improve partition deletion menu.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/app/fdisk/fdisk.c

    r852664b9 r21f1543  
    419419        fdisk_part_info_t pinfo;
    420420        char *scap = NULL;
     421        char *spkind = NULL;
    421422        char *sfstype = NULL;
    422423        char *sdesc = NULL;
     
    452453                }
    453454
    454                 rc = fdisk_fstype_format(pinfo.fstype, &sfstype);
    455                 if (rc != EOK) {
    456                         printf("Out of memory.\n");
    457                         goto error;
    458                 }
    459 
    460                 rc = asprintf(&sdesc, "%s, %s", scap, sfstype);
    461                 if (rc < 0) {
    462                         rc = ENOMEM;
    463                         goto error;
     455                rc = fdisk_pkind_format(pinfo.pkind, &spkind);
     456                if (rc != EOK) {
     457                        printf("\nOut of memory.\n");
     458                        goto error;
     459                }
     460
     461                if (pinfo.pkind != lpk_extended) {
     462                        rc = fdisk_fstype_format(pinfo.fstype, &sfstype);
     463                        if (rc != EOK) {
     464                                printf("Out of memory.\n");
     465                                goto error;
     466                        }
     467
     468                        rc = asprintf(&sdesc, "%s, %s, %s", scap, spkind, sfstype);
     469                        if (rc < 0) {
     470                                rc = ENOMEM;
     471                                goto error;
     472                        }
     473
     474                } else {
     475                        rc = asprintf(&sdesc, "%s, %s", scap, spkind);
     476                        if (rc < 0) {
     477                                rc = ENOMEM;
     478                                goto error;
     479                        }
    464480                }
    465481
     
    473489                free(scap);
    474490                scap = NULL;
     491                free(spkind);
     492                spkind = NULL;
    475493                free(sfstype);
    476494                sfstype = NULL;
     
    481499        }
    482500
     501        rc = nchoice_add(choice, "Cancel", NULL, 0);
     502        if (rc != EOK) {
     503                assert(rc == ENOMEM);
     504                printf("Out of memory.\n");
     505                goto error;
     506        }
     507
    483508        rc = nchoice_get(choice, &sel);
    484509        if (rc != EOK) {
     
    487512        }
    488513
    489         rc = fdisk_part_destroy((fdisk_part_t *)sel);
    490         if (rc != EOK) {
    491                 printf("Error deleting partition.\n");
    492                 return rc;
     514        if (sel != NULL) {
     515                rc = fdisk_part_destroy((fdisk_part_t *)sel);
     516                if (rc != EOK) {
     517                        printf("Error deleting partition.\n");
     518                        return rc;
     519                }
    493520        }
    494521
     
    497524error:
    498525        free(scap);
     526        free(spkind);
    499527        free(sfstype);
    500528        free(sdesc);
Note: See TracChangeset for help on using the changeset viewer.