]> git.ipfire.org Git - thirdparty/collectd.git/commitdiff
procevent plugin: Disable the `-Wgnu-variable-sized-type-not-at-end` warning.
authorFlorian Forster <octo@collectd.org>
Mon, 27 Nov 2023 13:59:05 +0000 (14:59 +0100)
committerFlorian Forster <octo@collectd.org>
Mon, 27 Nov 2023 15:12:03 +0000 (16:12 +0100)
src/procevent.c

index 03d9081f3bad8d8611965c5dbb03ff8f3c1abec8..81a1c973f6b627656709468f009c73394193897c 100644 (file)
 #define PROCEVENT_VF_STATUS_CRITICAL_VALUE "Ready to terminate"
 #define PROCEVENT_VF_STATUS_NORMAL_VALUE "Active"
 
+/*
+ * Disable a clang warning about variable sized types in the middle of a struct.
+ *
+ * The below code uses temporary structs containing a `struct cn_msg` followed
+ * by another field. `struct cn_msg` includes a "flexible array member" and the
+ * struct is an elegant and convenient way of populating this "flexible" element
+ * via the other field in the temporary struct.
+ *
+ * Unfortunately, this is not supported by the C standard. GCC and clang both
+ * can deal with the situation though. Disable the warning to keep the well
+ * readable code.
+ */
+#ifdef __clang__
+#pragma clang diagnostic ignored "-Wgnu-variable-sized-type-not-at-end"
+#endif
+
 /*
  * Private data types
  */