chiark / gitweb /
Rename bool, false and true identifiers to avoid clashes
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Sat, 20 Sep 2025 09:59:28 +0000 (10:59 +0100)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Sat, 20 Sep 2025 10:03:26 +0000 (11:03 +0100)
GCC-15 has different defaults which mean we can't use these names as
normal identifiers.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
conffile.c
debian/changelog
dh.c
random.c
rsa.c
secnet.h

index 8c4385cd4477f795b9a5830e495ca240a5c8f7ea..1549c0f9d73fe0257ff37dcced3514e22624db65 100644 (file)
@@ -478,8 +478,8 @@ static dict_t *process_config(struct p_node *c)
     dict_t *root;
     dict_t *context;
     item_t *i;
-    list_t *false;
-    list_t *true;
+    list_t *false_;
+    list_t *true_;
 
     root=dict_new(NULL);
     context=root;
@@ -489,29 +489,29 @@ static dict_t *process_config(struct p_node *c)
        length, so they line up nicely...  thanks VKC and SGT (who also
        point out that "mayhap" is a good "maybe" value as well) */
     i=new_item(t_bool,no_loc);
-    i->data.bool=False;
-    false=list_append(NULL,i);
+    i->data.bool_=False;
+    false_=list_append(NULL,i);
     i=new_item(t_bool,no_loc);
-    i->data.bool=True;
-    true=list_append(NULL,i);
-    dict_add(root,"false",false);
-    dict_add(root,"False",false);
-    dict_add(root,"FALSE",false);
-    dict_add(root,"no",false);
-    dict_add(root,"No",false);
-    dict_add(root,"NO",false);
-    dict_add(root,"nowise",false);
-    dict_add(root,"Nowise",false);
-    dict_add(root,"NOWISE",false);
-    dict_add(root,"true",true);
-    dict_add(root,"True",true);
-    dict_add(root,"TRUE",true);
-    dict_add(root,"yes",true);
-    dict_add(root,"Yes",true);
-    dict_add(root,"YES",true);
-    dict_add(root,"verily",true);
-    dict_add(root,"Verily",true);
-    dict_add(root,"VERILY",true);
+    i->data.bool_=True;
+    true_=list_append(NULL,i);
+    dict_add(root,"false",false_);
+    dict_add(root,"False",false_);
+    dict_add(root,"FALSE",false_);
+    dict_add(root,"no",false_);
+    dict_add(root,"No",false_);
+    dict_add(root,"NO",false_);
+    dict_add(root,"nowise",false_);
+    dict_add(root,"Nowise",false_);
+    dict_add(root,"NOWISE",false_);
+    dict_add(root,"true",true_);
+    dict_add(root,"True",true_);
+    dict_add(root,"TRUE",true_);
+    dict_add(root,"yes",true_);
+    dict_add(root,"Yes",true_);
+    dict_add(root,"YES",true_);
+    dict_add(root,"verily",true_);
+    dict_add(root,"Verily",true_);
+    dict_add(root,"VERILY",true_);
 
     add_closure(root,"makelist",makelist);
     add_closure(root,"readfile",readfile);
@@ -762,7 +762,7 @@ bool_t dict_read_bool(dict_t *dict, cstring_t key, bool_t required,
     if (i->type!=t_bool) {
        cfgfatal(loc,desc,"\"%s\" must be a boolean\n",key);
     }
-    r=i->data.bool;
+    r=i->data.bool_;
     return r;
 }
 
index 611ab03cca12ed2924bd98e20f92f0c333474b62..5cd9a017a9efa0863099dabff864d5216f34bdd8 100644 (file)
@@ -1,6 +1,7 @@
 secnet (0.6.8~) unstable; urgency=medium
 
-  * 
+  * Avoid using `bool`, `false` and `true` as identifiers.
+    Fixes conflicts with modern C and GCC-15.  Closes: #1097866.
 
  --
 
diff --git a/dh.c b/dh.c
index 261209aafedcfaa7077143e43fa27b268a507d10..aebcb06fac6ed9489dd5103147ee59f0a1ea654e 100644 (file)
--- a/dh.c
+++ b/dh.c
@@ -146,7 +146,7 @@ static list_t *dh_apply(closure_t *self, struct cloc loc, dict_t *context,
     }
 
     i=list_elem(args,2);
-    if (i && i->type==t_bool && i->data.bool==False) {
+    if (i && i->type==t_bool && i->data.bool_==False) {
        Message(M_INFO,"diffie-hellman (%s:%d): skipping modulus "
                "primality check\n",loc.file,loc.line);
     } else {
index 323fffd692e4677732edef90fe5d5a4106261872..65b540aadaffeceae781eac1e3f0cf6d771c875c 100644 (file)
--- a/random.c
+++ b/random.c
@@ -82,7 +82,7 @@ static list_t *random_apply(closure_t *self, struct cloc loc,
            cfgfatal(arg2->loc,"randomsource",
                     "blocking parameter (arg2) must be bool\n");
        }
-       st->ops.blocking=arg2->data.bool;
+       st->ops.blocking=arg2->data.bool_;
     }
 
     if (!filename) {
diff --git a/rsa.c b/rsa.c
index efcb650fc216c3a2965b2bb45d0b85e3158478f3..c52dec9db0c6ebe21c02de14a48c2e5313366ce7 100644 (file)
--- a/rsa.c
+++ b/rsa.c
@@ -803,7 +803,7 @@ static list_t *rsapriv_apply(closure_t *self, struct cloc loc, dict_t *context,
 
     bool_t do_validity_check=True;
     i=list_elem(args,1);
-    if (i && i->type==t_bool && i->data.bool==False) {
+    if (i && i->type==t_bool && i->data.bool_==False) {
        Message(M_INFO,"rsa-private (%s:%d): skipping RSA key validity "
                "check\n",loc.file,loc.line);
        do_validity_check=False;
index 79a3fc448e4a1a3a8ca81333746f0e12ee091e75..99d00ba13eabaea5da72462ef653ffa8e4fff714 100644 (file)
--- a/secnet.h
+++ b/secnet.h
@@ -160,7 +160,7 @@ enum types { t_null, t_bool, t_string, t_number, t_dict, t_closure };
 struct item {
     enum types type;
     union {
-       bool_t bool;
+       bool_t bool_;
        string_t string;
        uint32_t number;
        dict_t *dict;