wip sandbox/lstelmach/master
authorŁukasz Stelmach <l.stelmach@samsung.com>
Wed, 31 May 2017 11:26:39 +0000 (13:26 +0200)
committerŁukasz Stelmach <l.stelmach@samsung.com>
Fri, 9 Jun 2017 15:41:06 +0000 (17:41 +0200)
Change-Id: I44da8f5ff2419e1555c7451404e6fb4f0a3d0f2d
Signed-off-by: Łukasz Stelmach <l.stelmach@samsung.com>
src/core/database.c
src/util/common.h

index 5d06143b2bf7ffb1495ae55804875f6660eed4b3..3cd6eee7a514b7f39947367352b53dad4f78f9c3 100644 (file)
@@ -193,6 +193,9 @@ int database_new_oid(bson_oid_t *oid)
        assert(oid != NULL);
 
        sd_id128_randomize(&uuid);
+
+       BUILD_BUG_ON(sizeof(bson_oid_t) > sizeof(sd_id128_t));
        memcpy(oid, uuid.bytes, sizeof(*oid));
+
        return 0;
 }
index a17581e4375957b8904b808318118c9ab5481b2a..bd3bcf0abd38d6d554230496593f346552655d6b 100644 (file)
@@ -30,6 +30,8 @@
                                                         o.ints[1] == 0 && \
                                                         o.ints[2] == 0)
 
+#define BUILD_BUG_ON(condition) ((void)sizeof(char[1 - 2*!!(condition)]))
+
 #ifndef offsetof
 #define offsetof(type, member)  __builtin_offsetof(type, member)
 #endif /* offsetof */