summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPatrick McLean <patrick.mclean@sony.com>2019-11-08 15:25:23 -0800
committerPatrick McLean <chutzpah@gentoo.org>2019-11-08 15:25:23 -0800
commit8c9da308d9c8ee174b4627b75bbfc30bc91c6f65 (patch)
tree6024fd0d036a8cb4d5181f50cc1666778635900e /sys-cluster/ceph/files/ceph-14.2.4-undefined-behaviour.patch
parentsys-kernel/gentoo-sources: x86 stable (bug #699556) (diff)
downloadgentoo-8c9da308d9c8ee174b4627b75bbfc30bc91c6f65.tar.gz
gentoo-8c9da308d9c8ee174b4627b75bbfc30bc91c6f65.tar.bz2
gentoo-8c9da308d9c8ee174b4627b75bbfc30bc91c6f65.zip
sys-cluster/ceph: revbump to 14.2.4-r1, misc fixes
Copyright: Sony Interactive Entertainment Inc. Package-Manager: Portage-2.3.78, Repoman-2.3.17 Signed-off-by: Patrick McLean <chutzpah@gentoo.org>
Diffstat (limited to 'sys-cluster/ceph/files/ceph-14.2.4-undefined-behaviour.patch')
-rw-r--r--sys-cluster/ceph/files/ceph-14.2.4-undefined-behaviour.patch76
1 files changed, 76 insertions, 0 deletions
diff --git a/sys-cluster/ceph/files/ceph-14.2.4-undefined-behaviour.patch b/sys-cluster/ceph/files/ceph-14.2.4-undefined-behaviour.patch
new file mode 100644
index 000000000000..99249fb01a0c
--- /dev/null
+++ b/sys-cluster/ceph/files/ceph-14.2.4-undefined-behaviour.patch
@@ -0,0 +1,76 @@
+diff --git a/src/include/blobhash.h b/src/include/blobhash.h
+index 597884e4c9..97f2065ce3 100644
+--- a/src/include/blobhash.h
++++ b/src/include/blobhash.h
+@@ -14,33 +14,40 @@
+ #ifndef CEPH_BLOBHASH_H
+ #define CEPH_BLOBHASH_H
+
++#include <cstdint>
+ #include "hash.h"
+
+-/*
+-- this is to make some of the STL types work with 64 bit values, string hash keys, etc.
+-- added when i was using an old STL.. maybe try taking these out and see if things
+- compile now?
+-*/
+-
+ class blobhash {
+ public:
+- uint32_t operator()(const char *p, unsigned len) {
+- static rjhash<uint32_t> H;
+- uint32_t acc = 0;
++ uint32_t operator()(const void* p, size_t len) {
++ static rjhash<std::uint32_t> H;
++ std::uint32_t acc = 0;
++ auto buf = static_cast<const unsigned char*>(p);
+ while (len >= sizeof(acc)) {
+- acc ^= *(uint32_t*)p;
+- p += sizeof(uint32_t);
+- len -= sizeof(uint32_t);
++ acc ^= unaligned_load(buf);
++ buf += sizeof(std::uint32_t);
++ len -= sizeof(std::uint32_t);
+ }
+- int sh = 0;
+- while (len) {
+- acc ^= (uint32_t)*p << sh;
+- sh += 8;
+- len--;
+- p++;
++ // handle the last few bytes of p[-(len % 4):]
++ switch (len) {
++ case 3:
++ acc ^= buf[2] << 16;
++ [[fallthrough]];
++ case 2:
++ acc ^= buf[1] << 8;
++ [[fallthrough]];
++ case 1:
++ acc ^= buf[0];
++ [[fallthrough]];
+ }
+ return H(acc);
+ }
++private:
++ static inline std::uint32_t unaligned_load(const unsigned char* p) {
++ std::uint32_t result;
++ __builtin_memcpy(&result, p, sizeof(result));
++ return result;
++ }
+ };
+
+
+diff --git a/src/msg/msg_types.h b/src/msg/msg_types.h
+index b6952ca498..576b7d6b8a 100644
+--- a/src/msg/msg_types.h
++++ b/src/msg/msg_types.h
+@@ -566,7 +566,7 @@ namespace std {
+ size_t operator()( const entity_addr_t& x ) const
+ {
+ static blobhash H;
+- return H((const char*)&x, sizeof(x));
++ return H(&x, sizeof(x));
+ }
+ };
+ } // namespace std