Changeset: 2ef9b3adedb6 for MonetDB URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=2ef9b3adedb6 Modified Files: clients/mapiclient/mclient.c sql/backends/monet5/sql.c sql/backends/monet5/sql_gencode.c sql/backends/monet5/sql_scenario.c Branch: Jan2014 Log Message:
Handling more Coverity issues. diffs (206 lines): diff --git a/clients/mapiclient/mclient.c b/clients/mapiclient/mclient.c --- a/clients/mapiclient/mclient.c +++ b/clients/mapiclient/mclient.c @@ -1636,7 +1636,7 @@ doRequest(Mapi mid, const char *buf) return 0; } -#define CHECK_RESULT(mid, hdl, buf, break_or_continue) \ +#define CHECK_RESULT(mid, hdl, buf, break_or_continue,freebuf) \ switch (mapi_error(mid)) { \ case MOK: \ /* everything A OK */ \ @@ -1671,7 +1671,7 @@ doRequest(Mapi mid, const char *buf) mapi_explain(mid, stderr); \ errseen = 1; \ timerEnd(); \ - free(buf); \ + if( freebuf) free(freebuf); \ return 1; \ } @@ -1718,7 +1718,7 @@ doFileBulk(Mapi mid, FILE *fp) if (hdl == NULL) { hdl = mapi_query_prep(mid); - CHECK_RESULT(mid, hdl, buf, continue); + CHECK_RESULT(mid, hdl, buf, continue, buf); } if (first && @@ -1732,7 +1732,7 @@ doFileBulk(Mapi mid, FILE *fp) assert(hdl != NULL); mapi_query_part(hdl, buf + skip, length - skip); - CHECK_RESULT(mid, hdl, buf + skip, continue); + CHECK_RESULT(mid, hdl, buf + skip, continue, buf); /* make sure there is a newline in the buffer */ if (strchr(buf + skip, '\n') == NULL) @@ -1751,14 +1751,14 @@ doFileBulk(Mapi mid, FILE *fp) (length > 0 || mapi_query_done(hdl) == MMORE)) continue; /* get more data */ - CHECK_RESULT(mid, hdl, buf + skip, continue); + CHECK_RESULT(mid, hdl, buf + skip, continue, buf); rc = format_result(mid, hdl, 0); if (rc == MMORE && (length > 0 || mapi_query_done(hdl) != MOK)) continue; /* get more data */ - CHECK_RESULT(mid, hdl, buf + skip, continue); + CHECK_RESULT(mid, hdl, buf + skip, continue, buf); mapi_close_handle(hdl); hdl = NULL; @@ -2314,7 +2314,7 @@ doFile(Mapi mid, const char *file, int u "" : "AND \"system\" = false")); hdl = mapi_query(mid, q); - CHECK_RESULT(mid, hdl, buf, continue); + CHECK_RESULT(mid, hdl, buf, continue, buf); while (fetch_row(hdl) == 5) { name = mapi_fetch_field(hdl, 0); type = mapi_fetch_field(hdl, 1); @@ -2502,7 +2502,7 @@ doFile(Mapi mid, const char *file, int u if (hdl == NULL) { timerStart(); hdl = mapi_query_prep(mid); - CHECK_RESULT(mid, hdl, buf, continue); + CHECK_RESULT(mid, hdl, buf, continue, buf); } else timerResume(); @@ -2511,7 +2511,7 @@ doFile(Mapi mid, const char *file, int u if (length > 0) { SQLsetSpecial(line); mapi_query_part(hdl, line, length); - CHECK_RESULT(mid, hdl, buf, continue); + CHECK_RESULT(mid, hdl, buf, continue, buf); } /* If the server wants more but we're at the @@ -2529,7 +2529,7 @@ doFile(Mapi mid, const char *file, int u continue; /* done */ } } - CHECK_RESULT(mid, hdl, buf, continue); + CHECK_RESULT(mid, hdl, buf, continue, buf); if (mapi_get_querytype(hdl) == Q_PREPARE) { prepno = mapi_get_tableid(hdl); @@ -2541,7 +2541,7 @@ doFile(Mapi mid, const char *file, int u if (rc == MMORE && (line != NULL || mapi_query_done(hdl) != MOK)) continue; /* get more data */ - CHECK_RESULT(mid, hdl, buf, continue); + CHECK_RESULT(mid, hdl, buf, continue, buf); timerEnd(); mapi_close_handle(hdl); 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 @@ -367,8 +367,11 @@ str SQLshutdown_wrap(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr pci) { str answ = *(str *) getArgReference(stk, pci, 0); - - CLTshutdown(cntxt, mb, stk, pci); + str msg; + + msg =CLTshutdown(cntxt, mb, stk, pci); + if( msg) + GDKfree(msg); // administer the shutdown mnstr_printf(GDKstdout, "#%s\n", answ); @@ -4082,7 +4085,7 @@ SQLvacuum(Client cntxt, MalBlkPtr mb, Ma sql_table *t; sql_column *c; mvc *m = NULL; - str msg; + str msg= MAL_SUCCEED; BAT *b, *del; node *o; int ordered = 0; @@ -4124,12 +4127,12 @@ SQLvacuum(Client cntxt, MalBlkPtr mb, Ma /* now decide on the algorithm */ if (ordered) { if (BATcount(del) > cnt / 20) - SQLshrink(cntxt, mb, stk, pci); + msg = SQLshrink(cntxt, mb, stk, pci); } else - SQLreuse(cntxt, mb, stk, pci); + msg = SQLreuse(cntxt, mb, stk, pci); BBPreleaseref(del->batCacheid); - return MAL_SUCCEED; + return msg; } /* diff --git a/sql/backends/monet5/sql_gencode.c b/sql/backends/monet5/sql_gencode.c --- a/sql/backends/monet5/sql_gencode.c +++ b/sql/backends/monet5/sql_gencode.c @@ -94,10 +94,13 @@ static int argumentZero(MalBlkPtr mb, int tpe) { ValRecord cst; + str msg; cst.vtype = TYPE_int; cst.val.ival = 0; - convertConstant(tpe, &cst); + msg = convertConstant(tpe, &cst); + if( msg) + GDKfree(msg); // will not be called return defConstant(mb, tpe, &cst); } diff --git a/sql/backends/monet5/sql_scenario.c b/sql/backends/monet5/sql_scenario.c --- a/sql/backends/monet5/sql_scenario.c +++ b/sql/backends/monet5/sql_scenario.c @@ -2297,7 +2297,7 @@ SQLengineIntern(Client c, backend *be) msg = (str) runMAL(c, c->curprg->def, 0, 0); } - cleanup_engine: +cleanup_engine: if (m->type == Q_SCHEMA) qc_clean(m->qc); if (msg) { @@ -2308,7 +2308,9 @@ SQLengineIntern(Client c, backend *be) be->language = oldlang; assert(c->glb == 0 || c->glb == oldglb); /* detect leak */ c->glb = oldglb; - return SQLrecompile(c, be); + if ( msg) + GDKfree(msg); + return SQLrecompile(c, be); // retry compilation } else { /* don't print exception decoration, just the message */ char *n = NULL; @@ -2330,7 +2332,7 @@ SQLengineIntern(Client c, backend *be) if (m->type != Q_SCHEMA && be->q && msg) { qc_delete(m->qc, be->q); } else if (m->type != Q_SCHEMA && be->q && mb && varGetProp(mb, getArg(p = getInstrPtr(mb, 0), 0), runonceProp)) { - SQLCacheRemove(c, getFunctionId(p)); + msg = SQLCacheRemove(c, getFunctionId(p)); qc_delete(be->mvc->qc, be->q); ///* this should invalidate any match */ //be->q->key= -1; @@ -2358,8 +2360,11 @@ SQLrecompile(Client c, backend *be) mvc *m = be->mvc; int oldvtop = c->curprg->def->vtop; int oldstop = c->curprg->def->stop; + str msg; - SQLCacheRemove(c, be->q->name); + msg = SQLCacheRemove(c, be->q->name); + if( msg ) + GDKfree(msg); s = sql_relation2stmt(m, be->q->rel); be->q->code = (backend_code) backend_dumpproc(be, c, be->q, s); be->q->stk = 0; _______________________________________________ checkin-list mailing list checkin-list@monetdb.org https://www.monetdb.org/mailman/listinfo/checkin-list