[PATCH] secnet.h: Change bool_t to a C99 _Bool

Ian Jackson ijackson at chiark.greenend.org.uk
Thu May 15 01:35:01 BST 2014


This will (a) stop misleading readers of the code (b) make it possible
to write code expecting an implicit !! to be applied to assignments to
booleans (c) possibly make secnet smaller or faster.

I don't expect this to produce any functional change, but I haven't
reviewed every bool_t in secnet to check.

Signed-off-by: Ian Jackson <ijackson at chiark.greenend.org.uk>
---
 debian/changelog |    1 +
 secnet.h         |    5 ++++-
 2 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/debian/changelog b/debian/changelog
index 5f7de10..b51b541 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,6 +1,7 @@
 secnet (0.3.2~~) unstable; urgency=low
 
   * Updates to release checklist in Makefile.in.
+  * Use C99 _Bool for bool_t.
 
  --
 
diff --git a/secnet.h b/secnet.h
index d5663ff..29cbac7 100644
--- a/secnet.h
+++ b/secnet.h
@@ -16,7 +16,10 @@
 
 typedef char *string_t;
 typedef const char *cstring_t;
-typedef enum {False,True} bool_t;
+
+#define False (_Bool)0
+#define True  (_Bool)1
+typedef _Bool bool_t;
 
 #define ASSERT(x) do { if (!(x)) { fatal("assertion failed line %d file " \
 					 __FILE__,__LINE__); } } while(0)
-- 
1.7.10.4




More information about the sgo-software-discuss mailing list