Bug#1096840: insserv: ftbfs with GCC-15

Mark Hindley mark at hindley.org.uk
Fri Sep 5 18:13:17 BST 2025


Control: tags -1 patch

Jesse,

Would something like this work?

Mark

commit e16d596a0b53256f89193063ee980c13c81f9368
Author: Mark Hindley <mark at hindley.org.uk>
Date:   Mon Aug 25 14:51:17 2025 +0100

    Use stdbool.h, fixes FTBFS with gcc-15.
    
    Closes: #1096840

diff --git a/insserv.c b/insserv.c
index 80a3066..ab39157 100644
--- a/insserv.c
+++ b/insserv.c
@@ -182,12 +182,12 @@ static char buf[LINE_MAX];
 
 /* When to be verbose, and what level of verbosity */
 static int verbose = 0;
-static boolean silent_mode = false;
-static boolean dryrun = false;
+static bool silent_mode = false;
+static bool dryrun = false;
 
 /* When paths set do not add root if any */
-static boolean set_override = false;
-static boolean set_insconf = false;
+static bool set_override = false;
+static bool set_insconf = false;
 
 /* Legacy and current location for dependency files */
 /* #define DEPENDENCY_PATH "/lib/insserv/" */
@@ -202,8 +202,8 @@ char **file_filters = NULL;
 
 /* Wether systemd is active or not */
 #if WANT_SYSTEMD
-static boolean systemd = false;
-static boolean is_overridden_by_systemd(const char *);
+static bool systemd = false;
+static bool is_overridden_by_systemd(const char *);
 #endif /* WANT_SYSTEMD */
 
 /* Search results points here */
