From: Steven Whitehouse <swhiteho@redhat.com>
To: cluster-devel.redhat.com
Subject: [Cluster-devel] [PATCH] mkfs: Remove duplicated code from verify_bsize()
Date: Tue, 12 Jul 2011 15:26:14 +0100 [thread overview]
Message-ID: <1310480774.2731.10.camel@menhir> (raw)
In-Reply-To: <1310479579-12731-1-git-send-email-cmaiolino@redhat.com>
Hi,
On Tue, 2011-07-12 at 11:06 -0300, Carlos Maiolino wrote:
> 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.
> ---
This looks like another bit of code that should be simplified. Why does
are_you_sure() open the device like that I wonder? Its just been opened
immediately above that in the code, so we can remove that opening of the
device, it does nothing useful.
> 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);
> }
> }
>
This is a change of behaviour. Do we really want to run
check_dev_content() in this case? I suspect not. This is something which
could usefully be made into common code (the "are you sure" bit) but
please don't move it into libgfs2 as we are trying to keep all user
interface code out of there. A useful thing to do would be to work out
how to get at the glibc translations for useful phrases, such as "yes"
and "no" and rewrite the function using those,
Steve.
next prev parent reply other threads:[~2011-07-12 14:26 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-07-12 14:06 [Cluster-devel] [PATCH] mkfs: Remove duplicated code from verify_bsize() Carlos Maiolino
2011-07-12 14:26 ` Steven Whitehouse [this message]
2011-07-12 14:37 ` Andrew Price
2011-07-18 18:44 ` Carlos Maiolino
2011-07-19 9:40 ` Steven Whitehouse
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=1310480774.2731.10.camel@menhir \
--to=swhiteho@redhat.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;
as well as URLs for NNTP newsgroup(s).