Changeset: 857195c27a27 for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=857195c27a27
Modified Files:
common/stream/stream.c
geom/lib/libgeom.h
geom/monetdb5/geom.c
monetdb5/mal/mal.h
monetdb5/modules/atoms/blob.h
Branch: Oct2014
Log Message:
Use incomplete array type at end of to-be-extended struct.
This way we can be sure that the compiler will not optimize away loops
over the array because they access data beyond the end of the declared
array (which would be undefined behavior).
diffs (71 lines):
diff --git a/common/stream/stream.c b/common/stream/stream.c
--- a/common/stream/stream.c
+++ b/common/stream/stream.c
@@ -3555,7 +3555,7 @@ bstream_destroy(bstream *s)
typedef struct {
stream *s;
size_t len, pos;
- char buf[1]; /* NOTE: buf extends beyond array for wbs->len
bytes */
+ char buf[]; /* NOTE: buf extends beyond array for wbs->len
bytes */
} wbs_stream;
static int
@@ -3657,7 +3657,7 @@ wbstream(stream *s, size_t buflen)
ns = create_stream(s->name);
if (ns == NULL)
return NULL;
- wbs = (wbs_stream *) malloc(sizeof(wbs_stream) + buflen - 1);
+ wbs = (wbs_stream *) malloc(sizeof(wbs_stream) + buflen);
if (wbs == NULL) {
destroy(ns);
return NULL;
diff --git a/geom/lib/libgeom.h b/geom/lib/libgeom.h
--- a/geom/lib/libgeom.h
+++ b/geom/lib/libgeom.h
@@ -106,7 +106,7 @@ libgeom_export const char *geom_type2str
typedef struct wkb {
int len;
- char data[1];
+ char data[];
} wkb;
typedef struct {
diff --git a/geom/monetdb5/geom.c b/geom/monetdb5/geom.c
--- a/geom/monetdb5/geom.c
+++ b/geom/monetdb5/geom.c
@@ -354,8 +354,8 @@ wkb_size(size_t len)
{
if (len == ~(size_t) 0)
len = 0;
- assert(sizeof(wkb) - 1 + len <= VAR_MAX);
- return (var_t) (sizeof(wkb) - 1 + len);
+ assert(sizeof(wkb) + len <= VAR_MAX);
+ return (var_t) (sizeof(wkb) + len);
}
/* TOSTR: print atom in a string. */
diff --git a/monetdb5/mal/mal.h b/monetdb5/mal/mal.h
--- a/monetdb5/mal/mal.h
+++ b/monetdb5/mal/mal.h
@@ -263,7 +263,7 @@ typedef struct MALSTK {
int pcup; /* saved pc upon a recursive all */
struct MALSTK *up; /* stack trace list */
struct MALBLK *blk; /* associated definition */
- ValRecord stk[1];
+ ValRecord stk[];
} MalStack, *MalStkPtr;
#endif /* _MAL_H*/
diff --git a/monetdb5/modules/atoms/blob.h b/monetdb5/modules/atoms/blob.h
--- a/monetdb5/modules/atoms/blob.h
+++ b/monetdb5/modules/atoms/blob.h
@@ -27,7 +27,7 @@
typedef struct blob {
size_t nitems;
- /*unsigned */ char data[1];
+ /*unsigned */ char data[];
} blob;
#define sqlblob blob
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list