Changeset: faa34f31c8b4 for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=faa34f31c8b4
Modified Files:
        gdk/gdk_sample.c
        monetdb5/modules/kernel/microbenchmark.c
        monetdb5/modules/kernel/mmath.c
Branch: Oct2014
Log Message:

Hide calls to rand() from static analysis.
Coverity doesn't like it if we call rand() since it is
cryptographically unsafe.


diffs (72 lines):

diff --git a/gdk/gdk_sample.c b/gdk/gdk_sample.c
--- a/gdk/gdk_sample.c
+++ b/gdk/gdk_sample.c
@@ -40,7 +40,12 @@
 
 #undef BATsample
 
+#ifdef STATIC_CODE_ANALYSIS
+#define DRAND (0.5)
+#else
 #define DRAND ((double)rand()/(double)RAND_MAX)
+#endif
+
 
 /* this is a straightforward implementation of a binary tree */
 struct oidtreenode {
diff --git a/monetdb5/modules/kernel/microbenchmark.c 
b/monetdb5/modules/kernel/microbenchmark.c
--- a/monetdb5/modules/kernel/microbenchmark.c
+++ b/monetdb5/modules/kernel/microbenchmark.c
@@ -32,6 +32,10 @@
 #include <mal_exception.h>
 #include "microbenchmark.h"
 
+#ifdef STATIC_CODE_ANALYSIS
+#define rand()         0
+#endif
+
 static int
 BATrandom(BAT **bn, oid *base, wrd *size, int *domain, int seed)
 {
diff --git a/monetdb5/modules/kernel/mmath.c b/monetdb5/modules/kernel/mmath.c
--- a/monetdb5/modules/kernel/mmath.c
+++ b/monetdb5/modules/kernel/mmath.c
@@ -275,8 +275,11 @@ MATHunary_FINITE(bit *res, const dbl *a)
 str
 MATHrandint(int *res)
 {
-       /* coverity[dont_call] */
+#ifdef STATIC_CODE_ANALYSIS
+       *res = 0;
+#else
        *res = rand();
+#endif
        return MAL_SUCCEED;
 }
 
@@ -284,8 +287,11 @@ str
 MATHrandintarg(int *res, const int *dummy)
 {
        (void) dummy;
-       /* coverity[dont_call] */
+#ifdef STATIC_CODE_ANALYSIS
+       *res = 0;
+#else
        *res = rand();
+#endif
        return MAL_SUCCEED;
 }
 
@@ -301,8 +307,11 @@ str
 MATHsqlrandint(int *res, const int *seed)
 {
        srand(*seed);
-       /* coverity[dont_call] */
+#ifdef STATIC_CODE_ANALYSIS
+       *res = 0;
+#else
        *res = rand();
+#endif
        return MAL_SUCCEED;
 }
 
_______________________________________________
checkin-list mailing list
checkin-list@monetdb.org
https://www.monetdb.org/mailman/listinfo/checkin-list

Reply via email to