summaryrefslogtreecommitdiff
path: root/lib/replace
diff options
context:
space:
mode:
authorAndrew Bartlett <abartlet@samba.org>2022-03-22 16:12:00 +1300
committerAndreas Schneider <asn@cryptomilk.org>2022-03-23 12:31:47 +0000
commitc0f5af21acb8018a5e53d25f1560d2a96b79a7c0 (patch)
treec86ad31da026e30d83687c0251f125c4d5d89502 /lib/replace
parent1bde388ba854e320a390126155c7aeb60ecfbb90 (diff)
downloadsamba-c0f5af21acb8018a5e53d25f1560d2a96b79a7c0.tar.gz
lib/replace: Do not typedef int bool
We need a genuine boolean type, as otherwise expressions like bool foo = (4 & 4); if (foo == true) { exit(1); } else { exit(2); } could evaluate differently on non-modern platforms, and that would be a real pain to debug. _Bool and bool are in C99 BUG: https://bugzilla.samba.org/show_bug.cgi?id=15028 Signed-off-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Andreas Schneider <asn@samba.org> Reviewed-by: Stefan Metzmacher <metze@samba.org> Autobuild-User(master): Andreas Schneider <asn@cryptomilk.org> Autobuild-Date(master): Wed Mar 23 12:31:47 UTC 2022 on sn-devel-184
Diffstat (limited to 'lib/replace')
-rw-r--r--lib/replace/replace.h2
-rw-r--r--lib/replace/wscript5
2 files changed, 4 insertions, 3 deletions
diff --git a/lib/replace/replace.h b/lib/replace/replace.h
index 8609d84322c..5344d816d58 100644
--- a/lib/replace/replace.h
+++ b/lib/replace/replace.h
@@ -703,7 +703,7 @@ int rep_strerror_r(int errnum, char *buf, size_t buflen);
#ifdef HAVE__Bool
#define bool _Bool
#else
-typedef int bool;
+#error Need a real boolean type
#endif
#endif
diff --git a/lib/replace/wscript b/lib/replace/wscript
index e60ff15f903..827d74f19cb 100644
--- a/lib/replace/wscript
+++ b/lib/replace/wscript
@@ -153,8 +153,9 @@ def configure(conf):
msg='Checking for O_DIRECT flag to open(2)')
conf.CHECK_TYPES('"long long" intptr_t uintptr_t ptrdiff_t comparison_fn_t')
- conf.CHECK_TYPE('_Bool', define='HAVE__Bool')
- conf.CHECK_TYPE('bool', define='HAVE_BOOL')
+ if not conf.CHECK_TYPE('bool', define='HAVE_BOOL'):
+ if not conf.CHECK_TYPE('_Bool', define='HAVE__Bool'):
+ raise Errors.WafError('Samba requires a genuine boolean type')
conf.CHECK_TYPE('int8_t', 'char')
conf.CHECK_TYPE('uint8_t', 'unsigned char')