From: Kefu Chai Date: Thu, 18 Oct 2018 10:29:49 +0000 (+0800) Subject: osd: cast `whoami` to unsigned so it can be used as the seed for RNG X-Git-Tag: v12.2.10~41^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=refs%2Fpull%2F24659%2Fhead;p=ceph.git osd: cast `whoami` to unsigned so it can be used as the seed for RNG default_random_engine's result_type is `unsigned int`, so we need to pass an `unsigned int` as its seed. Fixes: http://tracker.ceph.com/issues/26890 Signed-off-by: Kefu Chai Conflicts: src/osd/OSD.cc: this breaks the build with clang. and in master we are not using std::default_random_engine for setting the scrub interval. so this change is not cherry-picked from master. --- diff --git a/src/osd/OSD.cc b/src/osd/OSD.cc index 042097bb35e2..e2d1a6db7a5e 100644 --- a/src/osd/OSD.cc +++ b/src/osd/OSD.cc @@ -2055,7 +2055,7 @@ double OSD::get_tick_interval() const { // vary +/- 5% to avoid scrub scheduling livelocks constexpr auto delta = 0.05; - std::default_random_engine rng{whoami}; + std::default_random_engine rng{static_cast(whoami)}; return (OSD_TICK_INTERVAL * std::uniform_real_distribution<>{1.0 - delta, 1.0 + delta}(rng)); }