]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commit
include/intarith: enforce the same type for p2*() arguments 27318/head
authorIlya Dryomov <idryomov@gmail.com>
Tue, 26 Feb 2019 15:21:10 +0000 (16:21 +0100)
committerIgor Fedotov <ifedotov@suse.com>
Tue, 2 Apr 2019 15:47:51 +0000 (18:47 +0300)
commit3244c871f36ee22ee826a96f30e82a8d05c9170c
treee73c3f8e7abc3dbf783d5746aa08f5decf070f93
parent64524b5a8c4248c02a6a3740fd9e2c34e311699b
include/intarith: enforce the same type for p2*() arguments

x and align must be of the same width.  Otherwise the lack of
sign-extension can bite, e.g.:

  uint64_t x = 128000;
  uint32_t align = 32768;
  uint64_t res = p2roundup(x, align);
  // res = 18446744069414715392

While the templates added in commit c06b97b3d7e3 ("include: Add
templates along side macros in intarith") are technically correct,
P2*() macros weren't meant to be used with different types.  The
Solaris kernel (which is where they originated) has P2*_TYPED()
variants for that.

Signed-off-by: Ilya Dryomov <idryomov@gmail.com>
(cherry picked from commit d0293dd2d8c0327c9d4d6b826a966dd7b18ea318)

 Conflicts:
src/librbd/io/ImageRequest.cc
src/msg/async/frames_v2.h
src/os/bluestore/StupidAllocator.cc
src/auth/Crypto.cc
src/include/intarith.h
src/os/bluestore/BlueStore.cc
src/os/bluestore/StupidAllocator.cc
src/os/bluestore/fastbmap_allocator_impl.cc
src/os/bluestore/fastbmap_allocator_impl.h