Changeset: fee07304d5b2 for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=fee07304d5b2
Modified Files:
clients/Tests/exports.stable.out
gdk/gdk.h
gdk/gdk_bat.c
gdk/gdk_batop.c
gdk/gdk_private.h
gdk/gdk_search.h
gdk/gdk_utils.c
gdk/gdk_utils.h
monetdb5/extras/jaql/json_jaql.c
monetdb5/modules/atoms/str.c
Branch: default
Log Message:
Make sure GDKexit and GDKfatal never return, and tell compiler about it.
diffs (258 lines):
diff --git a/clients/Tests/exports.stable.out b/clients/Tests/exports.stable.out
--- a/clients/Tests/exports.stable.out
+++ b/clients/Tests/exports.stable.out
@@ -252,9 +252,9 @@ int GDKatomcnt;
int GDKcreatedir(const char *nme);
int GDKdebug;
int GDKerror(_In_z_ _Printf_format_string_ const char *format, ...)
__attribute__((__format__(__printf__, 1, 2)));
-void GDKexit(int status);
+void GDKexit(int status) __attribute__((__noreturn__));
int GDKexiting(void);
-int GDKfatal(_In_z_ _Printf_format_string_ const char *format, ...)
__attribute__((__format__(__printf__, 1, 2)));
+void GDKfatal(_In_z_ _Printf_format_string_ const char *format, ...)
__attribute__((__format__(__printf__, 1, 2))) __attribute__((__noreturn__));
void GDKfilepath(str path, const char *nme, const char *mode, const char *ext);
void GDKfree(void *blk);
char *GDKgetenv(const char *name);
diff --git a/gdk/gdk.h b/gdk/gdk.h
--- a/gdk/gdk.h
+++ b/gdk/gdk.h
@@ -2548,8 +2548,9 @@ gdk_export int GDKerror(_In_z_ _Printf_f
__attribute__((__format__(__printf__, 1, 2)));
gdk_export int GDKsyserror(_In_z_ _Printf_format_string_ const char *format,
...)
__attribute__((__format__(__printf__, 1, 2)));
-gdk_export int GDKfatal(_In_z_ _Printf_format_string_ const char *format, ...)
- __attribute__((__format__(__printf__, 1, 2)));
+gdk_export void GDKfatal(_In_z_ _Printf_format_string_ const char *format, ...)
+ __attribute__((__format__(__printf__, 1, 2)))
+ __attribute__((__noreturn__));
/*
* @
diff --git a/gdk/gdk_bat.c b/gdk/gdk_bat.c
--- a/gdk/gdk_bat.c
+++ b/gdk/gdk_bat.c
@@ -1735,6 +1735,20 @@ void_replace_bat(BAT *b, BAT *u, bit for
* known and a hash index is available, one should use the inline
* functions to speed-up processing.
*/
+static BUN
+slowfnd(BAT *b, const void *v)
+{
+ BATiter bi = bat_iterator(b);
+ BUN p, q;
+ int (*cmp)(const void *, const void *) = BATatoms[b->htype].atomCmp;
+
+ BATloop(b, p, q) {
+ if ((*cmp)(v, BUNhead(bi, p)) == 0)
+ return p;
+ }
+ return BUN_NONE;
+}
+
BUN
BUNfnd(BAT *b, const void *v)
{
@@ -1774,6 +1788,9 @@ BUNfnd(BAT *b, const void *v)
HASHfnd(r, bi, v);
}
return r;
+ hashfnd_failed:
+ /* can't build hash table, search the slow way */
+ return slowfnd(b, v);
}
#define usemirror() \
diff --git a/gdk/gdk_batop.c b/gdk/gdk_batop.c
--- a/gdk/gdk_batop.c
+++ b/gdk/gdk_batop.c
@@ -1686,7 +1686,8 @@ BATmark_grp(BAT *b, BAT *g, oid *s)
if (gc)
BBPreclaim(gc);
return bn;
- bunins_failed:
+ bunins_failed:
+ hashfnd_failed:
if (gc)
BBPreclaim(gc);
if (bn)
diff --git a/gdk/gdk_private.h b/gdk/gdk_private.h
--- a/gdk/gdk_private.h
+++ b/gdk/gdk_private.h
@@ -94,8 +94,6 @@ int HEAPsave(Heap *h, const char *nme, c
int HEAPshrink(Heap *h, size_t size);
int HEAPwarm(Heap *h);
oid MAXoid(BAT *i);
-void MT_global_exit(int status)
- __attribute__((__noreturn__));
void MT_init_posix(void);
void *MT_mremap(const char *path, int mode, void *old_address, size_t
old_size, size_t *new_size);
int MT_msync(void *p, size_t len, int mode);
diff --git a/gdk/gdk_search.h b/gdk/gdk_search.h
--- a/gdk/gdk_search.h
+++ b/gdk/gdk_search.h
@@ -207,49 +207,49 @@ gdk_export BUN HASHlist(Hash *h, BUN i);
do { \
BUN _i; \
(x) = BUN_NONE; \
- if ((y).b->H->hash || BAThash((y).b, 0) || \
- GDKfatal("HASHfnd_str: hash build failed on %s.\n", \
- BATgetId((y).b))) \
+ if ((y).b->H->hash || BAThash((y).b, 0)) { \
HASHloop_str((y), (y).b->H->hash, _i, (z)) { \
(x) = _i; \
break; \
} \
+ } else \
+ goto hashfnd_failed; \
} while (0)
#define HASHfnd_str_hv(x,y,z) \
do { \
BUN _i; \
(x) = BUN_NONE; \
- if ((y).b->H->hash || BAThash((y).b, 0) || \
- GDKfatal("HASHfnd_str_hv: hash build failed on %s.\n", \
- BATgetId((y).b))) \
+ if ((y).b->H->hash || BAThash((y).b, 0)) { \
HASHloop_str_hv((y), (y).b->H->hash, _i, (z)) { \
(x) = _i; \
break; \
} \
+ } else \
+ goto hashfnd_failed; \
} while (0)
#define HASHfnd(x,y,z) \
do { \
BUN _i; \
- (x) = BUN_NONE; \
- if ((y).b->H->hash || BAThash((y).b, 0) || \
- GDKfatal("HASHfnd: hash build failed on %s.\n", \
- BATgetId((y).b))) \
+ (x) = BUN_NONE; \
+ if ((y).b->H->hash || BAThash((y).b, 0)) { \
HASHloop((y), (y).b->H->hash, _i, (z)) { \
(x) = _i; \
break; \
} \
+ } else \
+ goto hashfnd_failed; \
} while (0)
#define HASHfnd_TYPE(x,y,z,TYPE) \
do { \
BUN _i; \
- (x) = BUN_NONE; \
- if ((y).b->H->hash || BAThash((y).b, 0) || \
- GDKfatal("HASHfnd_" #TYPE ": hash build failed on %s.\n", \
- BATgetId((y).b))) \
+ (x) = BUN_NONE; \
+ if ((y).b->H->hash || BAThash((y).b, 0)) { \
HASHloop_##TYPE((y), (y).b->H->hash, _i, (z)) { \
(x) = _i; \
break; \
} \
+ } else \
+ goto hashfnd_failed; \
} while (0)
#define HASHfnd_bte(x,y,z) HASHfnd_TYPE(x,y,z,bte)
#define HASHfnd_sht(x,y,z) HASHfnd_TYPE(x,y,z,sht)
diff --git a/gdk/gdk_utils.c b/gdk/gdk_utils.c
--- a/gdk/gdk_utils.c
+++ b/gdk/gdk_utils.c
@@ -1185,6 +1185,7 @@ GDKexit(int status)
#endif
MT_global_exit(status);
}
+ MT_exit_thread(-1);
}
/*
@@ -1518,7 +1519,7 @@ GDKclrerr(void)
}
/* coverity[+kill] */
-int
+void
GDKfatal(const char *format, ...)
{
char message[GDKERRLEN];
@@ -1558,7 +1559,6 @@ GDKfatal(const char *format, ...)
GDKexit(1);
#endif
}
- return -1;
}
diff --git a/gdk/gdk_utils.h b/gdk/gdk_utils.h
--- a/gdk/gdk_utils.h
+++ b/gdk/gdk_utils.h
@@ -97,7 +97,8 @@ gdk_export int GDKinit(opt *set, int set
*/
gdk_export int GDKnr_threads;
-gdk_export void GDKexit(int status);
+gdk_export void GDKexit(int status)
+ __attribute__((__noreturn__));
gdk_export int GDKexiting(void);
gdk_export const char *GDKversion(void);
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
@@ -685,6 +685,8 @@ strlen_json_value(jsonbat *jb, oid id)
}
return ret;
+ hashfnd_failed:
+ GDKfatal("HASHfnd: hash build failed on %s.\n", BATgetId(bi.b));
}
static void
@@ -795,6 +797,9 @@ print_json_value(jsonbat *jb, stream *s,
break;
}
}
+ return;
+ hashfnd_failed:
+ GDKfatal("HASHfnd: hash build failed on %s.\n", BATgetId(bi.b));
}
str
@@ -869,6 +874,8 @@ 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));
}
str
@@ -1167,6 +1174,8 @@ json_copy_entry(BATiter bik, BATiter bis
}
return w;
+ hashfnd_failed:
+ GDKfatal("HASHfnd: hash build failed.\n");
}
str
@@ -1612,6 +1621,8 @@ JSONunwrap(Client cntxt, MalBlkPtr mb, M
}
return MAL_SUCCEED;
+ hashfnd_failed:
+ GDKfatal("HASHfnd: hash build failed.\n");
}
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
@@ -1576,6 +1576,8 @@ 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));
}
int
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list