summaryrefslogtreecommitdiff
path: root/slideshow
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2014-10-03 17:12:23 +0100
committerCaolán McNamara <caolanm@redhat.com>2014-10-06 14:13:27 +0100
commit8f436d3de7e99268a8862664d2cb2574231c3b18 (patch)
tree0a07dd3cecbd7bc5b0293006bb8691e33c5cca75 /slideshow
parente5ab3685550cf35c3eb9cb47530044f2d86433d5 (diff)
use comphelper::rng::uniform_*_distribution everywhere
and automatically seed from time on first use coverity#1242393 Don't call rand coverity#1242404 Don't call rand coverity#1242410 Don't call rand and additionally allow 0xFF as a value coverity#1242409 Don't call rand coverity#1242399 Don't call rand coverity#1242372 Don't call rand coverity#1242377 Don't call rand coverity#1242378 Don't call rand coverity#1242379 Don't call rand coverity#1242382 Don't call rand coverity#1242383 Don't call rand coverity#1242402 Don't call rand coverity#1242397 Don't call rand coverity#1242390 Don't call rand coverity#1242389 Don't call rand coverity#1242388 Don't call rand coverity#1242386 Don't call rand coverity#1242384 Don't call rand coverity#1242394 Don't call rand Change-Id: I241feab9cb370e091fd6ccaba2af941eb95bc7cf
Diffstat (limited to 'slideshow')
-rw-r--r--slideshow/source/engine/OGLTrans/generic/OGLTrans_TransitionImpl.cxx4
-rw-r--r--slideshow/source/inc/tools.hxx5
2 files changed, 5 insertions, 4 deletions
diff --git a/slideshow/source/engine/OGLTrans/generic/OGLTrans_TransitionImpl.cxx b/slideshow/source/engine/OGLTrans/generic/OGLTrans_TransitionImpl.cxx
index 86d11bf58c9b..ce78ab0c40ec 100644
--- a/slideshow/source/engine/OGLTrans/generic/OGLTrans_TransitionImpl.cxx
+++ b/slideshow/source/engine/OGLTrans/generic/OGLTrans_TransitionImpl.cxx
@@ -32,6 +32,8 @@
#include <utility>
#include <boost/make_shared.hpp>
+#include <boost/math/special_functions/next.hpp>
+#include <comphelper/random.hxx>
#include "OGLTrans_TransitionImpl.hxx"
#include <math.h>
@@ -674,7 +676,7 @@ boost::shared_ptr<OGLTransitionImpl> makeRochade()
inline double randFromNeg1to1()
{
- return ( ( static_cast<double>( rand() ) / static_cast<double>( RAND_MAX ) ) * 2.0 ) - 1.0;
+ return comphelper::rng::uniform_real_distribution(-1.0, boost::math::nextafter(1.0, DBL_MAX));
}
// TODO(Q3): extract to basegfx
diff --git a/slideshow/source/inc/tools.hxx b/slideshow/source/inc/tools.hxx
index 4e8037e3f3d3..682530f3bbc0 100644
--- a/slideshow/source/inc/tools.hxx
+++ b/slideshow/source/inc/tools.hxx
@@ -26,7 +26,7 @@
#include <com/sun/star/animations/XAnimationNode.hpp>
#include <com/sun/star/container/XEnumerationAccess.hpp>
#include <com/sun/star/container/XEnumeration.hpp>
-
+#include <comphelper/random.hxx>
#include <vector>
#include <cppcanvas/color.hxx>
@@ -293,8 +293,7 @@ namespace slideshow
/// Gets a random ordinal [0,n)
inline ::std::size_t getRandomOrdinal( const ::std::size_t n )
{
- return static_cast< ::std::size_t >(
- double(n) * rand() / (RAND_MAX + 1.0) );
+ return comphelper::rng::uniform_int_distribution(static_cast<size_t>(0), n-1);
}
/// To work around ternary operator in initializer lists