public inbox for linux-xfs@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] xfsdump: refactor exit_codestring()
@ 2011-08-15 17:43 Bill Kendall
  2011-08-15 18:33 ` Christoph Hellwig
  2011-08-26 15:42 ` Alex Elder
  0 siblings, 2 replies; 3+ messages in thread
From: Bill Kendall @ 2011-08-15 17:43 UTC (permalink / raw)
  To: xfs

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>
---
 common/exit.h |   12 +++++++++++-
 common/main.c |   33 ---------------------------------
 2 files changed, 11 insertions(+), 34 deletions(-)

diff --git a/common/exit.h b/common/exit.h
index 276562d..ef01684 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 c4d6878..5567d44 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 );
 
@@ -2448,38 +2447,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;
-- 
1.7.0.4

_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs

^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2011-08-26 15:42 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-08-15 17:43 [PATCH] xfsdump: refactor exit_codestring() Bill Kendall
2011-08-15 18:33 ` Christoph Hellwig
2011-08-26 15:42 ` Alex Elder

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox