From: Bill Kendall <wkendall@sgi.com>
To: xfs@oss.sgi.com
Subject: [PATCH] xfsdump: allow multi-digit dialog prompts
Date: Wed, 27 Jul 2011 11:41:53 -0500 [thread overview]
Message-ID: <1311784913-14191-1-git-send-email-wkendall@sgi.com> (raw)
xfsdump issues a multiple-choice dialog in various circumstances
(e.g., media change request). An assert incorrectly limits this to
at most 8 choices even though the code can handle up to 9. Remove
the assert and change the code to handle multi-digit responses.
Signed-off-by: Bill Kendall <wkendall@sgi.com>
---
common/dlog.c | 21 +++++++++------------
1 files changed, 9 insertions(+), 12 deletions(-)
diff --git a/common/dlog.c b/common/dlog.c
index 6a243ef..c81edc6 100644
--- a/common/dlog.c
+++ b/common/dlog.c
@@ -19,6 +19,7 @@
#include <xfs/xfs.h>
#include <xfs/jdm.h>
+#include <stdlib.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <time.h>
@@ -186,7 +187,6 @@ dlog_multi_query( char *querystr[ ],
/* sanity
*/
ASSERT( dlog_allowed_flag );
- ASSERT( choicecnt < 9 );
/* display query description strings
*/
@@ -245,24 +245,21 @@ dlog_multi_query( char *querystr[ ],
prepromptstr,
choicecnt );
if ( ok ) {
+ long int val;
+ char *end = buf;
+
if ( ! strlen( buf )) {
return defaultix;
}
- if ( strlen( buf ) != 1 ) {
- prepromptstr = _(
- "please enter a single "
- "digit response (1 to %d)");
- continue;
- }
- if ( buf[ 0 ] < '1'
- ||
- buf[ 0 ] >= '1' + ( u_char_t )choicecnt ) {
+
+ val = strtol( buf, &end, 10 );
+ if ( *end != '\0' || val < 1 || val > choicecnt ) {
prepromptstr = _(
- "please enter a single digit "
+ "please enter a value "
"between 1 and %d inclusive ");
continue;
}
- return ( size_t )( buf[ 0 ] - '1' );
+ return val - 1; // return value is a 0-based index
} else {
return exceptionix;
}
--
1.7.0.4
_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs
next reply other threads:[~2011-07-27 16:43 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-07-27 16:41 Bill Kendall [this message]
2011-08-02 9:55 ` [PATCH] xfsdump: allow multi-digit dialog prompts Christoph Hellwig
2011-08-09 20:55 ` 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=1311784913-14191-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