summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBen Hutchings <bhutchings@solarflare.com>2012-10-10 22:19:15 +0100
committerBen Hutchings <bhutchings@solarflare.com>2012-10-10 22:22:25 +0100
commit963faa0063e89bfd0d807b3c25fcb0723541a045 (patch)
treee2886f15dab98c163b0f259f813fa62633b3096d
parent5131914e1a10cfd90b6ba45fbd0eec372884398f (diff)
downloadethtool-963faa0063e89bfd0d807b3c25fcb0723541a045.tar.gz
Gracefully handle failure of register dump pretty-printer
If we have a pretty-printer matching the driver name for a register dump, but it doesn't handle the reported dump version, then we currently fail and print: Cannot dump registers: Success Instead, fall back to hex dump. Also, don't use perror() to explain a failure of dump_regs(). errno is not meaningful in either failure case. Signed-off-by: Ben Hutchings <bhutchings@solarflare.com>
-rw-r--r--ethtool.c13
1 files changed, 10 insertions, 3 deletions
diff --git a/ethtool.c b/ethtool.c
index f3649e2..1081576 100644
--- a/ethtool.c
+++ b/ethtool.c
@@ -934,8 +934,15 @@ static int dump_regs(int gregs_dump_raw, int gregs_dump_hex,
if (!gregs_dump_hex)
for (i = 0; i < ARRAY_SIZE(driver_list); i++)
if (!strncmp(driver_list[i].name, info->driver,
- ETHTOOL_BUSINFO_LEN))
- return driver_list[i].func(info, regs);
+ ETHTOOL_BUSINFO_LEN)) {
+ if (driver_list[i].func(info, regs) == 0)
+ return 0;
+ /* This version (or some other
+ * variation in the dump format) is
+ * not handled; fall back to hex
+ */
+ break;
+ }
dump_hex(stdout, regs->data, regs->len, 0);
@@ -2632,7 +2639,7 @@ static int do_gregs(struct cmd_context *ctx)
}
if (dump_regs(gregs_dump_raw, gregs_dump_hex, gregs_dump_file,
&drvinfo, regs) < 0) {
- perror("Cannot dump registers");
+ fprintf(stderr, "Cannot dump registers\n");
free(regs);
return 75;
}