Changeset: 89dcede8bc05 for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=89dcede8bc05
Modified Files:
monetdb5/extras/jaql/json_jaql.c
monetdb5/modules/atoms/str.c
Branch: default
Log Message:
Replace call to GDKfatal at end of function by returning an error.
This is to work around a problem with icc 11.1 on Linux which
complains about not returning a value when the function ends with a
call to a function that is declared to not return (such as GDKfatal).
diffs (153 lines):
diff --git a/monetdb5/extras/jaql/json_jaql.c b/monetdb5/extras/jaql/json_jaql.c
--- a/monetdb5/extras/jaql/json_jaql.c
+++ b/monetdb5/extras/jaql/json_jaql.c
@@ -617,6 +617,7 @@ strlen_json_value(jsonbat *jb, oid id)
BATiter bi;
oid v;
size_t ret = 0;
+ size_t l;
bi = bat_iterator(jb->kind);
@@ -654,7 +655,10 @@ strlen_json_value(jsonbat *jb, oid id)
bi = bat_iterator(elems);
ret += 2;
BATloop (elems, p, q) {
- ret += strlen_json_value(jb, *(oid
*)BUNtail(bi, p));
+ l = strlen_json_value(jb, *(oid *)BUNtail(bi,
p));
+ if (l == ~ (size_t) 0)
+ goto hashfnd_failed;
+ ret += l;
if (p < q - 1)
ret += 2;
}
@@ -674,7 +678,10 @@ strlen_json_value(jsonbat *jb, oid id)
BATloop (objects, p, q) {
BUNfndOID(n, ni, BUNtail(bi, p));
ret += 2 + strlen(BUNtail(ni, n)) + 2;
- ret += strlen_json_value(jb, *(oid
*)BUNtail(bi, p));
+ l = strlen_json_value(jb, *(oid *)BUNtail(bi,
p));
+ if (l == ~ (size_t) 0)
+ goto hashfnd_failed;
+ ret += l;
if (p < q - 1)
ret += 2;
}
@@ -686,7 +693,7 @@ strlen_json_value(jsonbat *jb, oid id)
return ret;
hashfnd_failed:
- GDKfatal("HASHfnd: hash build failed on %s.\n", BATgetId(bi.b));
+ return ~ (size_t) 0; /* indicate failure */
}
static void
@@ -831,6 +838,8 @@ JSONprint(int *ret, stream **s, int *kin
fsize = 4;
BATloop (elems, p, q) {
esize = strlen_json_value(&jb, *(oid *)BUNtail(bi, p));
+ if (esize == ~ (size_t) 0)
+ goto hashfnd_failed;
if (esize > 80)
break;
fsize += esize;
@@ -875,7 +884,7 @@ JSONprint(int *ret, stream **s, int *kin
*ret = 0;
return MAL_SUCCEED;
hashfnd_failed:
- GDKfatal("HASHfnd: hash build failed on %s.\n", BATgetId(bi.b));
+ throw(MAL, "json.print", "allocation failed");
}
str
@@ -1153,6 +1162,8 @@ json_copy_entry(BATiter bik, BATiter bis
x = *(oid *)BUNtail(bio, p);
z = json_copy_entry(bik, bis, bii, bid, bia,
bio, bin,
start, x, jb, jbr);
+ if (z == ~ (oid) 0)
+ goto hashfnd_failed;
BUNins(jbr->object, &w, &z, FALSE);
BUNfndOID(y, bin, &x);
BUNins(jbr->name, &z, BUNtail(bin, y), FALSE);
@@ -1175,7 +1186,7 @@ json_copy_entry(BATiter bik, BATiter bis
return w;
hashfnd_failed:
- GDKfatal("HASHfnd: hash build failed.\n");
+ return ~ (oid) 0;
}
str
@@ -1205,13 +1216,17 @@ JSONextract(int *rkind, int *rstring, in
/* initialise all bats */
jbr.kind = BATnew(TYPE_void, TYPE_bte, BATTINY);
- jbr.kind = BATseqbase(jbr.kind, *startoid);
jbr.string = BATnew(TYPE_oid, TYPE_str, BATTINY);
jbr.doble = BATnew(TYPE_oid, TYPE_dbl, BATTINY);
jbr.integer = BATnew(TYPE_oid, TYPE_lng, BATTINY);
jbr.name = BATnew(TYPE_oid, TYPE_str, BATTINY);
jbr.object = BATnew(TYPE_oid, TYPE_oid, BATTINY);
jbr.array = BATnew(TYPE_oid, TYPE_oid, BATTINY);
+ if (jbr.kind == NULL || jbr.string == NULL || jbr.doble == NULL ||
+ jbr.integer == NULL || jbr.name == NULL || jbr.object == NULL ||
+ jbr.array == NULL)
+ goto bailout;
+ jbr.kind = BATseqbase(jbr.kind, *startoid);
/* return all elems as the outermost array */
BUNappend(jbr.kind, "a", FALSE);
@@ -1221,6 +1236,8 @@ JSONextract(int *rkind, int *rstring, in
if (v != oid_nil) {
z = json_copy_entry(bik, bis, bii, bid, bia, bio, bin,
*startoid, v, &jb, &jbr);
+ if (z == ~ (oid) 0)
+ goto bailout;
BUNins(jbr.array, &w, &z, FALSE);
}
}
@@ -1243,6 +1260,23 @@ JSONextract(int *rkind, int *rstring, in
BBPkeepref(jbr.name->batCacheid);
*rname = jbr.name->batCacheid;
return MAL_SUCCEED;
+
+ bailout:
+ if (jbr.kind != NULL)
+ BBPunfix(jbr.kind->batCacheid);
+ if (jbr.string != NULL)
+ BBPunfix(jbr.string->batCacheid);
+ if (jbr.doble != NULL)
+ BBPunfix(jbr.doble->batCacheid);
+ if (jbr.integer != NULL)
+ BBPunfix(jbr.integer->batCacheid);
+ if (jbr.name != NULL)
+ BBPunfix(jbr.name->batCacheid);
+ if (jbr.object != NULL)
+ BBPunfix(jbr.object->batCacheid);
+ if (jbr.array != NULL)
+ BBPunfix(jbr.array->batCacheid);
+ throw(MAL, "???.???", "Allocation failed");
}
str
@@ -1622,7 +1656,7 @@ JSONunwrap(Client cntxt, MalBlkPtr mb, M
return MAL_SUCCEED;
hashfnd_failed:
- GDKfatal("HASHfnd: hash build failed.\n");
+ throw(MAL, "json.unwrap", "Allocation failed");
}
str
diff --git a/monetdb5/modules/atoms/str.c b/monetdb5/modules/atoms/str.c
--- a/monetdb5/modules/atoms/str.c
+++ b/monetdb5/modules/atoms/str.c
@@ -1577,7 +1577,7 @@ convertCase(BAT *from, BAT *to, str *res
*dst = 0;
return GDK_SUCCEED;
hashfnd_failed:
- GDKfatal("HASHfnd: hash build failed on %s.\n", BATgetId(fromi.b));
+ return GDK_FAIL;
}
int
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list