[sheepdog] [PATCH 3/3] journal: use BUILD_BUG_ON() for checking the size of struct journal_descriptor
Hitoshi Mitake
mitake.hitoshi at gmail.com
Sun Apr 28 19:08:07 CEST 2013
This patch adds BUILD_BUG_ON() for checking the size of struct
journal_descriptor. Even if the struct modified in wrong manners, the
BUILD_BUG_ON() can detect the invalid changes (on the size).
Signed-off-by: Hitoshi Mitake <mitake.hitoshi at lab.ntt.co.jp>
---
sheep/journal.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/sheep/journal.c b/sheep/journal.c
index 9ca1ce6..23a0ab7 100644
--- a/sheep/journal.c
+++ b/sheep/journal.c
@@ -437,3 +437,9 @@ int journal_write_epoch(const char *buf, size_t size, uint32_t epoch)
jd.epoch = epoch;
return journal_file_write(&jd, buf);
}
+
+static __attribute__((used)) void journal_c_build_bug_ons(void)
+{
+ /* never called, only for checking BUILD_BUG_ON()s */
+ BUILD_BUG_ON(sizeof(struct journal_descriptor) != JOURNAL_DESC_SIZE);
+}
--
1.7.10.rc0.41.gfa678
More information about the sheepdog
mailing list