Clean up some compile warnings.

This commit is contained in:
Roy Marples 2008-09-18 13:09:51 +00:00
parent 39304745d4
commit 80a17eb596
9 changed files with 50 additions and 40 deletions

View File

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

View File

@ -208,6 +208,5 @@ int checkpath(int argc, char **argv)
optind++;
}
exit(retval);
/* NOTREACHED */
return retval;
}

View File

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

View File

@ -481,6 +481,5 @@ int mountinfo(int argc, char **argv)
REG_FREE(point_regex);
REG_FREE(skip_point_regex);
exit(result);
/* NOTREACHED */
return result;
}

View File

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

View File

@ -289,6 +289,5 @@ exit:
rc_stringlist_free(levels);
rc_deptree_free(deptree);
exit(EXIT_SUCCESS);
/* NOTREACHED */
return(EXIT_SUCCESS);
}

View File

@ -354,7 +354,7 @@ static void sulogin(bool cont)
#endif
}
static void single_user(void)
_dead static void single_user(void)
{
rc_logger_close();

View File

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

View File

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