summaryrefslogtreecommitdiffstats
path: root/fdisk/fdisk.c
diff options
context:
space:
mode:
authorFrancesco Cosoleto2011-05-06 17:23:33 +0200
committerKarel Zak2011-05-10 13:50:16 +0200
commitb25c9df7c71d75e33d8364f9b3b590faf43c0522 (patch)
tree845dfcd1d7f9b395713dc0a85bff66bf112cdbec /fdisk/fdisk.c
parentfdisk: add a default response for the partition type dialog (diff)
downloadkernel-qcow2-util-linux-b25c9df7c71d75e33d8364f9b3b590faf43c0522.tar.gz
kernel-qcow2-util-linux-b25c9df7c71d75e33d8364f9b3b590faf43c0522.tar.xz
kernel-qcow2-util-linux-b25c9df7c71d75e33d8364f9b3b590faf43c0522.zip
fdisk: quit from partition type dialog after invalid response
This gets rid of the while() loop and fixes indentation. Signed-off-by: Francesco Cosoleto <cosoleto@gmail.com>
Diffstat (limited to 'fdisk/fdisk.c')
-rw-r--r--fdisk/fdisk.c45
1 files changed, 20 insertions, 25 deletions
diff --git a/fdisk/fdisk.c b/fdisk/fdisk.c
index ac9035cc7..b34b6537d 100644
--- a/fdisk/fdisk.c
+++ b/fdisk/fdisk.c
@@ -2534,8 +2534,7 @@ new_partition(void) {
} else {
char c, dflt, line[LINE_LENGTH];
- while (1) {
- dflt = (free_primary == 1 && !extended_offset) ? 'e' : 'p';
+ dflt = (free_primary == 1 && !extended_offset) ? 'e' : 'p';
snprintf(line, sizeof(line),
_("Partition type:\n"
" p primary (%d primary, %d extended, %d free)\n"
@@ -2545,30 +2544,26 @@ new_partition(void) {
extended_offset ? _(" l logical (numbered from 5)") : _(" e extended"),
dflt);
- c = tolower(read_chars(line));
- if (c == '\n') {
- c = dflt;
- printf(_("Using default response %c\n"), c);
- }
- if (c == 'p') {
- int i = get_nonexisting_partition(0, 4);
- if (i >= 0)
- add_partition(i, LINUX_NATIVE);
- return;
- }
- else if (c == 'l' && extended_offset) {
- add_logical();
- return;
- }
- else if (c == 'e' && !extended_offset) {
- int i = get_nonexisting_partition(0, 4);
- if (i >= 0)
- add_partition(i, EXTENDED);
- return;
- }
- else
- printf(_("Invalid partition type `%c'\n"), c);
+ c = tolower(read_chars(line));
+ if (c == '\n') {
+ c = dflt;
+ printf(_("Using default response %c\n"), c);
}
+ if (c == 'p') {
+ int i = get_nonexisting_partition(0, 4);
+ if (i >= 0)
+ add_partition(i, LINUX_NATIVE);
+ return;
+ } else if (c == 'l' && extended_offset) {
+ add_logical();
+ return;
+ } else if (c == 'e' && !extended_offset) {
+ int i = get_nonexisting_partition(0, 4);
+ if (i >= 0)
+ add_partition(i, EXTENDED);
+ return;
+ } else
+ printf(_("Invalid partition type `%c'\n"), c);
}
}