aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorRoy Marples <roy@marples.name>2008-01-22 11:07:39 +0000
committerRoy Marples <roy@marples.name>2008-01-22 11:07:39 +0000
commit649a71055294e9fa275ebb406361cf46c843cade (patch)
tree273005e044ce31f28f187b4abbabf78f35b53d1b /src
parentb4bff9ce5efce83a7265a42d4372d367ca32f696 (diff)
Quiet some more lint warnings.
Diffstat (limited to 'src')
-rw-r--r--src/rc/_usage.c10
-rw-r--r--src/rc/checkpath.c7
-rw-r--r--src/rc/fstabinfo.c1
-rw-r--r--src/rc/mountinfo.c5
-rw-r--r--src/rc/rc-applets.c7
-rw-r--r--src/rc/rc-logger.c3
-rw-r--r--src/rc/rc-misc.c64
-rw-r--r--src/rc/rc-status.c6
-rw-r--r--src/rc/rc.c23
-rw-r--r--src/rc/runscript.c19
-rw-r--r--src/rc/start-stop-daemon.c24
11 files changed, 99 insertions, 70 deletions
diff --git a/src/rc/_usage.c b/src/rc/_usage.c
index 57cdb9a4..0e39271d 100644
--- a/src/rc/_usage.c
+++ b/src/rc/_usage.c
@@ -24,8 +24,14 @@
* SUCH DAMAGE.
*/
-__attribute__ ((__noreturn__))
-static void usage (int exit_status)
+#if lint
+# define _noreturn
+#endif
+#if __GNUC__ > 2 || defined(__INTEL_COMPILER)
+# define _noreturn __attribute__ ((__noreturn__))
+#endif
+
+_noreturn static void usage (int exit_status)
{
const char * const has_arg[] = { "", "<arg>", "[arg]" };
int i;
diff --git a/src/rc/checkpath.c b/src/rc/checkpath.c
index 3fb43792..4b57e187 100644
--- a/src/rc/checkpath.c
+++ b/src/rc/checkpath.c
@@ -116,7 +116,7 @@ static int parse_mode (mode_t *mode, char *text)
errno = EINVAL;
return (-1);
}
- *mode = l;
+ *mode = (mode_t) l;
return (0);
}
@@ -138,7 +138,7 @@ static int parse_owner (struct passwd **user, struct group **group,
if (user && *u) {
if (sscanf (u, "%d", &id) == 1)
- *user = getpwuid (id);
+ *user = getpwuid ((uid_t) id);
else
*user = getpwnam (u);
if (! *user)
@@ -147,7 +147,7 @@ static int parse_owner (struct passwd **user, struct group **group,
if (group && g && *g) {
if (sscanf (g, "%d", &id) == 1)
- *group = getgrgid (id);
+ *group = getgrgid ((gid_t) id);
else
*group = getgrnam (g);
if (! *group)
@@ -232,4 +232,5 @@ int checkpath (int argc, char **argv)
}
exit (retval);
+ /* NOTREACHED */
}
diff --git a/src/rc/fstabinfo.c b/src/rc/fstabinfo.c
index 6dba903b..4b674bc4 100644
--- a/src/rc/fstabinfo.c
+++ b/src/rc/fstabinfo.c
@@ -232,4 +232,5 @@ int fstabinfo (int argc, char **argv)
rc_strlist_free (files);
exit (result);
+ /* NOTREACHED */
}
diff --git a/src/rc/mountinfo.c b/src/rc/mountinfo.c
index 8a847b8f..7dc7d063 100644
--- a/src/rc/mountinfo.c
+++ b/src/rc/mountinfo.c
@@ -219,7 +219,7 @@ static char **find_mounts (struct args *args)
int i;
char **list = NULL;
char *options = NULL;
- int flags;
+ uint64_t flags;
struct opt *o;
if ((nmnts = getmntinfo (&mnts, MNT_NOWAIT)) == 0)
@@ -236,7 +236,7 @@ static char **find_mounts (struct args *args)
options = xstrdup (o->o_name);
else {
char *tmp = NULL;
- int l = strlen (options) + strlen (o->o_name) + 2;
+ size_t l = strlen (options) + strlen (o->o_name) + 2;
tmp = xmalloc (sizeof (char) * l);
snprintf (tmp, l, "%s,%s", options, o->o_name);
free (options);
@@ -476,4 +476,5 @@ int mountinfo (int argc, char **argv)
REG_FREE (skip_point_regex);
exit (result);
+ /* NOTREACHED */
}
diff --git a/src/rc/rc-applets.c b/src/rc/rc-applets.c
index fc362a28..7d7d04e5 100644
--- a/src/rc/rc-applets.c
+++ b/src/rc/rc-applets.c
@@ -37,6 +37,7 @@
#include <sys/types.h>
#include <errno.h>
#include <ctype.h>
+#include <inttypes.h>
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
@@ -71,7 +72,7 @@ static int do_e (int argc, char **argv)
{
int retval = EXIT_SUCCESS;
int i;
- int l = 0;
+ size_t l = 0;
char *message = NULL;
char *p;
int level = 0;
@@ -99,7 +100,7 @@ static int do_e (int argc, char **argv)
strcmp (applet, "vweend") == 0)
{
errno = 0;
- retval = strtol (argv[0], NULL, 0);
+ retval = (int) strtoimax (argv[0], NULL, 0);
if (errno != 0)
retval = EXIT_FAILURE;
else {
@@ -278,7 +279,7 @@ static int do_mark_service (int argc, char **argv)
char *runscript_pid = getenv ("RC_RUNSCRIPT_PID");
char *mtime;
pid_t pid = 0;
- int l;
+ size_t l;
if (runscript_pid && sscanf (runscript_pid, "%d", &pid) == 1)
if (kill (pid, SIGHUP) != 0)
diff --git a/src/rc/rc-logger.c b/src/rc/rc-logger.c
index 46093433..0545f826 100644
--- a/src/rc/rc-logger.c
+++ b/src/rc/rc-logger.c
@@ -191,7 +191,7 @@ void rc_logger_open (const char *level)
buffer = xmalloc (sizeof (char) * BUFSIZ);
selfd = rc_logger_tty > signal_pipe[0] ? rc_logger_tty : signal_pipe[0];
- while (1) {
+ for (;;) {
FD_ZERO (&rset);
FD_SET (rc_logger_tty, &rset);
FD_SET (signal_pipe[0], &rset);
@@ -244,6 +244,7 @@ void rc_logger_open (const char *level)
system (MOVELOG);
exit (0);
+ /* NOTREACHED */
default:
setpgid (rc_logger_pid, 0);
fd_stdout = dup (STDOUT_FILENO);
diff --git a/src/rc/rc-misc.c b/src/rc/rc-misc.c
index 02d30c54..1b79d2c8 100644
--- a/src/rc/rc-misc.c
+++ b/src/rc/rc-misc.c
@@ -106,12 +106,12 @@ char **env_filter (void)
int count = 0;
bool got_path = false;
char *env_var;
- int env_len;
+ size_t env_len;
char *token;
char *sep;
char *e;
char *p;
- int pplen = strlen (PATH_PREFIX);
+ size_t pplen = strlen (PATH_PREFIX);
/* Init a system whitelist, start with shell vars we need */
rc_strlist_add (&whitelist, "PATH");
@@ -273,7 +273,7 @@ char **env_config (void)
{
char **env = NULL;
char *line;
- int i;
+ size_t l;
#ifdef __linux__
char sys[6];
#endif
@@ -284,36 +284,36 @@ char **env_config (void)
char *p;
/* One char less to drop the trailing / */
- i = strlen ("RC_LIBDIR=") + strlen (RC_LIBDIR) + 1;
- line = xmalloc (sizeof (char) * i);
- snprintf (line, i, "RC_LIBDIR=" RC_LIBDIR);
+ l = strlen ("RC_LIBDIR=") + strlen (RC_LIBDIR) + 1;
+ line = xmalloc (sizeof (char) * l);
+ snprintf (line, l, "RC_LIBDIR=" RC_LIBDIR);
rc_strlist_add (&env, line);
free (line);
/* One char less to drop the trailing / */
- i = strlen ("RC_SVCDIR=") + strlen (RC_SVCDIR) + 1;
- line = xmalloc (sizeof (char) * i);
- snprintf (line, i, "RC_SVCDIR=" RC_SVCDIR);
+ l = strlen ("RC_SVCDIR=") + strlen (RC_SVCDIR) + 1;
+ line = xmalloc (sizeof (char) * l);
+ snprintf (line, l, "RC_SVCDIR=" RC_SVCDIR);
rc_strlist_add (&env, line);
free (line);
rc_strlist_add (&env, "RC_BOOTLEVEL=" RC_LEVEL_BOOT);
- i = strlen ("RC_SOFTLEVEL=") + strlen (runlevel) + 1;
- line = xmalloc (sizeof (char) * i);
- snprintf (line, i, "RC_SOFTLEVEL=%s", runlevel);
+ l = strlen ("RC_SOFTLEVEL=") + strlen (runlevel) + 1;
+ line = xmalloc (sizeof (char) * l);
+ snprintf (line, l, "RC_SOFTLEVEL=%s", runlevel);
rc_strlist_add (&env, line);
free (line);
if ((fp = fopen (RC_KSOFTLEVEL, "r"))) {
memset (buffer, 0, sizeof (buffer));
if (fgets (buffer, sizeof (buffer), fp)) {
- i = strlen (buffer) - 1;
- if (buffer[i] == '\n')
- buffer[i] = 0;
- i += strlen ("RC_DEFAULTLEVEL=") + 2;
- line = xmalloc (sizeof (char) * i);
- snprintf (line, i, "RC_DEFAULTLEVEL=%s", buffer);
+ l = strlen (buffer) - 1;
+ if (buffer[l] == '\n')
+ buffer[l] = 0;
+ l += strlen ("RC_DEFAULTLEVEL=") + 2;
+ line = xmalloc (sizeof (char) * l);
+ snprintf (line, l, "RC_DEFAULTLEVEL=%s", buffer);
rc_strlist_add (&env, line);
free (line);
}
@@ -344,9 +344,9 @@ char **env_config (void)
}
if (sys[0]) {
- i = strlen ("RC_SYS=") + strlen (sys) + 2;
- line = xmalloc (sizeof (char) * i);
- snprintf (line, i, "RC_SYS=%s", sys);
+ l = strlen ("RC_SYS=") + strlen (sys) + 2;
+ line = xmalloc (sizeof (char) * l);
+ snprintf (line, l, "RC_SYS=%s", sys);
rc_strlist_add (&env, line);
free (line);
}
@@ -356,25 +356,25 @@ char **env_config (void)
/* Some scripts may need to take a different code path if Linux/FreeBSD, etc
To save on calling uname, we store it in an environment variable */
if (uname (&uts) == 0) {
- i = strlen ("RC_UNAME=") + strlen (uts.sysname) + 2;
- line = xmalloc (sizeof (char) * i);
- snprintf (line, i, "RC_UNAME=%s", uts.sysname);
+ l = strlen ("RC_UNAME=") + strlen (uts.sysname) + 2;
+ line = xmalloc (sizeof (char) * l);
+ snprintf (line, l, "RC_UNAME=%s", uts.sysname);
rc_strlist_add (&env, line);
free (line);
}
/* Be quiet or verbose as necessary */
if ((p = rc_conf_value ("rc_quiet"))) {
- i = strlen ("EINFO_QUIET=") + strlen (p) + 1;
- line = xmalloc (sizeof (char) * i);
- snprintf (line, i, "EINFO_QUIET=%s", p);
+ l = strlen ("EINFO_QUIET=") + strlen (p) + 1;
+ line = xmalloc (sizeof (char) * l);
+ snprintf (line, l, "EINFO_QUIET=%s", p);
rc_strlist_add (&env, line);
free (line);
}
if ((p = rc_conf_value ("rc_verbose"))) {
- i = strlen ("EINFO_VERBOSE=") + strlen (p) + 1;
- line = xmalloc (sizeof (char) * i);
- snprintf (line, i, "EINFO_VERBOSE=%s", p);
+ l = strlen ("EINFO_VERBOSE=") + strlen (p) + 1;
+ line = xmalloc (sizeof (char) * l);
+ snprintf (line, l, "EINFO_VERBOSE=%s", p);
rc_strlist_add (&env, line);
free (line);
}
@@ -412,7 +412,9 @@ bool service_plugable (const char *service)
star = strchr (token, '*');
if (star) {
- if (strncmp (service, token, star - token) == 0) {
+ if (strncmp (service, token, (size_t) (star - token))
+ == 0)
+ {
allow = truefalse;
break;
}
diff --git a/src/rc/rc-status.c b/src/rc/rc-status.c
index 445e6e72..92822483 100644
--- a/src/rc/rc-status.c
+++ b/src/rc/rc-status.c
@@ -132,12 +132,14 @@ int rc_status (int argc, char **argv)
printf ("%s\n", level);
rc_strlist_free (levels);
exit (EXIT_SUCCESS);
+ /* NOTREACHED */
case 's':
services = rc_services_in_runlevel (NULL);
STRLIST_FOREACH (services, service, i)
print_service (service);
rc_strlist_free (services);
exit (EXIT_SUCCESS);
+ /* NOTREACHED */
case 'u':
services = rc_services_in_runlevel (NULL);
levels = rc_runlevel_list ();
@@ -154,6 +156,7 @@ int rc_status (int argc, char **argv)
rc_strlist_free (levels);
rc_strlist_free (services);
exit (EXIT_SUCCESS);
+ /* NOTREACHED */
case_RC_COMMON_GETOPT
}
@@ -193,5 +196,6 @@ int rc_status (int argc, char **argv)
rc_strlist_free (levels);
rc_deptree_free (deptree);
- return (EXIT_SUCCESS);
+ exit (EXIT_SUCCESS);
+ /* NOTREACHED */
}
diff --git a/src/rc/rc.c b/src/rc/rc.c
index 1ee7330a..790362f5 100644
--- a/src/rc/rc.c
+++ b/src/rc/rc.c
@@ -113,7 +113,7 @@ static void clean_failed (void)
{
DIR *dp;
struct dirent *d;
- int i;
+ size_t l;
char *path;
/* Clean the failed services state dir now */
@@ -124,9 +124,9 @@ static void clean_failed (void)
(d->d_name[1] == '.' && d->d_name[2] == '\0')))
continue;
- i = strlen (RC_SVCDIR "/failed/") + strlen (d->d_name) + 1;
- path = xmalloc (sizeof (char) * i);
- snprintf (path, i, RC_SVCDIR "/failed/%s", d->d_name);
+ l = strlen (RC_SVCDIR "/failed/") + strlen (d->d_name) + 1;
+ path = xmalloc (sizeof (char) * l);
+ snprintf (path, l, RC_SVCDIR "/failed/%s", d->d_name);
if (path) {
if (unlink (path))
eerror ("%s: unlink `%s': %s", applet, path,
@@ -467,13 +467,16 @@ static void handle_signal (int sig)
case SIGINT:
if (! signame[0])
snprintf (signame, sizeof (signame), "SIGINT");
+ /* FALLTHROUGH */
case SIGTERM:
if (! signame[0])
snprintf (signame, sizeof (signame), "SIGTERM");
+ /* FALLTHROUGH */
case SIGQUIT:
if (! signame[0])
snprintf (signame, sizeof (signame), "SIGQUIT");
eerrorx ("%s: caught %s, aborting", applet, signame);
+ /* NOTREACHED */
case SIGUSR1:
eerror ("rc: Aborting!");
/* Kill any running services we have started */
@@ -495,7 +498,7 @@ static void handle_signal (int sig)
single_user ();
exit (EXIT_FAILURE);
- break;
+ /* NOTREACHED */
default:
eerror ("%s: caught unknown signal %d", applet, sig);
@@ -637,6 +640,7 @@ int main (int argc, char **argv)
if (*optarg == '\0')
optarg = NULL;
exit (set_ksoftlevel (optarg) ? EXIT_SUCCESS : EXIT_FAILURE);
+ /* NOTREACHED */
case_RC_COMMON_GETOPT
}
}
@@ -891,9 +895,10 @@ int main (int argc, char **argv)
{
char *p = d->d_name + 3;
if (p && isdigit ((int) *p)) {
- i = (strlen ("moused.") + strlen (d->d_name) + 1);
- tmp = xmalloc (sizeof (char) * i);
- snprintf (tmp, i, "moused.%s", d->d_name);
+ size_t len;
+ len = (strlen ("moused.") + strlen (d->d_name) + 1);
+ tmp = xmalloc (sizeof (char) * len);
+ snprintf (tmp, len, "moused.%s", d->d_name);
if (rc_service_exists (tmp) &&
service_plugable (tmp))
rc_service_mark (tmp, RC_SERVICE_COLDPLUGGED);
@@ -1007,7 +1012,7 @@ int main (int argc, char **argv)
/* Unless we would use a different config file */
if (found) {
- int len;
+ size_t len;
if (! newlevel)
continue;
diff --git a/src/rc/runscript.c b/src/rc/runscript.c
index 11432164..9324203a 100644
--- a/src/rc/runscript.c
+++ b/src/rc/runscript.c
@@ -175,9 +175,11 @@ static void handle_signal (int sig)
case SIGINT:
if (! signame[0])
snprintf (signame, sizeof (signame), "SIGINT");
+ /* FALLTHROUGH */
case SIGTERM:
if (! signame[0])
snprintf (signame, sizeof (signame), "SIGTERM");
+ /* FALLTHROUGH */
case SIGQUIT:
if (! signame[0])
snprintf (signame, sizeof (signame), "SIGQUIT");
@@ -185,6 +187,7 @@ static void handle_signal (int sig)
if (service_pid > 0)
kill (service_pid, sig);
eerrorx ("%s: caught %s, aborting", applet, signame);
+ /* NOTREACHED */
default:
eerror ("%s: caught unknown signal %d", applet, sig);
@@ -579,7 +582,7 @@ static rc_service_state_t svc_status ()
static void make_exclusive ()
{
char *path;
- int i;
+ size_t l;
/* We create a fifo so that other services can wait until we complete */
if (! exclusive)
@@ -591,9 +594,9 @@ static void make_exclusive ()
applet, exclusive, strerror (errno));
path = rc_strcatpaths (RC_SVCDIR, "exclusive", applet, (char *) NULL);
- i = strlen (path) + 16;
- mtime_test = xmalloc (sizeof (char) * i);
- snprintf (mtime_test, i, "%s.%d", path, getpid ());
+ l = strlen (path) + 16;
+ mtime_test = xmalloc (sizeof (char) * l);
+ snprintf (mtime_test, l, "%s.%d", path, getpid ());
free (path);
if (exists (mtime_test) && unlink (mtime_test) != 0) {
@@ -760,7 +763,7 @@ static void svc_start (bool deps)
if (tmplist) {
int n = 0;
- int len = 0;
+ size_t len = 0;
char *p;
/* Set the state now, then unlink our exclusive so that
@@ -1039,7 +1042,7 @@ static const char * const longopts_help[] = {
int runscript (int argc, char **argv)
{
- int i;
+ size_t i;
bool deps = true;
bool doneone = false;
char pid[16];
@@ -1136,8 +1139,8 @@ int runscript (int argc, char **argv)
/* eprefix is kinda klunky, but it works for our purposes */
if (rc_conf_yesno ("rc_parallel")) {
- int l = 0;
- int ll;
+ size_t l = 0;
+ size_t ll;
/* Get the longest service name */
services = rc_services_in_runlevel (NULL);
diff --git a/src/rc/start-stop-daemon.c b/src/rc/start-stop-daemon.c
index c2293e4e..85930902 100644
--- a/src/rc/start-stop-daemon.c
+++ b/src/rc/start-stop-daemon.c
@@ -150,7 +150,7 @@ static int parse_signal (const char *sig)
};
unsigned int i = 0;
- char *s;
+ const char *s;
if (! sig || *sig == '\0')
return (-1);
@@ -162,7 +162,7 @@ static int parse_signal (const char *sig)
}
if (strncmp (sig, "SIG", 3) == 0)
- s = (char *) sig + 3;
+ s = sig + 3;
else
s = NULL;
@@ -172,6 +172,7 @@ static int parse_signal (const char *sig)
return (signallist[i].signal);
eerrorx ("%s: `%s' is not a valid signal", applet, sig);
+ /* NOTREACHED */
}
static void parse_schedule_item (schedulelist_t *item, const char *string)
@@ -203,7 +204,7 @@ static void parse_schedule (const char *string, int default_signal)
const char *slash;
int count = 0;
schedulelist_t *repeatat = NULL;
- ptrdiff_t len;
+ size_t len;
schedulelist_t *next;
if (string)
@@ -446,7 +447,6 @@ static int run_stop_schedule (const char *exec, const char *cmd,
static void handle_signal (int sig)
{
- int pid;
int status;
int serrno = errno;
char signame[10] = { '\0' };
@@ -455,17 +455,20 @@ static void handle_signal (int sig)
case SIGINT:
if (! signame[0])
snprintf (signame, sizeof (signame), "SIGINT");
+ /* FALLTHROUGH */
case SIGTERM:
if (! signame[0])
snprintf (signame, sizeof (signame), "SIGTERM");
+ /* FALLTHROUGH */
case SIGQUIT:
if (! signame[0])
snprintf (signame, sizeof (signame), "SIGQUIT");
eerrorx ("%s: caught %s, aborting", applet, signame);
+ /* NOTREACHED */
case SIGCHLD:
- while (1) {
- if ((pid = waitpid (-1, &status, WNOHANG)) < 0) {
+ for (;;) {
+ if (waitpid (-1, &status, WNOHANG) < 0) {
if (errno != ECHILD)
eerror ("%s: waitpid: %s", applet, strerror (errno));
break;
@@ -618,7 +621,7 @@ int start_stop_daemon (int argc, char **argv)
if (sscanf (cu, "%d", &tid) != 1)
pw = getpwnam (cu);
else
- pw = getpwuid (tid);
+ pw = getpwuid ((uid_t) tid);
if (! pw)
eerrorx ("%s: user `%s' not found", applet, cu);
@@ -633,7 +636,7 @@ int start_stop_daemon (int argc, char **argv)
if (sscanf (cg, "%d", &tid) != 1)
gr = getgrnam (cg);
else
- gr = getgrgid (tid);
+ gr = getgrgid ((gid_t) tid);
if (! gr)
eerrorx ("%s: group `%s' not found", applet, cg);
@@ -653,7 +656,7 @@ int start_stop_daemon (int argc, char **argv)
if (sscanf (optarg, "%d", &tid) != 1)
gr = getgrnam (optarg);
else
- gr = getgrgid (tid);
+ gr = getgrgid ((gid_t) tid);
if (! gr)
eerrorx ("%s: group `%s' not found", applet, optarg);
@@ -912,7 +915,7 @@ int start_stop_daemon (int argc, char **argv)
char *p = path;
char *token;
char *np;
- int l;
+ size_t l;
int t;
p += 5;
@@ -1067,4 +1070,5 @@ int start_stop_daemon (int argc, char **argv)
rc_service_daemon_set (svcname, exec, cmd, pidfile, true);
exit (EXIT_SUCCESS);
+ /* NOTREACHED */
}