]> git.ipfire.org Git - thirdparty/util-linux.git/blobdiff - disk-utils/fdisk-menu.c
fstrim shouldn't run inside a container
[thirdparty/util-linux.git] / disk-utils / fdisk-menu.c
index b2cb0d7cb9571cbd2e77cdcc421cb601ac127a58..cd104e20be1a130c1d08ccce94b6ef64e92c92a5 100644 (file)
@@ -417,7 +417,7 @@ int process_fdisk_menu(struct fdisk_context **cxt0)
        const struct menu *menu;
        int key, rc;
        const char *prompt;
-       char buf[BUFSIZ];
+       char buf[BUFSIZ] = { '\0' };
 
        if (fdisk_is_details(cxt))
                prompt = _("Expert command (m for help): ");
@@ -650,8 +650,10 @@ static int generic_menu_cb(struct fdisk_context **cxt0,
        switch (ent->key) {
        case 'd':
                rc = fdisk_ask_partnum(cxt, &n, FALSE);
-               if (!rc)
-                       rc = fdisk_delete_partition(cxt, n);
+               if (rc)
+                       break; /* no partitions yet (or ENOMEM, ...) */
+
+               rc = fdisk_delete_partition(cxt, n);
                if (rc)
                        fdisk_warnx(cxt, _("Could not delete partition %zu"), n + 1);
                else