aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBill Kendall <wkendall@sgi.com>2011-09-02 14:22:18 +0000
committerAlex Elder <aelder@sgi.com>2011-09-21 13:00:17 -0500
commit672070559574d733a4b793eabf3d962aacca7105 (patch)
treedd23d292f1b523e483c8667f7ced29158e1a0594
parentcee691843b4565bfb1bbe038dd64fb0f6d94b5b0 (diff)
downloadxfsdump-dev-672070559574d733a4b793eabf3d962aacca7105.tar.gz
xfsdump: remove redundant error code mapping
Currently there is both an exit_strings array and an exit_codestring() function for mapping an exit code to a string. They are very similar except the latter prefaces every string with "EXIT_" and the former uses "SUCCESS" instead of "NORMAL", and cannot handle an invalid exit code. exit_codestring() is not currently used in active code (it's for multi-stream), so its values can be changed to allow the exit_strings array to be removed. Signed-off-by: Bill Kendall <wkendall@sgi.com> Signed-off-by: Alex Elder <aelder@sgi.com>
-rw-r--r--common/exit.h10
-rw-r--r--common/mlog.c14
2 files changed, 7 insertions, 17 deletions
diff --git a/common/exit.h b/common/exit.h
index ef01684b..f7e4878d 100644
--- a/common/exit.h
+++ b/common/exit.h
@@ -29,12 +29,12 @@ static inline const char *
exit_codestring( intgen_t code )
{
switch ( code ) {
- case EXIT_NORMAL: return "EXIT_NORMAL";
- case EXIT_ERROR: return "EXIT_ERROR";
- case EXIT_INTERRUPT: return "EXIT_INTERRUPT";
- case EXIT_FAULT: return "EXIT_FAULT";
+ case EXIT_NORMAL: return "SUCCESS";
+ case EXIT_ERROR: return "ERROR";
+ case EXIT_INTERRUPT: return "INTERRUPT";
+ case EXIT_FAULT: return "FAULT";
}
- return "???";
+ return "UNKNOWN";
}
#endif /* EXIT_H */
diff --git a/common/mlog.c b/common/mlog.c
index 55cb5cd7..2265895e 100644
--- a/common/mlog.c
+++ b/common/mlog.c
@@ -457,11 +457,6 @@ mlog_va( intgen_t levelarg, char *fmt, va_list args )
}
}
-
-static const char *exit_strings[] =
- { "SUCCESS", "ERROR", "INTERRUPT", "", "FAULT" };
-
-
/*
* Map RV codes to actual error messages.
*/
@@ -584,7 +579,7 @@ _mlog_exit( const char *file, int line, int exit_code, rv_t rv )
"%s: %d: mlog_exit called: "
"exit_code: %s return: %s (%s)\n",
file, line,
- exit_strings[exit_code],
+ exit_codestring(exit_code),
rvp->rv_string, rvp->rv_desc);
if (rv < 0 || rv >= _RV_NUM) {
@@ -780,12 +775,7 @@ mlog_exit_flush(void)
if (interrupt) status_str = "INTERRUPT";
else if (quit) status_str = "QUIT";
else if (incomplete) status_str = "INCOMPLETE";
-#ifdef NDEBUG
- /* We should never get here, but if we do make sure we don't die
- horribly when not running debug. */
- else if (! VALID_EXIT_CODE(mlog_main_exit_code)) status_str = "UNKNOWN";
-#endif /* NDEBUG */
- else status_str = exit_strings[mlog_main_exit_code];
+ else status_str = exit_codestring(mlog_main_exit_code);
/* now print the overall state of the dump/restore */
fprintf(mlog_fp, "%s: %s Status: %s\n", progname, PROGSTR_CAPS, status_str);