Changeset: 879c875f8359 for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=879c875f8359
Modified Files:
monetdb5/mal/mal_interpreter.c
sql/common/sql_keyword.c
Branch: Jun2016
Log Message:
Fix some cases of undefined behavior according to the C standard.
diffs (52 lines):
diff --git a/monetdb5/mal/mal_interpreter.c b/monetdb5/mal/mal_interpreter.c
--- a/monetdb5/mal/mal_interpreter.c
+++ b/monetdb5/mal/mal_interpreter.c
@@ -844,9 +844,10 @@ str runMALsequence(Client cntxt, MalBlkP
}
if (garbage[i] >= 0) {
PARDEBUG
mnstr_printf(GDKstdout, "#GC pc=%d bid=%d %s done\n", stkpc, bid,
getVarName(mb, garbage[i]));
- bid =
abs(stk->stk[garbage[i]].val.bval);
+ bid =
stk->stk[garbage[i]].val.bval;
stk->stk[garbage[i]].val.bval = bat_nil;
- BBPdecref(bid,
TRUE);
+ if (bid !=
bat_nil)
+
BBPdecref(abs(bid), TRUE);
}
} else if (i < pci->retc &&
0 <
stk->stk[a].vtype &&
@@ -1394,12 +1395,13 @@ void garbageElement(Client cntxt, ValPtr
* allowed during the execution of a GDK operation.
* All references should be logical.
*/
- bat bid = abs(v->val.bval);
+ bat bid = v->val.bval;
/* printf("garbage collecting: %d lrefs=%d refs=%d\n",
bid, BBP_lrefs(bid),BBP_refs(bid));*/
v->val.bval = bat_nil;
if (bid == bat_nil)
return;
+ bid = abs(bid);
if (!BBP_lrefs(bid))
return;
BBPdecref(bid, TRUE);
diff --git a/sql/common/sql_keyword.c b/sql/common/sql_keyword.c
--- a/sql/common/sql_keyword.c
+++ b/sql/common/sql_keyword.c
@@ -21,7 +21,7 @@ static int
keyword_key(char *k, int *l)
{
char *s = k;
- int h = 1;
+ unsigned int h = 1;
while (*k) {
h <<= 5;
@@ -31,7 +31,7 @@ keyword_key(char *k, int *l)
*l = (int) (k - s);
h <<= 4;
h += *l;
- return (h < 0) ? -h : h;
+ return (int) ((h & 0x80000000) ? ~h + 1 : h);
}
void
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list