From 8b558996d6edf85013452b1751ea12e5bb40cd69 Mon Sep 17 00:00:00 2001 From: =?utf8?q?=C5=81ukasz=20Stelmach?= Date: Wed, 31 May 2017 13:26:39 +0200 Subject: [PATCH] wip MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Change-Id: I44da8f5ff2419e1555c7451404e6fb4f0a3d0f2d Signed-off-by: Łukasz Stelmach --- src/core/database.c | 3 +++ src/util/common.h | 2 ++ 2 files changed, 5 insertions(+) diff --git a/src/core/database.c b/src/core/database.c index 5d06143..3cd6eee 100644 --- a/src/core/database.c +++ b/src/core/database.c @@ -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; } diff --git a/src/util/common.h b/src/util/common.h index a17581e..bd3bcf0 100644 --- a/src/util/common.h +++ b/src/util/common.h @@ -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 */ -- 2.34.1