]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
crimson: do not rely on implicit conversion to bool
authorKefu Chai <kchai@redhat.com>
Tue, 9 Mar 2021 14:28:09 +0000 (22:28 +0800)
committerKefu Chai <kchai@redhat.com>
Tue, 9 Mar 2021 14:32:36 +0000 (22:32 +0800)
for better readability

Signed-off-by: Kefu Chai <kchai@redhat.com>
src/crimson/common/throttle.cc
src/crimson/common/tri_mutex.cc
src/crimson/net/ProtocolV2.cc

index bd919518107a2e50d81e2354ea5b6f6a49d49cc2..8aeaa1fdd7d9fd75420c42d2fd506562a1a7d1f5 100644 (file)
@@ -4,7 +4,7 @@ namespace crimson::common {
 
 int64_t Throttle::take(int64_t c)
 {
-  if (!max) {
+  if (max == 0u) {
     return 0;
   }
   count += c;
@@ -13,7 +13,7 @@ int64_t Throttle::take(int64_t c)
 
 int64_t Throttle::put(int64_t c)
 {
-  if (!max) {
+  if (max == 0u) {
     return 0;
   }
   if (!c) {
@@ -26,7 +26,7 @@ int64_t Throttle::put(int64_t c)
 
 seastar::future<> Throttle::get(size_t c)
 {
-  if (!max) {
+  if (max == 0u) {
     return seastar::make_ready_future<>();
   }
   return on_free_slots.wait([this, c] {
index c18aff1a00fe94599210e348137208cbdbbd27f8..e4b18128053e3cea5e6ac99300b48952811e1998 100644 (file)
@@ -164,7 +164,7 @@ seastar::future<> tri_mutex::lock_for_excl()
 
 bool tri_mutex::try_lock_for_excl() noexcept
 {
-  if (!readers && !writers && !exclusively_used) {
+  if (readers == 0u && writers == 0u && !exclusively_used) {
     exclusively_used = true;
     return true;
   } else {
@@ -181,9 +181,9 @@ void tri_mutex::unlock_for_excl()
 
 bool tri_mutex::is_acquired() const
 {
-  if (readers) {
+  if (readers != 0u) {
     return true;
-  } else if (writers) {
+  } else if (writers != 0u) {
     return true;
   } else if (exclusively_used) {
     return true;
index b7137b8b83b94727c8ad1cae1e19a583b1024fa9..4e118302bc8528ec268b7e89acd939e8814d5c89 100644 (file)
@@ -1812,7 +1812,7 @@ ceph::bufferlist ProtocolV2::do_sweep_messages(
     INTERCEPT_FRAME(ceph::msgr::v2::Tag::KEEPALIVE2_ACK, bp_type_t::WRITE);
   }
 
-  if (require_ack && !num_msgs) {
+  if (require_ack && num_msgs == 0u) {
     auto ack_frame = AckFrame::Encode(conn.in_seq);
     bl.append(ack_frame.get_buffer(tx_frame_asm));
     INTERCEPT_FRAME(ceph::msgr::v2::Tag::ACK, bp_type_t::WRITE);