Fixed compiler warnings so that unused variables listed in

listing.h are skipped when not needed.
This commit is contained in:
Jesse Smith 2018-11-07 15:27:25 -04:00
parent e70067f9ec
commit c41ebc52a2
4 changed files with 20 additions and 12 deletions

View File

@ -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

View File

@ -65,6 +65,9 @@
#ifdef SUSE
# include <sys/mount.h>
#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;

View File

@ -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 */

13
map.c
View File

@ -3,17 +3,20 @@
#include <ctype.h>
#include <errno.h>
#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;