]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
client: fix compile warning and incorrect computing the max_fwd 45983/head
authorXiubo Li <xiubli@redhat.com>
Thu, 21 Apr 2022 10:15:20 +0000 (18:15 +0800)
committerXiubo Li <xiubli@redhat.com>
Fri, 22 Apr 2022 10:32:31 +0000 (18:32 +0800)
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 <jcollin@redhat.com>
Reported-by: Rishabh Dave <ridave@redhat.com>
Signed-off-by: Xiubo Li <xiubli@redhat.com>
src/client/Client.cc

index 9651509686d031464e829e9b35d8681aeadcaf4f..f206cefd381d539b86c77af9dae8ee7c8a4dbb83 100644 (file)
@@ -2552,7 +2552,7 @@ void Client::handle_client_request_forward(const MConstRef<MClientRequestForward
    * using the hardcode here.
    */
   int max_fwd = sizeof(((struct ceph_mds_request_head*)0)->num_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) {