diff options
author | David Robillard <d@drobilla.net> | 2020-11-11 17:44:24 +0100 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2020-11-11 22:01:05 +0100 |
commit | 86e4ecb99fa626a389cee96fb034c8c5b1c0121b (patch) | |
tree | 861ac8671a7726edf988ed8693544c0e3a3fe9ff | |
parent | 37727929bb07aec91038a9e4d14dc5a9290a9df5 (diff) | |
download | zix-86e4ecb99fa626a389cee96fb034c8c5b1c0121b.tar.gz zix-86e4ecb99fa626a389cee96fb034c8c5b1c0121b.tar.bz2 zix-86e4ecb99fa626a389cee96fb034c8c5b1c0121b.zip |
Use C11 if possible
-rw-r--r-- | .clang-tidy | 1 | ||||
-rw-r--r-- | wscript | 4 | ||||
-rw-r--r-- | zix/btree.c | 11 |
3 files changed, 14 insertions, 2 deletions
diff --git a/.clang-tidy b/.clang-tidy index a454239..1e42e8e 100644 --- a/.clang-tidy +++ b/.clang-tidy @@ -7,6 +7,7 @@ Checks: > -cert-err34-c, -cert-msc30-c, -cert-msc50-cpp, + -clang-analyzer-security.insecureAPI.DeprecatedOrUnsafeBufferHandling, -cppcoreguidelines-init-variables, -google-readability-casting, -hicpp-multiway-paths-covered, @@ -36,7 +36,9 @@ def options(ctx): def configure(conf): conf.load('compiler_c', cache=True) conf.load('autowaf', cache=True) - autowaf.set_c_lang(conf, 'c99') + + if not autowaf.set_c_lang(conf, 'c11', mandatory=False): + autowaf.set_c_lang(conf, 'c99') conf.env.update({ 'BUILD_BENCH': Options.options.bench, diff --git a/zix/btree.c b/zix/btree.c index 3dc2d57..302ab87 100644 --- a/zix/btree.c +++ b/zix/btree.c @@ -1,5 +1,5 @@ /* - Copyright 2011-2019 David Robillard <http://drobilla.net> + Copyright 2011-2020 David Robillard <http://drobilla.net> Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above @@ -49,6 +49,11 @@ struct ZixBTreeNodeImpl { ZixBTreeNode* children[ZIX_BTREE_INODE_VALS + 1]; // Nonexistent for leaves }; +#if (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112l) || \ + (defined(__cplusplus) && __cplusplus >= 201103L) +static_assert(sizeof(ZixBTreeNode) == ZIX_BTREE_PAGE_SIZE, ""); +#endif + typedef struct { ZixBTreeNode* node; unsigned index; @@ -99,7 +104,11 @@ print_tree(const ZixBTreeNode* parent, const ZixBTreeNode* node, int level) ZIX_PRIVATE ZixBTreeNode* zix_btree_node_new(const bool leaf) { +#if !((defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112l) || \ + (defined(__cplusplus) && __cplusplus >= 201103L)) assert(sizeof(ZixBTreeNode) == ZIX_BTREE_PAGE_SIZE); +#endif + ZixBTreeNode* node = (ZixBTreeNode*)malloc(sizeof(ZixBTreeNode)); if (node) { node->is_leaf = leaf; |