summarylogtreecommitdiffstats
path: root/0002-lwp-Replace-the-typedefed-bool-datatype-with-int.patch
blob: 459ddec70db528ca4b00ea5b514ad212556939b3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
From 131771b5b0aa5fa32787a4325692a232d72b57f1 Mon Sep 17 00:00:00 2001
From: Cheyenne Wills <cwills@sinenomine.net>
Date: Thu, 24 Apr 2025 13:21:12 -0600
Subject: [PATCH 2/3] lwp: Replace the typedefed bool datatype with int
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

A new C standard (C23) is coming out and newer versions of C compilers
(e.g. gcc 15) are using the new standard (or an extension of that
standard) as their default.  The C23 standard has added a native C data
type `bool`.  This causes a build error when code tries to use
a typedef to define a `bool` data type:

 iomgr.c:50:23: error: ‘bool’ cannot be defined via ‘typedef’
   50 | typedef unsigned char bool;
      |                       ^~~~
 iomgr.c:50:23: note: ‘bool’ is a keyword with ‘-std=c23’ onwards
 iomgr.c:50:1: warning: useless type name in empty declaration
   50 | typedef unsigned char bool;

There are just a few locations where `bool` is used as a data type.
Replace the use of the `bool` data type with an `int`.

Note: This problem occurred on Fedora 42 which comes with gcc 15.

Reviewed-on: https://gerrit.openafs.org/16369
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Andrew Deason <adeason@sinenomine.net>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
(cherry picked from commit bf64c84058493ee6fe2b1b2fb27b73787aaed318)

Change-Id: Ib959f8c72189df0a797b905388bdd33627ca1ca1
---
 src/lwp/iomgr.c | 5 ++---
 src/lwp/timer.c | 3 +--
 2 files changed, 3 insertions(+), 5 deletions(-)

diff --git a/src/lwp/iomgr.c b/src/lwp/iomgr.c
index 82b576fe2..b317eb2eb 100644
--- a/src/lwp/iomgr.c
+++ b/src/lwp/iomgr.c
@@ -47,7 +47,6 @@
 #include "lwp.h"
 #include "timer.h"
 
-typedef unsigned char bool;
 #define FALSE	0
 #define TRUE	1
 
@@ -356,7 +355,7 @@ static void *IOMGR(void *dummy)
 	int code;
 	struct TM_Elem *earliest;
 	struct timeval timeout, junk;
-	bool woke_someone;
+	int woke_someone;
 
 	FD_ZERO(&IOMGR_readfds);
 	FD_ZERO(&IOMGR_writefds);
@@ -651,7 +650,7 @@ static void SigHandler (int signo)
    to LWPs waiting on Unix signals. NOW ALSO CAN YIELD!! */
 static int SignalSignals (void)
 {
-    bool gotone = FALSE;
+    int gotone = FALSE;
     int i;
     void *(*p)(void *);
     afs_int32 stackSize;
diff --git a/src/lwp/timer.c b/src/lwp/timer.c
index b9172944d..3032b5640 100644
--- a/src/lwp/timer.c
+++ b/src/lwp/timer.c
@@ -30,7 +30,6 @@
 
 
 
-typedef unsigned char bool;
 #define FALSE	0
 #define TRUE	1
 
@@ -107,7 +106,7 @@ static bool geq(struct timeval *t1, struct timeval *t2)
 }
 */
 
-static bool
+static int
 blocking(struct TM_Elem *t)
 {
     return (t->TotalTime.tv_sec < 0 || t->TotalTime.tv_usec < 0);
-- 
2.49.0