From: Xiubo Li Date: Thu, 21 Apr 2022 10:15:20 +0000 (+0800) Subject: client: fix compile warning and incorrect computing the max_fwd X-Git-Tag: v16.2.14~138^2~5 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=bc2fbbeef573f695c2ab1833b01e4026f9d61c62;p=ceph.git client: fix compile warning and incorrect computing the max_fwd warning: suggest parentheses around ‘-’ inside ‘<<’ [-Wparentheses] max_fwd = 1 << (max_fwd * CHAR_BIT) - 1; ~~~~~~~~~~~~~~~~~~~~~^~~ And also the '-' has precedence over the '<<', more detail please see https://en.cppreference.com/w/c/language/operator_precedence. Fixes: https://tracker.ceph.com/issues/55409 Reported-by: Jos Collin Reported-by: Rishabh Dave Signed-off-by: Xiubo Li (cherry picked from commit 6a28c337d9c669f49855367da4dc91131b836b94) --- diff --git a/src/client/Client.cc b/src/client/Client.cc index aa9b1de0a717..71ccd9c70d57 100644 --- a/src/client/Client.cc +++ b/src/client/Client.cc @@ -2611,7 +2611,7 @@ void Client::handle_client_request_forward(const MConstRefnum_fwd); - max_fwd = 1 << (max_fwd * CHAR_BIT) - 1; + max_fwd = (1 << (max_fwd * CHAR_BIT)) - 1; auto num_fwd = fwd->get_num_fwd(); if (num_fwd <= request->num_fwd || num_fwd >= max_fwd) { if (request->num_fwd >= max_fwd || num_fwd >= max_fwd) {