aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBill Kendall <wkendall@sgi.com>2011-08-15 17:43:32 +0000
committerAlex Elder <aelder@sgi.com>2011-08-26 10:42:54 -0500
commita629a5090e48e08fd8d0accca3925c972641b702 (patch)
tree7a2e1ea11eb07bfd19c59fab5193f411e9d4df2b
parent5bbc74256d8dcbb086a57a40116cbecf16e2beec (diff)
downloadxfsdump-dev-a629a5090e48e08fd8d0accca3925c972641b702.tar.gz
xfsdump: refactor exit_codestring()
Simplify exit_codestring(), which maps an exit code into a string. Make it available to all code which includes "exit.h". Also remove the unused type "exit_t". Signed-off-by: Bill Kendall <wkendall@sgi.com> Reviewed-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Alex Elder <aelder@sgi.com>
-rw-r--r--common/exit.h12
-rw-r--r--common/main.c33
2 files changed, 11 insertions, 34 deletions
diff --git a/common/exit.h b/common/exit.h
index 276562d8..ef01684b 100644
--- a/common/exit.h
+++ b/common/exit.h
@@ -25,6 +25,16 @@
#define EXIT_INTERRUPT 2 /* interrupted (operator or device error) */
#define EXIT_FAULT 4 /* code fault */
-typedef size_t exit_t;
+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";
+ }
+ return "???";
+}
#endif /* EXIT_H */
diff --git a/common/main.c b/common/main.c
index ba62a690..980d2d43 100644
--- a/common/main.c
+++ b/common/main.c
@@ -100,7 +100,6 @@ static bool_t set_rlimits( void );
#ifdef RESTORE
static bool_t set_rlimits( size64_t * );
#endif /* RESTORE */
-static char *exit_codestring( intgen_t code );
static char *sig_numstring( intgen_t num );
static char *strpbrkquotes( char *p, const char *sep );
@@ -2319,38 +2318,6 @@ set_rlimits( size64_t *vmszp )
return BOOL_TRUE;
}
-struct exit_printmap {
- intgen_t code;
- char *string;
-};
-
-typedef struct exit_printmap exit_printmap_t;
-
-static exit_printmap_t exit_printmap[ ] = {
- {EXIT_NORMAL, "EXIT_NORMAL"},
- {EXIT_ERROR, "EXIT_ERROR"},
- {EXIT_INTERRUPT,"EXIT_INTERRUPT"},
- {EXIT_FAULT, "EXIT_FAULT"}
-};
-
-static char *
-exit_codestring( intgen_t code )
-{
- exit_printmap_t *p = exit_printmap;
- exit_printmap_t *endp = exit_printmap
- +
- ( sizeof( exit_printmap )
- /
- sizeof( exit_printmap[ 0 ] ));
- for ( ; p < endp ; p++ ) {
- if ( p->code == code ) {
- return p->string;
- }
- }
-
- return "???";
-}
-
struct sig_printmap {
intgen_t num;
char *string;