cluster-devel.redhat.com archive mirror
 help / color / mirror / Atom feed
* [Cluster-devel] [PATCH] mkfs: Remove duplicated code from verify_bsize()
@ 2011-07-12 14:06 Carlos Maiolino
  2011-07-12 14:26 ` Steven Whitehouse
  2011-07-12 14:37 ` Andrew Price
  0 siblings, 2 replies; 5+ messages in thread
From: Carlos Maiolino @ 2011-07-12 14:06 UTC (permalink / raw)
  To: cluster-devel.redhat.com

Although are_you_sure() function adds some little extra overhead due some
extra checks, use this function instead of duplicate code is worth.
The extra security checks and the additional overhead will not be
noticed by the user.

This is the first try of this patch, but I think the good way to do that
is to move are_you_sure() and some related functions to libgfs2.
---
 gfs2/mkfs/main_mkfs.c |   12 ++++--------
 1 files changed, 4 insertions(+), 8 deletions(-)

diff --git a/gfs2/mkfs/main_mkfs.c b/gfs2/mkfs/main_mkfs.c
index b0bb6e3..315f191 100644
--- a/gfs2/mkfs/main_mkfs.c
+++ b/gfs2/mkfs/main_mkfs.c
@@ -26,6 +26,9 @@
 #include "libgfs2.h"
 #include "gfs2_mkfs.h"
 
+/*Function prototypes*/
+static void are_you_sure(struct gfs2_sbd *sdp);
+
 int discard = 1;
 
 /**
@@ -317,14 +320,7 @@ static void verify_bsize(struct gfs2_sbd *sdp)
 		if (sdp->override)
 			return;
 
-		printf( _("\nAre you sure you want to proceed? [y/n] "));
-		if(!fgets(input, 32, stdin))
-			die( _("unable to read from stdin\n"));
-
-		if (input[0] != 'y')
-			die( _("aborted\n"));
-		else
-			printf("\n");
+		are_you_sure(sdp);
 	}
 }
 
-- 
1.7.5.2



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

end of thread, other threads:[~2011-07-19  9:40 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-07-12 14:06 [Cluster-devel] [PATCH] mkfs: Remove duplicated code from verify_bsize() Carlos Maiolino
2011-07-12 14:26 ` Steven Whitehouse
2011-07-12 14:37 ` Andrew Price
2011-07-18 18:44   ` Carlos Maiolino
2011-07-19  9:40     ` Steven Whitehouse

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).