]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
hobject: better left-shift an unsigned
authorKefu Chai <kchai@redhat.com>
Wed, 23 Nov 2016 06:08:10 +0000 (14:08 +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/common/hobject.cc

index dc76e8b552434084713c1fe809e20eef91c3307c..e4586594246e39c447e6b0bacbbb6990b4dbaba7 100644 (file)
@@ -45,7 +45,7 @@ set<string> hobject_t::get_prefixes(
     for (set<uint32_t>::iterator j = from.begin();
         j != from.end();
         ++j) {
-      to.insert(*j | (1 << i));
+      to.insert(*j | (1U << i));
       to.insert(*j);
     }
     to.swap(from);