]> git.ipfire.org Git - thirdparty/knot-resolver.git/commitdiff
treewide: minor C11 cleanup
authorVladimír Čunát <vladimir.cunat@nic.cz>
Wed, 12 May 2021 17:03:37 +0000 (19:03 +0200)
committerTomas Krizek <tomas.krizek@nic.cz>
Tue, 25 May 2021 12:39:45 +0000 (14:39 +0200)
lib/cache/impl.h
lib/defines.h
lib/utils.h

index 6703617006f1947f77aae3c31de82d0164d18a33..54b0802c12ac177bd51bc3762dffaea77c7d3fed 100644 (file)
@@ -303,7 +303,8 @@ static inline int rdataset_dematerialize_size(const knot_rdataset_t *rds)
 static inline int rdataset_dematerialized_size(const uint8_t *data, uint16_t *rdataset_count)
 {
        uint16_t count;
-       kr_require(sizeof(count) == KR_CACHE_RR_COUNT_SIZE);
+       static_assert(sizeof(count) == KR_CACHE_RR_COUNT_SIZE,
+                       "Unexpected KR_CACHE_RR_COUNT_SIZE.");
        memcpy(&count, data, sizeof(count));
        const uint8_t *rdata = data + sizeof(count);
        if (rdataset_count) // memcpy is safe for unaligned case (on non-x86)
index dc8c3788248886455ba331f192c4aaab32dfb1e4..618903f46e70d92efd83b93faa45fdddffce3ca4 100644 (file)
 #define KR_PRINTF(n)
 #endif
 
-#ifndef uint /* Redefining typedef is a C11 feature. */
 typedef unsigned int uint;
-#define uint uint
-#endif
 
 /*
  * Error codes.
@@ -41,6 +38,10 @@ static inline int KR_COLD kr_error(int x) {
 }
 #define kr_strerror(x) strerror(abs(x))
 
+/* We require C11 but want to avoid including the standard assertion header
+ * so we alias it ourselves. */
+#define static_assert _Static_assert
+
 /*
  * Connection limits.
  * @cond internal
index e11e8b144887d82630388029cba3d2ded0bbdede..01b5c0506b0b620a0623d67a33dc671103bb2344 100644 (file)
@@ -154,11 +154,6 @@ void kr_log_q(const struct kr_query *qry, const char *source, const char *fmt, .
        knot_rrtype_to_string((rrtype), rrtype_str, sizeof(rrtype_str)); \
        rrtype_str[sizeof(rrtype_str) - 1] = 0;
 
-/* C11 compatibility, but without any implementation so far. */
-#ifndef static_assert
-#define static_assert(cond, msg)
-#endif
-
 // Use this for alocations with mm.
 // Use mm_alloc for alocations into mempool