Changeset: 1d2f6665bc2d for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=1d2f6665bc2d
Modified Files:
common/stream/stream.c
gdk/gdk_imprints.c
gdk/gdk_sample.c
gdk/gdk_system.c
monetdb5/mal/mal_function.c
monetdb5/modules/kernel/microbenchmark.c
monetdb5/modules/kernel/mmath.c
sql/backends/monet5/bam/bam_wrapper.c
sql/backends/monet5/sql.c
sql/backends/monet5/sql_scenario.c
tools/merovingian/client/monetdb.c
tools/merovingian/daemon/connections.c
tools/merovingian/daemon/discoveryrunner.c
tools/merovingian/daemon/forkmserver.c
tools/merovingian/daemon/merovingian.c
tools/merovingian/daemon/peering.c
tools/merovingian/daemon/proxy.c
Branch: default
Log Message:
Merge with Oct2014 branch.
diffs (truncated from 516 to 300 lines):
diff --git a/common/stream/stream.c b/common/stream/stream.c
--- a/common/stream/stream.c
+++ b/common/stream/stream.c
@@ -742,8 +742,9 @@ getFileSize(stream *s)
if (s->read == file_read) {
struct stat stb;
- fstat(fileno((FILE *) s->stream_data.p), &stb);
- return (size_t) stb.st_size;
+ if (fstat(fileno((FILE *) s->stream_data.p), &stb) == 0)
+ return (size_t) stb.st_size;
+ /* we shouldn't get here... */
}
return 0; /* unknown */
}
@@ -1690,11 +1691,11 @@ socket_read(stream *s, void *buf, size_t
{
ssize_t nr = 0, size = (ssize_t) (elmsize * cnt);
- if (s->errnr || size == 0)
+ if (s->errnr)
return -1;
-
if (size == 0)
return 0;
+
#ifdef _MSC_VER
/* recv only takes an int parameter, and read does not accept
* sockets */
diff --git a/gdk/gdk_imprints.c b/gdk/gdk_imprints.c
--- a/gdk/gdk_imprints.c
+++ b/gdk/gdk_imprints.c
@@ -932,8 +932,9 @@ IMPSremove(BAT *b)
if ((imprints = b->T->imprints) != NULL) {
b->T->imprints = NULL;
- HEAPdelete(imprints->imprints, BBP_physical(b->batCacheid),
- b->batCacheid > 0 ? "timprints" : "himprints");
+ if (HEAPdelete(imprints->imprints, BBP_physical(b->batCacheid),
+ b->batCacheid > 0 ? "timprints" : "himprints"))
+ IODEBUG THRprintf(GDKstdout, "#IMPSremove(%s): imprints
heap\n", BATgetId(b));
GDKfree(imprints->imprints);
GDKfree(imprints);
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/gdk/gdk_system.c b/gdk/gdk_system.c
--- a/gdk/gdk_system.c
+++ b/gdk/gdk_system.c
@@ -473,6 +473,28 @@ static struct posthread {
} *posthreads = NULL;
static pthread_mutex_t posthread_lock = PTHREAD_MUTEX_INITIALIZER;
+static struct posthread *
+find_posthread_locked(pthread_t tid)
+{
+ struct posthread *p;
+
+ for (p = posthreads; p; p = p->next)
+ if (p->tid == tid)
+ return p;
+ return NULL;
+}
+
+static struct posthread *
+find_posthread(pthread_t tid)
+{
+ struct posthread *p;
+
+ pthread_mutex_lock(&posthread_lock);
+ p = find_posthread_locked(tid);
+ pthread_mutex_unlock(&posthread_lock);
+ return p;
+}
+
static void
MT_thread_sigmask(sigset_t * new_mask, sigset_t * orig_mask)
{
@@ -483,18 +505,22 @@ MT_thread_sigmask(sigset_t * new_mask, s
#endif
static void
-rm_posthread(struct posthread *p, int lock)
+rm_posthread_locked(struct posthread *p)
{
struct posthread **pp;
- if (lock)
- pthread_mutex_lock(&posthread_lock);
for (pp = &posthreads; *pp && *pp != p; pp = &(*pp)->next)
;
if (*pp)
*pp = p->next;
- if (lock)
- pthread_mutex_unlock(&posthread_lock);
+}
+
+static void
+rm_posthread(struct posthread *p)
+{
+ pthread_mutex_lock(&posthread_lock);
+ rm_posthread_locked(p);
+ pthread_mutex_unlock(&posthread_lock);
}
static void
@@ -522,10 +548,14 @@ join_threads(void)
n = p->next;
if (p->exited) {
tid = p->tid;
- rm_posthread(p, 0);
pthread_mutex_unlock(&posthread_lock);
pthread_join(tid, NULL);
pthread_mutex_lock(&posthread_lock);
+ /* find the thread again, mostly to
+ * keep Coverity happy */
+ p = find_posthread_locked(tid);
+ assert(p != NULL);
+ rm_posthread_locked(p);
free(p);
waited = 1;
break;
@@ -578,7 +608,7 @@ MT_create_thread(MT_Id *t, void (*f) (vo
*t = (MT_Id) (((size_t) *newtp) + 1); /* use pthread-id + 1 */
#endif
} else if (p) {
- rm_posthread(p, 1);
+ rm_posthread(p);
free(p);
}
#ifdef HAVE_PTHREAD_SIGMASK
@@ -587,26 +617,16 @@ MT_create_thread(MT_Id *t, void (*f) (vo
return ret;
}
-static struct posthread *
-find_posthread(pthread_t tid)
-{
- struct posthread *p;
-
- pthread_mutex_lock(&posthread_lock);
- for (p = posthreads; p; p = p->next)
- if (p->tid == tid)
- break;
- pthread_mutex_unlock(&posthread_lock);
- return p;
-}
-
void
MT_exiting_thread(void)
{
struct posthread *p;
+ pthread_t tid = pthread_self();
- if ((p = find_posthread(pthread_self())) != NULL)
+ pthread_mutex_lock(&posthread_lock);
+ if ((p = find_posthread_locked(tid)) != NULL)
p->exited = 1;
+ pthread_mutex_unlock(&posthread_lock);
}
void
diff --git a/monetdb5/mal/mal_function.c b/monetdb5/mal/mal_function.c
--- a/monetdb5/mal/mal_function.c
+++ b/monetdb5/mal/mal_function.c
@@ -1009,7 +1009,7 @@ showFlowGraph(MalBlkPtr mb, MalStkPtr st
} else if (f != GDKout) {
if (!stethoscope ) {
MT_sleep_ms(4000); /* delay for stethoscope */
- mnstr_close(f);
+ close_stream(f);
}
}
}
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;
}
diff --git a/sql/backends/monet5/bam/bam_wrapper.c
b/sql/backends/monet5/bam/bam_wrapper.c
--- a/sql/backends/monet5/bam/bam_wrapper.c
+++ b/sql/backends/monet5/bam/bam_wrapper.c
@@ -942,11 +942,12 @@ process_header(bam_wrapper * bw)
rg_fields_found[11]);
/* if this point is reached, option
wasn't recognized */
- clear_bam_header_line(&hl);
- throw(MAL, "process_header",
+ msg = createException(MAL,
"process_header",
ERR_PROCESS_HEADER
"Unknown option '%s' found in
header tag RG",
bw->file_location,
hl.options[o].tag);
+ clear_bam_header_line(&hl);
+ return msg;
}
if (!rg_fields_found[0]) {
clear_bam_header_line(&hl);
diff --git a/sql/backends/monet5/sql.c b/sql/backends/monet5/sql.c
--- a/sql/backends/monet5/sql.c
+++ b/sql/backends/monet5/sql.c
@@ -2782,26 +2782,33 @@ mvc_import_table_wrap(Client cntxt, MalB
GDKfree(rsep);
throw(MAL, "sql.copy_from", MAL_MALLOC_FAIL);
}
- GDKstrFromStr(ssep = GDKmalloc(len + 1), *S, len);
+ GDKstrFromStr(ssep, *S, len);
len = 0;
}
/* convert UTF-8 encoded file name to the character set of our
* own locale before passing it on to the system call */
- if ((msg = STRcodeset(&cs)) != MAL_SUCCEED ||
- (msg = STRIconv(&filename, fname, &utf8, &cs)) != MAL_SUCCEED) {
+ if ((msg = STRcodeset(&cs)) != MAL_SUCCEED) {
GDKfree(tsep);
GDKfree(rsep);
GDKfree(ssep);
return msg;
}
-
+ msg = STRIconv(&filename, fname, &utf8, &cs);
GDKfree(cs);
+ if (msg != MAL_SUCCEED) {
+ GDKfree(tsep);
+ GDKfree(rsep);
+ GDKfree(ssep);
+ return msg;
+ }
+
len = strlen((char *) (*N));
if ((ns = GDKmalloc(len + 1)) == NULL) {
GDKfree(tsep);
GDKfree(rsep);
GDKfree(ssep);
+ GDKfree(filename);
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list