[PATCH] lib: fwts_json.h: define TRUE and FALSE for newer versions of json-c (LP: #1874224)

Colin King colin.king at canonical.com
Wed Apr 22 12:40:49 UTC 2020


From: Colin Ian King <colin.king at canonical.com>

BugLink: https://bugs.launchpad.net/bugs/1874224

json-c-0.14 does not provide TRUE/FALSE defines anymore, and instead
only uses 1/0 directly. Add in the defines for TRUE/FALSE if they
don't exist already.

Thanks to Björn Esser for the fix from originally from
https://src.fedoraproject.org/rpms/fwts/c/2d53ef23970e but with
the JSON_C_VERSION_NUM removed as we don't need to be overly
pedantic here.

Signed-off-by: Colin Ian King <colin.king at canonical.com>
---
 src/lib/include/fwts_json.h | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/src/lib/include/fwts_json.h b/src/lib/include/fwts_json.h
index 747c4bdb..ad51bc45 100644
--- a/src/lib/include/fwts_json.h
+++ b/src/lib/include/fwts_json.h
@@ -31,4 +31,17 @@
 #define FWTS_JSON_ERROR(ptr) \
 	( (ptr == NULL) || ((const json_object *)ptr == __FWTS_JSON_ERR_PTR__) )
 
+/*
+ * json-c 0.13.99 does not define TRUE/FALSE anymore
+ * the json-c maintainers replaced them with pure 1/0
+ * https://github.com/json-c/json-c/commit/0992aac61f8b
+ */
+#ifndef FALSE
+#define FALSE 0
+#endif
+
+#ifndef TRUE
+#define TRUE  1
+#endif
+
 #endif
-- 
2.25.1




More information about the fwts-devel mailing list