This is an automated email from the git hooks/post-receive script.
andyp pushed a commit to branch RHEL7
in repository gfs2-utils.
commit ffe94a73a147c6ef5086530734772bccfff6e70c
Author: Andrew Price <anprice(a)redhat.com>
Date: Fri Jun 10 11:44:10 2016 +0100
mkfs.gfs2: Tidy up are_you_sure()
Coverity pointed out that the 'line' pointer was dereferenced before it
was NULL-checked and although that wasn't a bug it highlighted this
function's strange structure. This patch tidies it up somewhat, keeping
in mind that the memory allocated by getline() always has to be freed
whether it succeeds or not.
Signed-off-by: Andrew Price <anprice(a)redhat.com>
---
gfs2/mkfs/main_mkfs.c | 33 ++++++++++++++-------------------
1 file changed, 14 insertions(+), 19 deletions(-)
diff --git a/gfs2/mkfs/main_mkfs.c b/gfs2/mkfs/main_mkfs.c
index 4436f93..7ede5ad 100644
--- a/gfs2/mkfs/main_mkfs.c
+++ b/gfs2/mkfs/main_mkfs.c
@@ -422,34 +422,29 @@ static void test_locking(struct mkfs_opts *opts)
static void are_you_sure(void)
{
- char *line = NULL;
- size_t len = 0;
- int ret = -1;
- int res = 0;
+ while (1) {
+ char *line = NULL;
+ size_t len = 0;
+ int ret;
+ int res;
- do{
/* Translators: We use rpmatch(3) to match the answers to y/n
questions in the user's own language, so the [y/n] here must also be
translated to match one of the letters in the pattern printed by
`locale -k yesexpr` and one of the letters in the pattern printed by
`locale -k noexpr` */
- printf( _("Are you sure you want to proceed? [y/n]"));
+ printf( _("Are you sure you want to proceed? [y/n] "));
ret = getline(&line, &len, stdin);
res = rpmatch(line);
-
- if (res > 0){
- free(line);
- return;
- }
- if (!res){
- printf("\n");
- die( _("Aborted.\n"));
- }
-
- }while(ret >= 0);
-
- if(line)
free(line);
+ if (ret <= 0)
+ continue;
+ if (res == 1) /* Yes */
+ return;
+ if (res == 0) /* No */
+ exit(1);
+ /* Unrecognized input; go again. */
+ };
}
static unsigned choose_blocksize(struct mkfs_opts *opts)
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
Show replies by date