]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
osd_types: pg_t::is_split(): use unsigned for bits operations
authorKefu Chai <kchai@redhat.com>
Wed, 23 Nov 2016 05:58:08 +0000 (13:58 +0800)
committerKefu Chai <kchai@redhat.com>
Wed, 23 Nov 2016 07:00:30 +0000 (15:00 +0800)
this silences the warning of

The result of the '<<' expression is undefined

quote from n3337, ยง5.8 expr.shift:

If E1 has an unsigned type, the value ... (is deterministic)...
Otherwise, if E1 has a signed type and non-negative value, and E1 x 2^E2
is representable in the result type, then that is the resulting value;
otherwise, the behavior is undefined.

Signed-off-by: Kefu Chai <kchai@redhat.com>
src/osd/osd_types.cc

index b6fdc7fbe62887624e3f13f94a501a056cc1b083..93586843e5340d32ead72e07f9865a56e851bbc4 100644 (file)
@@ -476,10 +476,10 @@ bool pg_t::is_split(unsigned old_pg_num, unsigned new_pg_num, set<pg_t> *childre
 
   bool split = false;
   if (true) {
-    int old_bits = cbits(old_pg_num);
-    int old_mask = (1 << old_bits) - 1;
-    for (int n = 1; ; n++) {
-      int next_bit = (n << (old_bits-1));
+    unsigned old_bits = cbits(old_pg_num);
+    unsigned old_mask = (1 << old_bits) - 1;
+    for (unsigned n = 1; ; n++) {
+      unsigned next_bit = (n << (old_bits-1));
       unsigned s = next_bit | m_seed;
 
       if (s < old_pg_num || s == m_seed)