]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commit
include/intarith: enforce the same type for p2*() arguments 26660/head
authorIlya Dryomov <idryomov@gmail.com>
Tue, 26 Feb 2019 15:21:10 +0000 (16:21 +0100)
committerIlya Dryomov <idryomov@gmail.com>
Tue, 5 Mar 2019 21:31:03 +0000 (22:31 +0100)
commitd0293dd2d8c0327c9d4d6b826a966dd7b18ea318
tree06053de9bb5f3cc2225c79b6f99498144dae7f39
parente030ba465def5b6d3a0d820b0de42e39caa6a983
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>
src/auth/Crypto.cc
src/include/intarith.h
src/librbd/io/ImageRequest.cc
src/msg/async/frames_v2.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