summaryrefslogtreecommitdiffstats
path: root/libdwfl/argp-std.c
diff options
context:
space:
mode:
authorMark Wielaard <[email protected]>2013-02-10 15:07:33 +0100
committerMark Wielaard <[email protected]>2013-02-10 15:07:33 +0100
commit40025813dc9e5f2524c3c1851a99efd43cb59894 (patch)
tree5e88f67b7dcbfac97a39aec1060cb7604e5c0f1f /libdwfl/argp-std.c
parent3bdc16ce98295463c071192eab2ec611a8edc508 (diff)
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 <[email protected]>
Diffstat (limited to 'libdwfl/argp-std.c')
-rw-r--r--libdwfl/argp-std.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/libdwfl/argp-std.c b/libdwfl/argp-std.c
index 7584054a..e54f720c 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