This is an automated email from the git hooks/post-receive script.
andyp pushed a commit to branch master in repository gfs2-utils.
commit a39faf8697e487079feb7c99a41dcf51af2ebc37 Author: Andrew Price anprice@redhat.com Date: Thu Aug 3 16:03:14 2017 +0100
gfs2_convert: Fix fgets return value warning
Rewrite the gfs2_query() function to use the input method used in mkfs.gfs2 and avoid problems with fgets()
gfs2_convert.c:2139:3: warning: ignoring return value of ‘fgets’, declared with attribute warn_unused_result [-Wunused-result]
Signed-off-by: Andrew Price anprice@redhat.com --- gfs2/convert/gfs2_convert.c | 31 ++++++++++++++----------------- 1 file changed, 14 insertions(+), 17 deletions(-)
diff --git a/gfs2/convert/gfs2_convert.c b/gfs2/convert/gfs2_convert.c index 5d813dc..d5e98e6 100644 --- a/gfs2/convert/gfs2_convert.c +++ b/gfs2/convert/gfs2_convert.c @@ -2123,8 +2123,7 @@ static void copy_quotas(struct gfs2_sbd *sdp)
static int gfs2_query(struct gfs2_options *opts, const char *dev) { - char response[3] = { 0, 0 }; - int ret = 0; + int res = 0;
if(opts->yes) return 1; @@ -2133,27 +2132,25 @@ static int gfs2_query(struct gfs2_options *opts, const char *dev)
opts->query = TRUE; while (1) { + char *line = NULL; + size_t len = 0; + int ret; + printf(_("Convert %s from GFS1 to GFS2? (y/n)"), dev); - /* Make sure query is printed out */ - fflush(NULL); - fgets(response, 3, stdin); - printf("\n"); - fflush(NULL); - response[1] = 0; - ret = rpmatch(response); - - if (ret >= 0) + fflush(stdout); + ret = getline(&line, &len, stdin); + res = rpmatch(line); + free(line); + if (ret <= 0) + continue; + if (res == 1 || res == 0) break; - printf(_("Bad response '%s', please type 'y' or 'n'.\n"), response); + /* Unrecognized input; go again. */ } - opts->query = FALSE; - return ret; + return res; }
-/* ------------------------------------------------------------------------- */ -/* main - mainline code */ -/* ------------------------------------------------------------------------- */ int main(int argc, char **argv) { int error;
cluster-commits@lists.stg.fedorahosted.org