Skip to contentSkip to conversation

fdisk: add an quit/exit handling function

PATCH Applied Davidlohr Bueso 1 participant 1 message May 20, 2012 Util-Linux package

lore
Share & tools
lore
#0 lore raw

PATCH 1/6 fdisk: add an quit/exit handling function

From: Davidlohr Bueso <[email protected]>

---
 fdisk/fdisk.c |   15 +++++++++------
 1 files changed, 9 insertions(+), 6 deletions(-)
fdisk/fdisk.c +9 -6
index 3f83297..2f3c119 100644
@@ -1810,6 +1810,13 @@ move_begin(int i) {
 	}
 }
 
+static void __attribute__ ((__noreturn__)) handle_quit(void)
+{
+	close(fd);
+	printf("\n");
+	exit(EXIT_SUCCESS);
+}
+
 static void
 expert_command_prompt(void)
 {
@@ -1875,9 +1882,7 @@ expert_command_prompt(void)
 				x_list_table(0);
 			break;
 		case 'q':
-			close(fd);
-			printf("\n");
-			exit(0);
+			handle_quit();
 		case 'r':
 			return;
 		case 's':
@@ -2064,9 +2069,7 @@ static void command_prompt(void)
 			list_table(0);
 			break;
 		case 'q':
-			close(fd);
-			printf("\n");
-			exit(0);
+			handle_quit();
 		case 's':
 			create_sunlabel();
 			break;
Signature · 1 line
1.7.4.1