From: Mark Wielaard Date: Sun, 10 Feb 2013 14:07:33 +0000 (+0100) Subject: libdwfl: Use actual file names in parse_opt failure cases. X-Git-Tag: elfutils-0.156~41 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=40025813dc9e5f2524c3c1851a99efd43cb59894;p=platform%2Fupstream%2Felfutils.git libdwfl: Use actual file names in parse_opt failure cases. When handling ARGP_KEY_SUCCESS the failure handling code would use 'arg' as failure string. But 'arg' would be NULL in such cases leading to failure messages like: "cannot open '(null)': No such file or directory". Use opt->e and opt->core explicitly to show file names that caused failure. Signed-off-by: Mark Wielaard --- diff --git a/libdwfl/ChangeLog b/libdwfl/ChangeLog index 11d599b..1311dea 100644 --- a/libdwfl/ChangeLog +++ b/libdwfl/ChangeLog @@ -1,3 +1,9 @@ +2013-02-10 Mark Wielaard + + * argp-std.c (parse_opt): Use opt->core and opt->e explicitly in + failure messages When handling ARGP_KEY_SUCCESS because arg will + not have been set. + 2013-01-30 Jan Kratochvil * linux-proc-maps.c: Include system.h. diff --git a/libdwfl/argp-std.c b/libdwfl/argp-std.c index 7584054..e54f720 100644 --- a/libdwfl/argp-std.c +++ b/libdwfl/argp-std.c @@ -210,7 +210,6 @@ parse_opt (int key, char *arg, struct argp_state *state) { FILE *f = fopen (arg, "r"); if (f == NULL) - nofile: { int code = errno; argp_failure (state, EXIT_FAILURE, code, @@ -298,7 +297,12 @@ parse_opt (int key, char *arg, struct argp_state *state) { int fd = open64 (opt->core, O_RDONLY); if (fd < 0) - goto nofile; + { + int code = errno; + argp_failure (state, EXIT_FAILURE, code, + "cannot open '%s'", opt->core); + return code; + } Elf *core; Dwfl_Error error = __libdw_open_file (&fd, &core, true, false); @@ -333,7 +337,7 @@ parse_opt (int key, char *arg, struct argp_state *state) else if (opt->e) { if (INTUSE(dwfl_report_offline) (dwfl, "", opt->e, -1) == NULL) - return fail (dwfl, -1, arg); + return fail (dwfl, -1, opt->e); } /* One of the three flavors has done dwfl_begin and some reporting