diff --git a/CHANGES b/CHANGES index 4dfe2c2..42a0d5a 100644 --- a/CHANGES +++ b/CHANGES @@ -4,6 +4,8 @@ October 2018 - jsmith@resonatingmedia.com - Added ability to run --dry-run and --show-all in addition to the existing --dryrun and --showall options. Closes Debian bug #580773 +- Fixed compiler warnings when unused variables are defined in listing.h + ------------------------------------------------------------------- August 2018 - jsmith@resonatingmedia.com diff --git a/insserv.c b/insserv.c index c927f71..1fffd72 100644 --- a/insserv.c +++ b/insserv.c @@ -65,6 +65,9 @@ #ifdef SUSE # include #endif /* SUSE */ +#ifndef NEED_RUNLEVELS_DEF +#define NEED_RUNLEVELS_DEF +#endif #include "listing.h" #include "systemd.h" @@ -1794,7 +1797,7 @@ char * lvl2str(const ushort lvl) last = ptr = &str[0]; memset(ptr, '\0', sizeof(str)); - for (num = 0; num < RUNLEVLES; num++) { + for (num = 0; num < RUNLEVELS; num++) { if (bit & lvl) { if (ptr > last) *ptr++ = ' '; @@ -1832,7 +1835,7 @@ static void scan_script_locations(const char *const path, const char *const over int runlevel; pushd(path); - for (runlevel = 0; runlevel < RUNLEVLES; runlevel++) { + for (runlevel = 0; runlevel < RUNLEVELS; runlevel++) { const char * rcd = (char*)0; struct stat st_script; struct dirent *d; @@ -3803,7 +3806,7 @@ int main (int argc, char *argv[]) #else # ifdef SUSE /* SuSE's SystemV link scheme */ pushd(path); - for (runlevel = 0; runlevel < RUNLEVLES; runlevel++) { + for (runlevel = 0; runlevel < RUNLEVELS; runlevel++) { const ushort lvl = map_runlevel_to_lvl(runlevel); char nlink[PATH_MAX+1], olink[PATH_MAX+1]; const char * rcd = (char*)0; @@ -3989,7 +3992,7 @@ int main (int argc, char *argv[]) * approach a new directory halt.d/ whould be an idea. */ pushd(path); - for (runlevel = 0; runlevel < RUNLEVLES; runlevel++) { + for (runlevel = 0; runlevel < RUNLEVELS; runlevel++) { char nlink[PATH_MAX+1], olink[PATH_MAX+1]; const char * rcd = (char*)0; const char * script; diff --git a/listing.h b/listing.h index 62dcb2c..91dfac0 100644 --- a/listing.h +++ b/listing.h @@ -455,7 +455,7 @@ extern char empty[]; */ #define MAX_DEEP 99 - +#ifdef NEED_RUNLEVELS_DEF static struct { char *location; const ushort lvl; @@ -486,5 +486,5 @@ static struct { }; -#define RUNLEVLES (int)(sizeof(runlevel_locations)/sizeof(runlevel_locations[0])) - +#define RUNLEVELS (int)(sizeof(runlevel_locations)/sizeof(runlevel_locations[0])) +#endif /* done checking if we need runlevels defined */ diff --git a/map.c b/map.c index 8458509..1f3ee48 100644 --- a/map.c +++ b/map.c @@ -3,17 +3,20 @@ #include #include +#ifndef NEED_RUNLEVELS_DEF +#define NEED_RUNLEVELS_DEF +#endif #include "listing.h" int map_has_runlevels(void) { - return RUNLEVLES; + return RUNLEVELS; } char map_runlevel_to_key(const int runlevel) { - if (runlevel >= RUNLEVLES) { + if (runlevel >= RUNLEVELS) { error("Wrong runlevel %d\n", runlevel); } return runlevel_locations[runlevel].key; @@ -23,7 +26,7 @@ ushort map_key_to_lvl(const char key) { int runlevel; const char uckey = toupper(key); - for (runlevel = 0; runlevel < RUNLEVLES; runlevel++) { + for (runlevel = 0; runlevel < RUNLEVELS; runlevel++) { if (uckey == runlevel_locations[runlevel].key) return runlevel_locations[runlevel].lvl; } @@ -33,7 +36,7 @@ ushort map_key_to_lvl(const char key) const char *map_runlevel_to_location(const int runlevel) { - if (runlevel >= RUNLEVLES) { + if (runlevel >= RUNLEVELS) { error("Wrong runlevel %d\n", runlevel); } return runlevel_locations[runlevel].location; @@ -41,7 +44,7 @@ const char *map_runlevel_to_location(const int runlevel) ushort map_runlevel_to_lvl(const int runlevel) { - if (runlevel >= RUNLEVLES) { + if (runlevel >= RUNLEVELS) { error("Wrong runlevel %d\n", runlevel); } return runlevel_locations[runlevel].lvl;