From 80a17eb5966a2b2c1dff3206621a338b45cbdf7d Mon Sep 17 00:00:00 2001 From: Roy Marples Date: Thu, 18 Sep 2008 13:09:51 +0000 Subject: Clean up some compile warnings. --- src/includes/rc-misc.h | 4 ++++ src/rc/checkpath.c | 3 +-- src/rc/fstabinfo.c | 6 +++--- src/rc/mountinfo.c | 3 +-- src/rc/rc-applets.c | 52 +++++++++++++++++++++++++++------------------- src/rc/rc-status.c | 3 +-- src/rc/rc.c | 2 +- src/rc/runscript.c | 10 ++++----- src/rc/start-stop-daemon.c | 7 +++---- 9 files changed, 50 insertions(+), 40 deletions(-) diff --git a/src/includes/rc-misc.h b/src/includes/rc-misc.h index 91e15895..12154b95 100644 --- a/src/includes/rc-misc.h +++ b/src/includes/rc-misc.h @@ -52,12 +52,16 @@ #define ERRX fprintf (stderr, "out of memory\n"); exit (1) +#define UNCONST(a) ((void *)(unsigned long)(const void *)(a)) + #ifdef lint # define _unused #endif #if __GNUC__ > 2 || defined(__INTEL_COMPILER) +# define _dead __attribute__((__noreturn__)) # define _unused __attribute__((__unused__)) #else +# define _dead # define _unused #endif diff --git a/src/rc/checkpath.c b/src/rc/checkpath.c index 7ea94f09..f9695697 100644 --- a/src/rc/checkpath.c +++ b/src/rc/checkpath.c @@ -208,6 +208,5 @@ int checkpath(int argc, char **argv) optind++; } - exit(retval); - /* NOTREACHED */ + return retval; } diff --git a/src/rc/fstabinfo.c b/src/rc/fstabinfo.c index d1cd4323..b32ee2e4 100644 --- a/src/rc/fstabinfo.c +++ b/src/rc/fstabinfo.c @@ -98,10 +98,10 @@ static int do_mount(struct ENT *ent) pid_t pid; int status; - argv[0] = (char *) "mount"; - argv[1] = (char *) "-o"; + argv[0] = UNCONST("mount"); + argv[1] = UNCONST("-o"); argv[2] = ENT_OPTS(*ent); - argv[3] = (char *) "-t"; + argv[3] = UNCONST("-t"); argv[4] = ENT_TYPE(*ent); argv[5] = ENT_BLOCKDEVICE(*ent); argv[6] = ENT_FILE(*ent); diff --git a/src/rc/mountinfo.c b/src/rc/mountinfo.c index 858851ff..c6a421c3 100644 --- a/src/rc/mountinfo.c +++ b/src/rc/mountinfo.c @@ -481,6 +481,5 @@ int mountinfo(int argc, char **argv) REG_FREE(point_regex); REG_FREE(skip_point_regex); - exit(result); - /* NOTREACHED */ + return result; } diff --git a/src/rc/rc-applets.c b/src/rc/rc-applets.c index 2b7d1909..f5892f98 100644 --- a/src/rc/rc-applets.c +++ b/src/rc/rc-applets.c @@ -82,9 +82,10 @@ static int do_e(int argc, char **argv) char *message = NULL; char *p; int level = 0; - const char *fmt = "%s"; struct timespec ts; struct timeval stop, now; + int (*e) (const char *, ...) __EINFO_PRINTF = NULL; + int (*ee) (int, const char *, ...) __EEND_PRINTF = NULL; /* Punt applet */ argc--; @@ -184,45 +185,42 @@ static int do_e(int argc, char **argv) *p = 0; } - if (! message) - fmt = ""; - if (strcmp(applet, "einfo") == 0) - einfo(fmt, message); + e = einfo; else if (strcmp(applet, "einfon") == 0) - einfon(fmt, message); + e = einfon; else if (strcmp(applet, "ewarn") == 0) - ewarn(fmt, message); + e = ewarn; else if (strcmp(applet, "ewarnn") == 0) - ewarnn(fmt, message); + e = ewarnn; else if (strcmp(applet, "eerror") == 0) { - eerror(fmt, message); + e = eerror; retval = 1; } else if (strcmp(applet, "eerrorn") == 0) { - eerrorn(fmt, message); + e = eerrorn; retval = 1; } else if (strcmp(applet, "ebegin") == 0) - ebegin(fmt, message); + e = ebegin; else if (strcmp(applet, "eend") == 0) - eend(retval, fmt, message); + ee = eend; else if (strcmp(applet, "ewend") == 0) - ewend(retval, fmt, message); + ee = ewend; else if (strcmp(applet, "esyslog") == 0) - elog(level, fmt, message); + ee = elog; else if (strcmp(applet, "veinfo") == 0) - einfov(fmt, message); + e = einfov; else if (strcmp(applet, "veinfon") == 0) - einfovn(fmt, message); + e = einfovn; else if (strcmp(applet, "vewarn") == 0) - ewarnv(fmt, message); + e = ewarnv; else if (strcmp(applet, "vewarnn") == 0) - ewarnvn(fmt, message); + e = ewarnvn; else if (strcmp(applet, "vebegin") == 0) - ebeginv(fmt, message); + e = ebeginv; else if (strcmp(applet, "veend") == 0) - eendv(retval, fmt, message); + ee = eendv; else if (strcmp(applet, "vewend") == 0) - ewendv(retval, fmt, message); + ee = ewendv; else if (strcmp(applet, "eindent") == 0) eindent(); else if (strcmp(applet, "eoutdent") == 0) @@ -236,6 +234,18 @@ static int do_e(int argc, char **argv) retval = EXIT_FAILURE; } + if (message) { + if (e) + e("%s", message); + else if (ee) + ee(retval, "%s", message); + } else { + if (e) + e(NULL); + else if (ee) + ee(retval, NULL); + } + free(message); return retval; } diff --git a/src/rc/rc-status.c b/src/rc/rc-status.c index a64ab1b5..41ac6519 100644 --- a/src/rc/rc-status.c +++ b/src/rc/rc-status.c @@ -289,6 +289,5 @@ exit: rc_stringlist_free(levels); rc_deptree_free(deptree); - exit(EXIT_SUCCESS); - /* NOTREACHED */ + return(EXIT_SUCCESS); } diff --git a/src/rc/rc.c b/src/rc/rc.c index 3d5a8175..f9cff8a9 100644 --- a/src/rc/rc.c +++ b/src/rc/rc.c @@ -354,7 +354,7 @@ static void sulogin(bool cont) #endif } -static void single_user(void) +_dead static void single_user(void) { rc_logger_close(); diff --git a/src/rc/runscript.c b/src/rc/runscript.c index 876503af..44cc2f85 100644 --- a/src/rc/runscript.c +++ b/src/rc/runscript.c @@ -547,18 +547,18 @@ static bool svc_wait(const char *svc) static RC_SERVICE svc_status(void) { char status[10]; - int (*e) (const char *fmt, ...) = &einfo; + int (*e) (const char *fmt, ...) __EINFO_PRINTF = einfo; RC_SERVICE state = rc_service_state(service); if (state & RC_SERVICE_STOPPING) { snprintf(status, sizeof(status), "stopping"); - e = &ewarn; + e = ewarn; } else if (state & RC_SERVICE_STARTING) { snprintf(status, sizeof(status), "starting"); - e = &ewarn; + e = ewarn; } else if (state & RC_SERVICE_INACTIVE) { snprintf(status, sizeof(status), "inactive"); - e = &ewarn; + e = ewarn; } else if (state & RC_SERVICE_STARTED) { errno = 0; if (_rc_can_find_pids() && @@ -566,7 +566,7 @@ static RC_SERVICE svc_status(void) errno != EACCES) { snprintf(status, sizeof(status), "crashed"); - e = &eerror; + e = eerror; } else snprintf(status, sizeof(status), "started"); } else diff --git a/src/rc/start-stop-daemon.c b/src/rc/start-stop-daemon.c index 3ee98496..045bad12 100644 --- a/src/rc/start-stop-daemon.c +++ b/src/rc/start-stop-daemon.c @@ -874,12 +874,11 @@ int start_stop_daemon(int argc, char **argv) opt = 0; for (nav = argv; *nav; nav++) opt++; - nav = xmalloc(sizeof(char *) * (opt + 3)); + nav = xmalloc(sizeof(char *) * (opt + 2)); nav[0] = exec_file; - nav[1] = (char *)"--"; for (i = 0; i < opt; i++) - nav[i + 2] = argv[i]; - nav[i + 2] = '\0'; + nav[i + 1] = argv[i]; + nav[i + 1] = '\0'; argv = nav; exec = exec_file; } -- cgit v1.2.3