@@ -405,14 +405,14 @@ static void rememberreq(service_t * restrict serv, uint bit, const char * restri
     char * tmp = strdupa(required);
     list_t * ptr, * list;
     ushort old = bit;
-    boolean can_expand_name = false;
+    bool can_expand_name = false;
 
     if (!tmp)
 	error("%s", strerror(errno));
 
     while ((token = strsep(&tmp, delimeter)) && *token) {
 	service_t * req, * here, * need;
-	boolean found = false;
+	bool found = false;
 
 	bit = old;
 
@@ -528,10 +528,10 @@ static void reversereq(service_t *restrict serv, uint bit, const char *restrict
 /*
  * Check required services for name
  */
-static boolean chkrequired(service_t *restrict serv, const boolean recursive) attribute((nonnull(1)));
-static boolean chkrequired(service_t *restrict serv, const boolean recursive)
+static bool chkrequired(service_t *restrict serv, const bool recursive) attribute((nonnull(1)));
+static bool chkrequired(service_t *restrict serv, const bool recursive)
 {
-    boolean ret = true;
+    bool ret = true;
     list_t * pos;
 
     /* Technically, it is not possible for this function to be called if serv is
@@ -593,11 +593,11 @@ static boolean chkrequired(service_t *restrict serv, const boolean recursive)
 /*
  * Check dependencies for name as a service
  */
-static boolean chkdependencies(service_t *restrict serv) attribute((nonnull(1)));
-static boolean chkdependencies(service_t *restrict serv)
+static bool chkdependencies(service_t *restrict serv) attribute((nonnull(1)));
+static bool chkdependencies(service_t *restrict serv)
 {
     const char * const name = serv->name;
-    boolean ret = true;
+    bool ret = true;
     list_t * ptr;
 
     list_for_each(ptr, s_start) {
@@ -972,7 +972,7 @@ static inline void makedep(void)
 	const service_t * lserv[100] = {0};
 	unsigned long lcnt = 0;
 #endif /* not MINIMAL_DEPEND */
-	boolean mark;
+	bool mark;
 	list_t * pos;
 
 #if defined(MINIMAL_RULES) && (MINIMAL_RULES != 0)
@@ -994,7 +994,7 @@ static inline void makedep(void)
 	    req_t * req = getreq(pos);
 	    service_t * dep = req->serv;
 #if defined(MINIMAL_DEPEND) && (MINIMAL_DEPEND != 0)
-	    boolean shadow = false;
+	    bool shadow = false;
 	    unsigned long n;
 #endif /* not MINIMAL_DEPEND */
 	    const char * name;
@@ -1114,7 +1114,7 @@ static inline void makedep(void)
 	const service_t * lserv[100] = {0};
 	unsigned long lcnt = 0;
 #endif /* not MINIMAL_DEPEND */
-	boolean mark;
+	bool mark;
 	list_t * pos;
 
 #if defined(MINIMAL_RULES) && (MINIMAL_RULES != 0)
@@ -1139,7 +1139,7 @@ static inline void makedep(void)
 	    req_t * rev = getreq(pos);
 	    service_t * dep = rev->serv;
 #if defined(MINIMAL_DEPEND) && (MINIMAL_DEPEND != 0)
-	    boolean shadow = false;
+	    bool shadow = false;
 	    unsigned long n;
 #endif /* not MINIMAL_DEPEND */
 	    const char * name;
@@ -1267,11 +1267,11 @@ out:
  *  Check for script in list.
  */
 static int curr_argc = -1;
-static inline boolean chkfor(const char *restrict const script,
+static inline bool chkfor(const char *restrict const script,
 			     char **restrict const list, const int cnt) attribute((nonnull(1,2)));
-static inline boolean chkfor(const char *restrict const script, char **restrict const list, const int cnt)
+static inline bool chkfor(const char *restrict const script, char **restrict const list, const int cnt)
 {
-    boolean isinc = false;
+    bool isinc = false;
     register int c = cnt;
 
     curr_argc = -1;
@@ -1343,10 +1343,10 @@ static inline void regcompiler(regex_t *restrict preg, const char *restrict rege
 /*
  * Wrapper for regexec(3)
  */
-static inline boolean regexecutor(regex_t *restrict preg,
+static inline bool regexecutor(regex_t *restrict preg,
 				  const char *restrict string,
 				  size_t nmatch, regmatch_t pmatch[], int eflags) attribute((nonnull(1,2)));
-static inline boolean regexecutor(regex_t *preg, const char *string,
+static inline bool regexecutor(regex_t *preg, const char *string,
 	size_t nmatch, regmatch_t pmatch[], int eflags)
 {
     register int ret = regexec(preg, string, nmatch, pmatch, eflags);
@@ -1511,9 +1511,9 @@ static char *is_upstart_job(const char *path)
 static int o_flags = O_RDONLY;
 
 static uchar scan_lsb_headers(const int dfd, const char *restrict const path,
-			      const boolean cache, const boolean ignore) attribute((nonnull(2)));
+			      const bool cache, const bool ignore) attribute((nonnull(2)));
 static uchar scan_lsb_headers(const int dfd, const char *restrict const path,
-			      const boolean cache, const boolean ignore)
+			      const bool cache, const bool ignore)
 {
     regmatch_t subloc[SUBNUM_SHD+1], *val = &subloc[SUBNUM-1], *shl = &subloc[SUBNUM_SHD-1];
     char *upstart_job = (char*)0;
@@ -1794,10 +1794,10 @@ static char * scriptname(int dfd, const char *restrict const path, char **restri
 
 static uchar load_overrides(const char *restrict const dir,
 			    const char *restrict const name,
-			    const boolean cache, const boolean ignore) attribute((nonnull(1,2)));
+			    const bool cache, const bool ignore) attribute((nonnull(1,2)));
 static uchar load_overrides(const char *restrict const dir,
 			    const char *restrict const name,
-			    const boolean cache, const boolean ignore)
+			    const bool cache, const bool ignore)
 {
     uchar ret = 0;
     char fullpath[PATH_MAX+1];
@@ -1818,11 +1818,11 @@ static uchar load_overrides(const char *restrict const dir,
 static uchar scan_script_defaults(int dfd, const char *const restrict path,
 				  const char *const restrict override_path,
 				  char **restrict first,
-				  const boolean cache, const boolean ignore) attribute((nonnull(2,3)));
+				  const bool cache, const bool ignore) attribute((nonnull(2,3)));
 static uchar scan_script_defaults(int dfd, const char *restrict const path,
 				  const char *restrict const override_path,
 				  char **restrict first,
-				  const boolean cache, const boolean ignore)
+				  const bool cache, const bool ignore)
 {
     char * name = scriptname(dfd, path, first);
     uchar ret = 0;
@@ -1987,9 +1987,9 @@ char * lvl2str(const ushort lvl)
  */
 static void scan_script_locations(const char *const restrict path,
 				  const char *const restrict override_path,
-				  const boolean ignore) attribute((nonnull(1,2)));
+				  const bool ignore) attribute((nonnull(1,2)));
 static void scan_script_locations(const char *const path, const char *const override_path,
-				  const boolean ignore)
+				  const bool ignore)
 {
     int runlevel;
 
@@ -2268,7 +2268,7 @@ err:
 static int cfgfile_filter(const struct dirent *restrict d) attribute((nonnull(1)));
 static int cfgfile_filter(const struct dirent *restrict d)
 {
-    boolean ret = false;
+    bool ret = false;
     const char * name = d->d_name;
     const char * end;
 
@@ -2298,7 +2298,7 @@ static int cfgfile_filter(const struct dirent *restrict d)
         /* check loaded filters */
         else if (file_filters)
         {
-            boolean found = false;
+            bool found = false;
             int index = 0;
             while ( (file_filters[index]) && (! found) )
             {
@@ -2630,10 +2630,10 @@ static inline char * scan_for(DIR *const rcdir,
  * a sub process "/bin/sh" forked off for executing a temporary file for %preun,
  * %postun, %pre, or %post scriptlet.
  */
-static inline boolean underrpm(void)
+static inline bool underrpm(void)
 {
-    boolean ret = false;
-    boolean mnt = true;
+    bool ret = false;
+    bool mnt = true;
     const pid_t pp = getppid();
     char buf[PATH_MAX], *argv[3], *ptr;
 # if defined(USE_RPMLIB) && (USE_RPMLIB > 0)
@@ -2724,9 +2724,9 @@ out:
 /*
  * Systemd integration
  */
-static boolean is_overridden_by_systemd(const char *service) {
+static bool is_overridden_by_systemd(const char *service) {
     char *p;
-    boolean ret = false;
+    bool ret = false;
 
     if (asprintf(&p, SYSTEMD_SERVICE_PATH "/%s.service", service) < 0)
 	error("asprintf(): %s\n", strerror(errno));
@@ -2737,7 +2737,7 @@ static boolean is_overridden_by_systemd(const char *service) {
     return ret;
 }
 
-static void forward_to_systemd (const char *initscript, const char *verb, boolean alternative_root) {
+static void forward_to_systemd (const char *initscript, const char *verb, bool alternative_root) {
     const char *name;
 
     if (initscript == NULL)
@@ -2783,9 +2783,9 @@ static void forward_to_systemd (const char *initscript, const char *verb, boolea
    stop or stop levels.
    Returns true if overlap is found and false is none is found.
 */
-boolean Start_Stop_Overlap(char *start_levels, char *stop_levels)
+bool Start_Stop_Overlap(char *start_levels, char *stop_levels)
 {
-   boolean found_overlap = false;
+   bool found_overlap = false;
    int string_index = 0;
    char *found;
 
@@ -2865,16 +2865,16 @@ int main (int argc, char *argv[])
     char * insconf = INSCONF;
     const char *const ipath = path;
     int runlevel, c, dfd;
-    boolean del = false;
-    boolean defaults = false;
-    boolean ignore = false;
-    boolean loadarg = false;
-    boolean recursive = false;
-    boolean showall = false;
-    boolean waserr = false;
-    /* boolean legacy_path = false; */
-    boolean free_dependency_path = false;
-    boolean overlap;
+    bool del = false;
+    bool defaults = false;
+    bool ignore = false;
+    bool loadarg = false;
+    bool recursive = false;
+    bool showall = false;
+    bool waserr = false;
+    /* bool legacy_path = false; */
+    bool free_dependency_path = false;
+    bool overlap;
 
     myname = basename(*argv);
 
@@ -3231,8 +3231,8 @@ int main (int argc, char *argv[])
 	service_t * service = (service_t*)0;
 	char * token;
 	char * begin = (char*)0;	/* hold start pointer of strings handled by strsep() */
-	boolean hard = false;
-	boolean isarg = false;
+	bool hard = false;
+	bool isarg = false;
 	uchar lsb = 0;
 #if defined(DEBUG) && (DEBUG > 0)
 	int nobug = 0;
@@ -3588,7 +3588,7 @@ int main (int argc, char *argv[])
 	    	}
 
 		if (service) {
-		    boolean known = (service->attr.flags & SERV_KNOWN);
+		    bool known = (service->attr.flags & SERV_KNOWN);
 		    service->attr.flags |= SERV_KNOWN;
 
 		    if (!known) {
@@ -3640,7 +3640,7 @@ int main (int argc, char *argv[])
 		     * check if all services are around for this script.
 		     */
 		    if (isarg && !ignore) {
-			boolean ok = true;
+			bool ok = true;
 			if (del)
 			    ok = chkdependencies(service);
 			else
@@ -3806,7 +3806,7 @@ int main (int argc, char *argv[])
 		char * ptr = argr[curr_argc];
 		struct _mark {
 		    const char * wrd;
-		    const boolean sk;
+		    const bool sk;
 		    char * order;
 		    char ** str;
 		} mark[] = {
@@ -4146,8 +4146,8 @@ int main (int argc, char *argv[])
 
 	script = (char*)0;
 	while ((serv = listscripts(&script, 'X', lvl))) {
-	    boolean this = chkfor(script, argv, argc);
-	    boolean found, slink;
+	    bool this = chkfor(script, argv, argc);
+	    bool found, slink;
 	    char * clink;
 
 	    if (*script == '$')		/* Do not link in virtual dependencies */
@@ -4331,8 +4331,8 @@ int main (int argc, char *argv[])
 
 	script = (char*)0;
 	while ((serv = listscripts(&script, 'X', seek))) {
-	    boolean this = chkfor(script, argv, argc);
-	    boolean found;
+	    bool this = chkfor(script, argv, argc);
+	    bool found;
 	    char * clink;
 	    char mode;
 
diff --git a/listing.c b/listing.c
index 98fa278..f82a9e9 100644
--- a/listing.c
+++ b/listing.c
@@ -237,10 +237,10 @@ out:
 /*
  * Remember loops to warn only once
  */
-static inline boolean remembernode (handle_t *restrict const peg) attribute((always_inline,nonnull(1)));
-static inline boolean remembernode (handle_t *restrict const peg)
+static inline bool remembernode (handle_t *restrict const peg) attribute((always_inline,nonnull(1)));
+static inline bool remembernode (handle_t *restrict const peg)
 {
-    register boolean ret = true;
+    register bool ret = true;
 
     if (peg->flags & DIR_LOOP)
 	goto out;
@@ -330,7 +330,7 @@ static void __follow (dir_t *restrict dir, dir_t *restrict skip, const int level
 
     for (tmp = dir; tmp; tmp = getnextlink(l_list)) {
 	const typeof(attof(tmp)->flags) sflags = attof(tmp)->flags;
-	register boolean recursion = true;
+	register bool recursion = true;
 	handle_t * ptmp = (mode == 'K') ? &tmp->stopp : &tmp->start;
 	uchar  * order = &ptmp->deep;
 	list_t * dent;
@@ -567,7 +567,7 @@ void lsort(const char type)
 		    if (dir->stopp.deep == order) {
 			service_t *const orig = getorig(rev->serv);
 			list_t * chk;
-			boolean found = false;
+			bool found = false;
 
 			list_for_each_prev(chk, &sort) {    /* check if service was already resorted */
 			    req_t * this = getreq(chk);
@@ -622,7 +622,7 @@ void lsort(const char type)
 		    if (dir->start.deep == order) {
 			service_t * orig = getorig(req->serv);
 			list_t * chk;
-			boolean found = false;
+			bool found = false;
 
 			list_for_each_prev(chk, &sort) {    /* check if service was already resorted */
 			    req_t * this = getreq(chk);
@@ -734,7 +734,7 @@ void nickservice(service_t *restrict orig, service_t *restrict nick)
 
     list_for_each_safe(dent, safe, &nick->sort.req) {
 	req_t * this = getreq(dent);
-	boolean ok = true;
+	bool ok = true;
 	list_t * req;
 	list_for_each(req, &orig->sort.req) {
 	    if (!strcmp(this->serv->name,getreq(req)->serv->name)) {
@@ -751,7 +751,7 @@ void nickservice(service_t *restrict orig, service_t *restrict nick)
 
     list_for_each_safe(dent, safe, &nick->sort.rev) {
 	req_t * this = getreq(dent);
-	boolean ok = true;
+	bool ok = true;
 	list_t * rev;
 	list_for_each(rev, &orig->sort.rev) {
 	    if (!strcmp(this->serv->name,getreq(rev)->serv->name)) {
@@ -851,7 +851,7 @@ void clear_all(void)
 
 	    list_for_each_safe(dent, safe, &orv->sort.req) {
 		req_t * this = getreq(dent);
-		boolean ok = true;
+		bool ok = true;
 		list_t * req;
 		list_for_each(req, &srv->sort.req) {
 		    if (!strcmp(this->serv->name,getreq(req)->serv->name)) {
@@ -873,7 +873,7 @@ void clear_all(void)
 
 	    list_for_each_safe(dent, safe, &orv->sort.rev) {
 		req_t * this = getreq(dent);
-		boolean ok = true;
+		bool ok = true;
 		list_t * rev;
 		list_for_each(rev, &srv->sort.rev) {
 		   if (!strcmp(this->serv->name,getreq(rev)->serv->name)) {
@@ -926,7 +926,7 @@ void follow_all(void)
     }
 }
 
-boolean is_loop_detected(void)
+bool is_loop_detected(void)
 {
     list_t *tmp;
     list_for_each(tmp, d_start) {
@@ -1020,10 +1020,10 @@ void show_all()
 /*
  * Used within loops to get scripts not included in this runlevel
  */
-boolean notincluded(const char *restrict const script, const char mode, const int runlevel)
+bool notincluded(const char *restrict const script, const char mode, const int runlevel)
 {
     list_t *tmp;
-    boolean ret = false;
+    bool ret = false;
     const ushort lvl = map_runlevel_to_lvl (runlevel);
 
     list_for_each_prev(tmp, d_start) {
@@ -1128,7 +1128,7 @@ void runlevels(service_t *restrict serv, const char mode, const char *restrict l
  * Reorder all services starting with a service
  * being in same runlevels.
  */
-void setorder(const char *restrict script, const char mode, const int order, const boolean recursive)
+void setorder(const char *restrict script, const char mode, const int order, const bool recursive)
 {
     dir_t * dir = findscript(script);
     handle_t * peg;
@@ -1194,11 +1194,11 @@ int getorder(const char *restrict script, const char mode)
  * One script and several provided facilities leads
  * to the same order for those facilities.
  */
-boolean makeprov(service_t *restrict serv, const char *restrict script)
+bool makeprov(service_t *restrict serv, const char *restrict script)
 {
     dir_t *restrict alias = findscript(script);
     dir_t *restrict dir   = (dir_t *restrict)serv->dir;
-    boolean ret = true;
+    bool ret = true;
 
     if (!dir->script) {
 	list_t * ptr;
diff --git a/listing.h b/listing.h
index b7d8b84..373a46e 100644
--- a/listing.h
+++ b/listing.h
@@ -20,11 +20,11 @@
  *
  */
 
+#include <stdbool.h>
 #include <stddef.h>
 #include <sys/types.h>
 #include "config.h"
 
-typedef enum _boolean {false, true} boolean;
 typedef unsigned char uchar;
 #ifndef __USE_MISC
 typedef unsigned short ushort;
@@ -191,8 +191,8 @@ static inline void join(list_t *restrict list, list_t *restrict head)
     }
 }
 
-static inline boolean list_empty(const list_t *restrict const head) attribute((always_inline,nonnull(1)));
-static inline boolean list_empty(const list_t *restrict const head)
+static inline bool list_empty(const list_t *restrict const head) attribute((always_inline,nonnull(1)));
+static inline bool list_empty(const list_t *restrict const head)
 {
      return head->next == head;
 }
@@ -308,14 +308,14 @@ extern void follow_all(void);
 extern void show_all(void);
 extern void requires(service_t *restrict this, service_t *restrict dep, const char mode) attribute((nonnull(1,2)));
 extern void runlevels(service_t *restrict serv, const char mode, const char *restrict lvl) attribute((nonnull(1,3)));
-extern boolean makeprov(service_t *restrict serv, const char *restrict script) attribute((nonnull(1,2)));
-extern void setorder(const char *restrict script, const char mode, const int order, const boolean recursive) attribute((nonnull(1)));
+extern bool makeprov(service_t *restrict serv, const char *restrict script) attribute((nonnull(1,2)));
+extern void setorder(const char *restrict script, const char mode, const int order, const bool recursive) attribute((nonnull(1)));
 extern int getorder(const char *restrict script, const char mode) attribute((nonnull(1)));
-extern boolean notincluded(const char *restrict const script, const char mode, const int runlevel) attribute((nonnull(1)));
+extern bool notincluded(const char *restrict const script, const char mode, const int runlevel) attribute((nonnull(1)));
 extern const char * getscript(const char *restrict prov) attribute((nonnull(1)));
 extern const char * getprovides(const char *restrict script) attribute((nonnull(1)));
 extern service_t * listscripts(const char **restrict script, const char mode, const ushort lvl);
-extern boolean is_loop_detected(void);
+extern bool is_loop_detected(void);
 extern service_t * addservice(const char *restrict const serv) attribute((malloc,nonnull(1)));
 extern service_t * findservice(const char *restrict const name);
 extern service_t * getorig(service_t *restrict serv) attribute((const,nonnull(1)));



More information about the Debian-init-diversity mailing list