From 6a0112e2c101a5ccf39124e45020f22c7716da5c Mon Sep 17 00:00:00 2001 From: Anoop C S Date: Thu, 27 Jul 2017 14:20:31 +0530 Subject: protocol/server: Fix Wint-in-bool-context compiler warning MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Following warning is shown when compiled with gcc v7: server-helpers.c: In function ‘auth_set_username_passwd’: server-helpers.c:1282:65: warning: ?: using integer constants in boolean context [-Wint-in-bool-context] ret = !((strcmp (data_to_str (passwd_data), ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ password))?0: -1); ~~~~~~~~~~~~^~~~~ CCLD server.la Previously we used to have integers being used in context where boolean values were intended with ternay oprations and it was hard to understand the logic. This change simplifies the logic so that it avoids the warning too. Change-Id: Ie533cf34f829b9fcfeb79f3d519a0ac3cb7f2ab8 Updates: #259 Signed-off-by: Anoop C S Reviewed-on: https://review.gluster.org/17895 Smoke: Gluster Build System Reviewed-by: mohammed rafi kc Reviewed-by: Niels de Vos CentOS-regression: Gluster Build System Reviewed-by: Jeff Darcy --- xlators/protocol/server/src/server-helpers.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'xlators/protocol') diff --git a/xlators/protocol/server/src/server-helpers.c b/xlators/protocol/server/src/server-helpers.c index 381fb6f515e..e6def55c745 100644 --- a/xlators/protocol/server/src/server-helpers.c +++ b/xlators/protocol/server/src/server-helpers.c @@ -1282,19 +1282,19 @@ auth_set_username_passwd (dict_t *input_params, dict_t *config_params, goto out; } - ret = !((strcmp (data_to_str (passwd_data), - password))?0: -1); + ret = strcmp (data_to_str (passwd_data), + password); if (!ret) { client->auth.username = gf_strdup (username); client->auth.passwd = gf_strdup (password); - } - if (ret == -1) + } else { gf_msg ("auth/login", GF_LOG_ERROR, 0, PS_MSG_LOGIN_ERROR, "wrong " "password for user %s", username); + } break; } username_str = strtok_r (NULL, " ,", &tmp); -- cgit