public inbox for linux-xfs@vger.kernel.org
 help / color / mirror / Atom feed
From: Bill Kendall <wkendall@sgi.com>
To: xfs@oss.sgi.com
Subject: [PATCH] xfsdump: refactor exit_codestring()
Date: Mon, 15 Aug 2011 12:43:32 -0500	[thread overview]
Message-ID: <1313430212-20028-1-git-send-email-wkendall@sgi.com> (raw)

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

             reply	other threads:[~2011-08-15 17:43 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-08-15 17:43 Bill Kendall [this message]
2011-08-15 18:33 ` [PATCH] xfsdump: refactor exit_codestring() Christoph Hellwig
2011-08-26 15:42 ` Alex Elder

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1313430212-20028-1-git-send-email-wkendall@sgi.com \
    --to=wkendall@sgi.com \
    --cc=xfs@oss.sgi.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox