diff options
author | Joel Granados Moreno <jgranado@redhat.com> | 2009-06-10 19:05:50 +0200 |
---|---|---|
committer | Jim Meyering <meyering@redhat.com> | 2009-06-10 21:23:25 +0200 |
commit | 0615f35015f375d2c80cd95939b28fba3828eddb (patch) | |
tree | b86f7df69418fd49c465ef0799658dbb3239d836 /parted | |
parent | fafc091696d3022f7b1d6bf5df719a465e8e1cf7 (diff) | |
download | parted-0615f35015f375d2c80cd95939b28fba3828eddb.tar.gz |
parted-ui: ensure cmd-line buffer is empty before ped_exception_throw
When ped_exception_throw requires input from the user and there are
leftover strings in the command line, there is an "invalid token" error
from parted. This happens because the ped_exception expects some input
that is, most likely, different from the leftover string(s). To address
this, one must make sure that all the argument strings are parsed before
invoking any exception that requires input.
* parted/parted.c (do_mklabel): Call command_line_get_disk_type call
before the disk checks (_disk_warn_loss will call ped_exception_throw).
* tests/t0000-basic.sh: Adjust, now that the output need not include
the error message.
Diffstat (limited to 'parted')
-rw-r--r-- | parted/parted.c | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/parted/parted.c b/parted/parted.c index ac1b176..e6364bf 100644 --- a/parted/parted.c +++ b/parted/parted.c @@ -1,6 +1,6 @@ /* parted - a frontend to libparted - Copyright (C) 1999-2003, 2005-2008 Free Software Foundation, Inc. + Copyright (C) 1999-2003, 2005-2009 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -595,13 +595,16 @@ static int do_mklabel (PedDevice** dev) { PedDisk* disk; - const PedDiskType* type = ped_disk_probe (*dev); + const PedDiskType* type = NULL; ped_exception_fetch_all (); disk = ped_disk_new (*dev); if (!disk) ped_exception_catch (); ped_exception_leave_all (); + if (!command_line_get_disk_type (_("New disk label type?"), &type)) + goto error; + if (disk) { if (!_disk_warn_busy (disk)) goto error_destroy_disk; @@ -611,9 +614,6 @@ do_mklabel (PedDevice** dev) ped_disk_destroy (disk); } - if (!command_line_get_disk_type (_("New disk label type?"), &type)) - goto error; - disk = ped_disk_new_fresh (*dev, type); if (!disk) goto error; |