From: Petr Uzel <petr.uzel@suse.cz>
To: Davidlohr Bueso <dave@gnu.org>
Cc: util-linux <util-linux@vger.kernel.org>
Subject: Re: [PATCH 1/4] fdisk: remove stack jumping
Date: Sat, 28 Apr 2012 18:15:02 +0200 [thread overview]
Message-ID: <20120428161502.GA8714@skipper.site> (raw)
In-Reply-To: <1335525822.11068.4.camel@offworld>
[-- Attachment #1: Type: text/plain, Size: 2583 bytes --]
On Fri, Apr 27, 2012 at 01:23:42PM +0200, Davidlohr Bueso wrote:
> From: Davidlohr Bueso <dave@gnu.org>
>
> This patch eliminates the long/setjmp code. The current logic
> does not do anything with stack jumps as it only exits from
> print_partition_table_from_option() when a fatal error occurs.
The stack jumping makes fdisk remain silent and return success (!)
if the listing fails on any of the devices. Not that I think this
is useful behavior, but IMHO this change in behavior is worth
mentioning in the release notes.
Reviewed-by: Petr Uzel <petr.uzel@suse.cz>
> Signed-off-by: Davidlohr Bueso <dave@gnu.org>
> ---
> fdisk/fdisk.c | 17 ++---------------
> 1 files changed, 2 insertions(+), 15 deletions(-)
>
> diff --git a/fdisk/fdisk.c b/fdisk/fdisk.c
> index 4054b4d..886f011 100644
> --- a/fdisk/fdisk.c
> +++ b/fdisk/fdisk.c
> @@ -14,7 +14,6 @@
> #include <string.h>
> #include <fcntl.h>
> #include <ctype.h>
> -#include <setjmp.h>
> #include <errno.h>
> #include <getopt.h>
> #include <sys/stat.h>
> @@ -245,8 +244,6 @@ int has_topology;
>
> enum labeltype disklabel; /* Current disklabel */
>
> -jmp_buf listingbuf;
> -
> static void __attribute__ ((__noreturn__)) usage(FILE *out)
> {
> fprintf(out, _("Usage:\n"
> @@ -266,13 +263,8 @@ static void __attribute__ ((__noreturn__)) usage(FILE *out)
> exit(out == stderr ? EXIT_FAILURE : EXIT_SUCCESS);
> }
>
> -void fatal(enum failure why) {
> -
> - if (listing) {
> - close(fd);
> - longjmp(listingbuf, 1);
> - }
> -
> +void fatal(enum failure why)
> +{
> switch (why) {
> case unable_to_open:
> err(EXIT_FAILURE, _("unable to open %s"), disk_device);
> @@ -2708,8 +2700,6 @@ print_partition_table_from_option(char *device)
> int gb;
>
> disk_device = device;
> - if (setjmp(listingbuf))
> - return;
> gpt_warning(device);
> gb = get_boot(1);
> if (gb < 0) { /* no DOS signature */
> @@ -2950,9 +2940,6 @@ main(int argc, char **argv) {
> nowarn = 1;
> if (argc > optind) {
> int k;
> - /* avoid gcc warning:
> - variable `k' might be clobbered by `longjmp' */
> - dummy(&k);
> listing = 1;
> for (k = optind; k < argc; k++)
> print_partition_table_from_option(argv[k]);
> --
> 1.7.4.1
>
>
>
>
> --
> To unsubscribe from this list: send the line "unsubscribe util-linux" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
Petr
--
Petr Uzel
IRC: ptr_uzl @ freenode
[-- Attachment #2: Type: application/pgp-signature, Size: 198 bytes --]
next prev parent reply other threads:[~2012-04-28 16:19 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-04-27 11:23 [PATCH 1/4] fdisk: remove stack jumping Davidlohr Bueso
2012-04-28 16:15 ` Petr Uzel [this message]
2012-05-02 7:42 ` Karel Zak
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20120428161502.GA8714@skipper.site \
--to=petr.uzel@suse.cz \
--cc=dave@gnu.org \
--cc=util-linux@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox