]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
fdisk: add an quit/exit handling function
authorDavidlohr Bueso <dave@gnu.org>
Sun, 20 May 2012 16:11:21 +0000 (18:11 +0200)
committerKarel Zak <kzak@redhat.com>
Wed, 23 May 2012 08:50:59 +0000 (10:50 +0200)
Signed-off-by: Davidlohr Bueso <dave@gnu.org>
fdisk/fdisk.c

index 3f832977c1ec124327c9460daad00087c8f66778..2f3c11900bc32dadcddfd1fb79bfb05dd81dc3c6 100644 (file)
@@ -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;