Quiet some more lint warnings.
This commit is contained in:
parent
b4bff9ce5e
commit
649a710552
@ -24,8 +24,14 @@
|
|||||||
* SUCH DAMAGE.
|
* SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
__attribute__ ((__noreturn__))
|
#if lint
|
||||||
static void usage (int exit_status)
|
# 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]" };
|
const char * const has_arg[] = { "", "<arg>", "[arg]" };
|
||||||
int i;
|
int i;
|
||||||
|
@ -116,7 +116,7 @@ static int parse_mode (mode_t *mode, char *text)
|
|||||||
errno = EINVAL;
|
errno = EINVAL;
|
||||||
return (-1);
|
return (-1);
|
||||||
}
|
}
|
||||||
*mode = l;
|
*mode = (mode_t) l;
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -138,7 +138,7 @@ static int parse_owner (struct passwd **user, struct group **group,
|
|||||||
|
|
||||||
if (user && *u) {
|
if (user && *u) {
|
||||||
if (sscanf (u, "%d", &id) == 1)
|
if (sscanf (u, "%d", &id) == 1)
|
||||||
*user = getpwuid (id);
|
*user = getpwuid ((uid_t) id);
|
||||||
else
|
else
|
||||||
*user = getpwnam (u);
|
*user = getpwnam (u);
|
||||||
if (! *user)
|
if (! *user)
|
||||||
@ -147,7 +147,7 @@ static int parse_owner (struct passwd **user, struct group **group,
|
|||||||
|
|
||||||
if (group && g && *g) {
|
if (group && g && *g) {
|
||||||
if (sscanf (g, "%d", &id) == 1)
|
if (sscanf (g, "%d", &id) == 1)
|
||||||
*group = getgrgid (id);
|
*group = getgrgid ((gid_t) id);
|
||||||
else
|
else
|
||||||
*group = getgrnam (g);
|
*group = getgrnam (g);
|
||||||
if (! *group)
|
if (! *group)
|
||||||
@ -232,4 +232,5 @@ int checkpath (int argc, char **argv)
|
|||||||
}
|
}
|
||||||
|
|
||||||
exit (retval);
|
exit (retval);
|
||||||
|
/* NOTREACHED */
|
||||||
}
|
}
|
||||||
|
@ -232,4 +232,5 @@ int fstabinfo (int argc, char **argv)
|
|||||||
|
|
||||||
rc_strlist_free (files);
|
rc_strlist_free (files);
|
||||||
exit (result);
|
exit (result);
|
||||||
|
/* NOTREACHED */
|
||||||
}
|
}
|
||||||
|
@ -219,7 +219,7 @@ static char **find_mounts (struct args *args)
|
|||||||
int i;
|
int i;
|
||||||
char **list = NULL;
|
char **list = NULL;
|
||||||
char *options = NULL;
|
char *options = NULL;
|
||||||
int flags;
|
uint64_t flags;
|
||||||
struct opt *o;
|
struct opt *o;
|
||||||
|
|
||||||
if ((nmnts = getmntinfo (&mnts, MNT_NOWAIT)) == 0)
|
if ((nmnts = getmntinfo (&mnts, MNT_NOWAIT)) == 0)
|
||||||
@ -236,7 +236,7 @@ static char **find_mounts (struct args *args)
|
|||||||
options = xstrdup (o->o_name);
|
options = xstrdup (o->o_name);
|
||||||
else {
|
else {
|
||||||
char *tmp = NULL;
|
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);
|
tmp = xmalloc (sizeof (char) * l);
|
||||||
snprintf (tmp, l, "%s,%s", options, o->o_name);
|
snprintf (tmp, l, "%s,%s", options, o->o_name);
|
||||||
free (options);
|
free (options);
|
||||||
@ -476,4 +476,5 @@ int mountinfo (int argc, char **argv)
|
|||||||
REG_FREE (skip_point_regex);
|
REG_FREE (skip_point_regex);
|
||||||
|
|
||||||
exit (result);
|
exit (result);
|
||||||
|
/* NOTREACHED */
|
||||||
}
|
}
|
||||||
|
@ -37,6 +37,7 @@
|
|||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
|
#include <inttypes.h>
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
@ -71,7 +72,7 @@ static int do_e (int argc, char **argv)
|
|||||||
{
|
{
|
||||||
int retval = EXIT_SUCCESS;
|
int retval = EXIT_SUCCESS;
|
||||||
int i;
|
int i;
|
||||||
int l = 0;
|
size_t l = 0;
|
||||||
char *message = NULL;
|
char *message = NULL;
|
||||||
char *p;
|
char *p;
|
||||||
int level = 0;
|
int level = 0;
|
||||||
@ -99,7 +100,7 @@ static int do_e (int argc, char **argv)
|
|||||||
strcmp (applet, "vweend") == 0)
|
strcmp (applet, "vweend") == 0)
|
||||||
{
|
{
|
||||||
errno = 0;
|
errno = 0;
|
||||||
retval = strtol (argv[0], NULL, 0);
|
retval = (int) strtoimax (argv[0], NULL, 0);
|
||||||
if (errno != 0)
|
if (errno != 0)
|
||||||
retval = EXIT_FAILURE;
|
retval = EXIT_FAILURE;
|
||||||
else {
|
else {
|
||||||
@ -278,7 +279,7 @@ static int do_mark_service (int argc, char **argv)
|
|||||||
char *runscript_pid = getenv ("RC_RUNSCRIPT_PID");
|
char *runscript_pid = getenv ("RC_RUNSCRIPT_PID");
|
||||||
char *mtime;
|
char *mtime;
|
||||||
pid_t pid = 0;
|
pid_t pid = 0;
|
||||||
int l;
|
size_t l;
|
||||||
|
|
||||||
if (runscript_pid && sscanf (runscript_pid, "%d", &pid) == 1)
|
if (runscript_pid && sscanf (runscript_pid, "%d", &pid) == 1)
|
||||||
if (kill (pid, SIGHUP) != 0)
|
if (kill (pid, SIGHUP) != 0)
|
||||||
|
@ -191,7 +191,7 @@ void rc_logger_open (const char *level)
|
|||||||
|
|
||||||
buffer = xmalloc (sizeof (char) * BUFSIZ);
|
buffer = xmalloc (sizeof (char) * BUFSIZ);
|
||||||
selfd = rc_logger_tty > signal_pipe[0] ? rc_logger_tty : signal_pipe[0];
|
selfd = rc_logger_tty > signal_pipe[0] ? rc_logger_tty : signal_pipe[0];
|
||||||
while (1) {
|
for (;;) {
|
||||||
FD_ZERO (&rset);
|
FD_ZERO (&rset);
|
||||||
FD_SET (rc_logger_tty, &rset);
|
FD_SET (rc_logger_tty, &rset);
|
||||||
FD_SET (signal_pipe[0], &rset);
|
FD_SET (signal_pipe[0], &rset);
|
||||||
@ -244,6 +244,7 @@ void rc_logger_open (const char *level)
|
|||||||
system (MOVELOG);
|
system (MOVELOG);
|
||||||
|
|
||||||
exit (0);
|
exit (0);
|
||||||
|
/* NOTREACHED */
|
||||||
default:
|
default:
|
||||||
setpgid (rc_logger_pid, 0);
|
setpgid (rc_logger_pid, 0);
|
||||||
fd_stdout = dup (STDOUT_FILENO);
|
fd_stdout = dup (STDOUT_FILENO);
|
||||||
|
@ -106,12 +106,12 @@ char **env_filter (void)
|
|||||||
int count = 0;
|
int count = 0;
|
||||||
bool got_path = false;
|
bool got_path = false;
|
||||||
char *env_var;
|
char *env_var;
|
||||||
int env_len;
|
size_t env_len;
|
||||||
char *token;
|
char *token;
|
||||||
char *sep;
|
char *sep;
|
||||||
char *e;
|
char *e;
|
||||||
char *p;
|
char *p;
|
||||||
int pplen = strlen (PATH_PREFIX);
|
size_t pplen = strlen (PATH_PREFIX);
|
||||||
|
|
||||||
/* Init a system whitelist, start with shell vars we need */
|
/* Init a system whitelist, start with shell vars we need */
|
||||||
rc_strlist_add (&whitelist, "PATH");
|
rc_strlist_add (&whitelist, "PATH");
|
||||||
@ -273,7 +273,7 @@ char **env_config (void)
|
|||||||
{
|
{
|
||||||
char **env = NULL;
|
char **env = NULL;
|
||||||
char *line;
|
char *line;
|
||||||
int i;
|
size_t l;
|
||||||
#ifdef __linux__
|
#ifdef __linux__
|
||||||
char sys[6];
|
char sys[6];
|
||||||
#endif
|
#endif
|
||||||
@ -284,36 +284,36 @@ char **env_config (void)
|
|||||||
char *p;
|
char *p;
|
||||||
|
|
||||||
/* One char less to drop the trailing / */
|
/* One char less to drop the trailing / */
|
||||||
i = strlen ("RC_LIBDIR=") + strlen (RC_LIBDIR) + 1;
|
l = strlen ("RC_LIBDIR=") + strlen (RC_LIBDIR) + 1;
|
||||||
line = xmalloc (sizeof (char) * i);
|
line = xmalloc (sizeof (char) * l);
|
||||||
snprintf (line, i, "RC_LIBDIR=" RC_LIBDIR);
|
snprintf (line, l, "RC_LIBDIR=" RC_LIBDIR);
|
||||||
rc_strlist_add (&env, line);
|
rc_strlist_add (&env, line);
|
||||||
free (line);
|
free (line);
|
||||||
|
|
||||||
/* One char less to drop the trailing / */
|
/* One char less to drop the trailing / */
|
||||||
i = strlen ("RC_SVCDIR=") + strlen (RC_SVCDIR) + 1;
|
l = strlen ("RC_SVCDIR=") + strlen (RC_SVCDIR) + 1;
|
||||||
line = xmalloc (sizeof (char) * i);
|
line = xmalloc (sizeof (char) * l);
|
||||||
snprintf (line, i, "RC_SVCDIR=" RC_SVCDIR);
|
snprintf (line, l, "RC_SVCDIR=" RC_SVCDIR);
|
||||||
rc_strlist_add (&env, line);
|
rc_strlist_add (&env, line);
|
||||||
free (line);
|
free (line);
|
||||||
|
|
||||||
rc_strlist_add (&env, "RC_BOOTLEVEL=" RC_LEVEL_BOOT);
|
rc_strlist_add (&env, "RC_BOOTLEVEL=" RC_LEVEL_BOOT);
|
||||||
|
|
||||||
i = strlen ("RC_SOFTLEVEL=") + strlen (runlevel) + 1;
|
l = strlen ("RC_SOFTLEVEL=") + strlen (runlevel) + 1;
|
||||||
line = xmalloc (sizeof (char) * i);
|
line = xmalloc (sizeof (char) * l);
|
||||||
snprintf (line, i, "RC_SOFTLEVEL=%s", runlevel);
|
snprintf (line, l, "RC_SOFTLEVEL=%s", runlevel);
|
||||||
rc_strlist_add (&env, line);
|
rc_strlist_add (&env, line);
|
||||||
free (line);
|
free (line);
|
||||||
|
|
||||||
if ((fp = fopen (RC_KSOFTLEVEL, "r"))) {
|
if ((fp = fopen (RC_KSOFTLEVEL, "r"))) {
|
||||||
memset (buffer, 0, sizeof (buffer));
|
memset (buffer, 0, sizeof (buffer));
|
||||||
if (fgets (buffer, sizeof (buffer), fp)) {
|
if (fgets (buffer, sizeof (buffer), fp)) {
|
||||||
i = strlen (buffer) - 1;
|
l = strlen (buffer) - 1;
|
||||||
if (buffer[i] == '\n')
|
if (buffer[l] == '\n')
|
||||||
buffer[i] = 0;
|
buffer[l] = 0;
|
||||||
i += strlen ("RC_DEFAULTLEVEL=") + 2;
|
l += strlen ("RC_DEFAULTLEVEL=") + 2;
|
||||||
line = xmalloc (sizeof (char) * i);
|
line = xmalloc (sizeof (char) * l);
|
||||||
snprintf (line, i, "RC_DEFAULTLEVEL=%s", buffer);
|
snprintf (line, l, "RC_DEFAULTLEVEL=%s", buffer);
|
||||||
rc_strlist_add (&env, line);
|
rc_strlist_add (&env, line);
|
||||||
free (line);
|
free (line);
|
||||||
}
|
}
|
||||||
@ -344,9 +344,9 @@ char **env_config (void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (sys[0]) {
|
if (sys[0]) {
|
||||||
i = strlen ("RC_SYS=") + strlen (sys) + 2;
|
l = strlen ("RC_SYS=") + strlen (sys) + 2;
|
||||||
line = xmalloc (sizeof (char) * i);
|
line = xmalloc (sizeof (char) * l);
|
||||||
snprintf (line, i, "RC_SYS=%s", sys);
|
snprintf (line, l, "RC_SYS=%s", sys);
|
||||||
rc_strlist_add (&env, line);
|
rc_strlist_add (&env, line);
|
||||||
free (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
|
/* 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 */
|
To save on calling uname, we store it in an environment variable */
|
||||||
if (uname (&uts) == 0) {
|
if (uname (&uts) == 0) {
|
||||||
i = strlen ("RC_UNAME=") + strlen (uts.sysname) + 2;
|
l = strlen ("RC_UNAME=") + strlen (uts.sysname) + 2;
|
||||||
line = xmalloc (sizeof (char) * i);
|
line = xmalloc (sizeof (char) * l);
|
||||||
snprintf (line, i, "RC_UNAME=%s", uts.sysname);
|
snprintf (line, l, "RC_UNAME=%s", uts.sysname);
|
||||||
rc_strlist_add (&env, line);
|
rc_strlist_add (&env, line);
|
||||||
free (line);
|
free (line);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Be quiet or verbose as necessary */
|
/* Be quiet or verbose as necessary */
|
||||||
if ((p = rc_conf_value ("rc_quiet"))) {
|
if ((p = rc_conf_value ("rc_quiet"))) {
|
||||||
i = strlen ("EINFO_QUIET=") + strlen (p) + 1;
|
l = strlen ("EINFO_QUIET=") + strlen (p) + 1;
|
||||||
line = xmalloc (sizeof (char) * i);
|
line = xmalloc (sizeof (char) * l);
|
||||||
snprintf (line, i, "EINFO_QUIET=%s", p);
|
snprintf (line, l, "EINFO_QUIET=%s", p);
|
||||||
rc_strlist_add (&env, line);
|
rc_strlist_add (&env, line);
|
||||||
free (line);
|
free (line);
|
||||||
}
|
}
|
||||||
if ((p = rc_conf_value ("rc_verbose"))) {
|
if ((p = rc_conf_value ("rc_verbose"))) {
|
||||||
i = strlen ("EINFO_VERBOSE=") + strlen (p) + 1;
|
l = strlen ("EINFO_VERBOSE=") + strlen (p) + 1;
|
||||||
line = xmalloc (sizeof (char) * i);
|
line = xmalloc (sizeof (char) * l);
|
||||||
snprintf (line, i, "EINFO_VERBOSE=%s", p);
|
snprintf (line, l, "EINFO_VERBOSE=%s", p);
|
||||||
rc_strlist_add (&env, line);
|
rc_strlist_add (&env, line);
|
||||||
free (line);
|
free (line);
|
||||||
}
|
}
|
||||||
@ -412,7 +412,9 @@ bool service_plugable (const char *service)
|
|||||||
|
|
||||||
star = strchr (token, '*');
|
star = strchr (token, '*');
|
||||||
if (star) {
|
if (star) {
|
||||||
if (strncmp (service, token, star - token) == 0) {
|
if (strncmp (service, token, (size_t) (star - token))
|
||||||
|
== 0)
|
||||||
|
{
|
||||||
allow = truefalse;
|
allow = truefalse;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -132,12 +132,14 @@ int rc_status (int argc, char **argv)
|
|||||||
printf ("%s\n", level);
|
printf ("%s\n", level);
|
||||||
rc_strlist_free (levels);
|
rc_strlist_free (levels);
|
||||||
exit (EXIT_SUCCESS);
|
exit (EXIT_SUCCESS);
|
||||||
|
/* NOTREACHED */
|
||||||
case 's':
|
case 's':
|
||||||
services = rc_services_in_runlevel (NULL);
|
services = rc_services_in_runlevel (NULL);
|
||||||
STRLIST_FOREACH (services, service, i)
|
STRLIST_FOREACH (services, service, i)
|
||||||
print_service (service);
|
print_service (service);
|
||||||
rc_strlist_free (services);
|
rc_strlist_free (services);
|
||||||
exit (EXIT_SUCCESS);
|
exit (EXIT_SUCCESS);
|
||||||
|
/* NOTREACHED */
|
||||||
case 'u':
|
case 'u':
|
||||||
services = rc_services_in_runlevel (NULL);
|
services = rc_services_in_runlevel (NULL);
|
||||||
levels = rc_runlevel_list ();
|
levels = rc_runlevel_list ();
|
||||||
@ -154,6 +156,7 @@ int rc_status (int argc, char **argv)
|
|||||||
rc_strlist_free (levels);
|
rc_strlist_free (levels);
|
||||||
rc_strlist_free (services);
|
rc_strlist_free (services);
|
||||||
exit (EXIT_SUCCESS);
|
exit (EXIT_SUCCESS);
|
||||||
|
/* NOTREACHED */
|
||||||
|
|
||||||
case_RC_COMMON_GETOPT
|
case_RC_COMMON_GETOPT
|
||||||
}
|
}
|
||||||
@ -193,5 +196,6 @@ int rc_status (int argc, char **argv)
|
|||||||
rc_strlist_free (levels);
|
rc_strlist_free (levels);
|
||||||
rc_deptree_free (deptree);
|
rc_deptree_free (deptree);
|
||||||
|
|
||||||
return (EXIT_SUCCESS);
|
exit (EXIT_SUCCESS);
|
||||||
|
/* NOTREACHED */
|
||||||
}
|
}
|
||||||
|
23
src/rc/rc.c
23
src/rc/rc.c
@ -113,7 +113,7 @@ static void clean_failed (void)
|
|||||||
{
|
{
|
||||||
DIR *dp;
|
DIR *dp;
|
||||||
struct dirent *d;
|
struct dirent *d;
|
||||||
int i;
|
size_t l;
|
||||||
char *path;
|
char *path;
|
||||||
|
|
||||||
/* Clean the failed services state dir now */
|
/* 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')))
|
(d->d_name[1] == '.' && d->d_name[2] == '\0')))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
i = strlen (RC_SVCDIR "/failed/") + strlen (d->d_name) + 1;
|
l = strlen (RC_SVCDIR "/failed/") + strlen (d->d_name) + 1;
|
||||||
path = xmalloc (sizeof (char) * i);
|
path = xmalloc (sizeof (char) * l);
|
||||||
snprintf (path, i, RC_SVCDIR "/failed/%s", d->d_name);
|
snprintf (path, l, RC_SVCDIR "/failed/%s", d->d_name);
|
||||||
if (path) {
|
if (path) {
|
||||||
if (unlink (path))
|
if (unlink (path))
|
||||||
eerror ("%s: unlink `%s': %s", applet, path,
|
eerror ("%s: unlink `%s': %s", applet, path,
|
||||||
@ -467,13 +467,16 @@ static void handle_signal (int sig)
|
|||||||
case SIGINT:
|
case SIGINT:
|
||||||
if (! signame[0])
|
if (! signame[0])
|
||||||
snprintf (signame, sizeof (signame), "SIGINT");
|
snprintf (signame, sizeof (signame), "SIGINT");
|
||||||
|
/* FALLTHROUGH */
|
||||||
case SIGTERM:
|
case SIGTERM:
|
||||||
if (! signame[0])
|
if (! signame[0])
|
||||||
snprintf (signame, sizeof (signame), "SIGTERM");
|
snprintf (signame, sizeof (signame), "SIGTERM");
|
||||||
|
/* FALLTHROUGH */
|
||||||
case SIGQUIT:
|
case SIGQUIT:
|
||||||
if (! signame[0])
|
if (! signame[0])
|
||||||
snprintf (signame, sizeof (signame), "SIGQUIT");
|
snprintf (signame, sizeof (signame), "SIGQUIT");
|
||||||
eerrorx ("%s: caught %s, aborting", applet, signame);
|
eerrorx ("%s: caught %s, aborting", applet, signame);
|
||||||
|
/* NOTREACHED */
|
||||||
case SIGUSR1:
|
case SIGUSR1:
|
||||||
eerror ("rc: Aborting!");
|
eerror ("rc: Aborting!");
|
||||||
/* Kill any running services we have started */
|
/* Kill any running services we have started */
|
||||||
@ -495,7 +498,7 @@ static void handle_signal (int sig)
|
|||||||
single_user ();
|
single_user ();
|
||||||
|
|
||||||
exit (EXIT_FAILURE);
|
exit (EXIT_FAILURE);
|
||||||
break;
|
/* NOTREACHED */
|
||||||
|
|
||||||
default:
|
default:
|
||||||
eerror ("%s: caught unknown signal %d", applet, sig);
|
eerror ("%s: caught unknown signal %d", applet, sig);
|
||||||
@ -637,6 +640,7 @@ int main (int argc, char **argv)
|
|||||||
if (*optarg == '\0')
|
if (*optarg == '\0')
|
||||||
optarg = NULL;
|
optarg = NULL;
|
||||||
exit (set_ksoftlevel (optarg) ? EXIT_SUCCESS : EXIT_FAILURE);
|
exit (set_ksoftlevel (optarg) ? EXIT_SUCCESS : EXIT_FAILURE);
|
||||||
|
/* NOTREACHED */
|
||||||
case_RC_COMMON_GETOPT
|
case_RC_COMMON_GETOPT
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -891,9 +895,10 @@ int main (int argc, char **argv)
|
|||||||
{
|
{
|
||||||
char *p = d->d_name + 3;
|
char *p = d->d_name + 3;
|
||||||
if (p && isdigit ((int) *p)) {
|
if (p && isdigit ((int) *p)) {
|
||||||
i = (strlen ("moused.") + strlen (d->d_name) + 1);
|
size_t len;
|
||||||
tmp = xmalloc (sizeof (char) * i);
|
len = (strlen ("moused.") + strlen (d->d_name) + 1);
|
||||||
snprintf (tmp, i, "moused.%s", d->d_name);
|
tmp = xmalloc (sizeof (char) * len);
|
||||||
|
snprintf (tmp, len, "moused.%s", d->d_name);
|
||||||
if (rc_service_exists (tmp) &&
|
if (rc_service_exists (tmp) &&
|
||||||
service_plugable (tmp))
|
service_plugable (tmp))
|
||||||
rc_service_mark (tmp, RC_SERVICE_COLDPLUGGED);
|
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 */
|
/* Unless we would use a different config file */
|
||||||
if (found) {
|
if (found) {
|
||||||
int len;
|
size_t len;
|
||||||
if (! newlevel)
|
if (! newlevel)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
@ -175,9 +175,11 @@ static void handle_signal (int sig)
|
|||||||
case SIGINT:
|
case SIGINT:
|
||||||
if (! signame[0])
|
if (! signame[0])
|
||||||
snprintf (signame, sizeof (signame), "SIGINT");
|
snprintf (signame, sizeof (signame), "SIGINT");
|
||||||
|
/* FALLTHROUGH */
|
||||||
case SIGTERM:
|
case SIGTERM:
|
||||||
if (! signame[0])
|
if (! signame[0])
|
||||||
snprintf (signame, sizeof (signame), "SIGTERM");
|
snprintf (signame, sizeof (signame), "SIGTERM");
|
||||||
|
/* FALLTHROUGH */
|
||||||
case SIGQUIT:
|
case SIGQUIT:
|
||||||
if (! signame[0])
|
if (! signame[0])
|
||||||
snprintf (signame, sizeof (signame), "SIGQUIT");
|
snprintf (signame, sizeof (signame), "SIGQUIT");
|
||||||
@ -185,6 +187,7 @@ static void handle_signal (int sig)
|
|||||||
if (service_pid > 0)
|
if (service_pid > 0)
|
||||||
kill (service_pid, sig);
|
kill (service_pid, sig);
|
||||||
eerrorx ("%s: caught %s, aborting", applet, signame);
|
eerrorx ("%s: caught %s, aborting", applet, signame);
|
||||||
|
/* NOTREACHED */
|
||||||
|
|
||||||
default:
|
default:
|
||||||
eerror ("%s: caught unknown signal %d", applet, sig);
|
eerror ("%s: caught unknown signal %d", applet, sig);
|
||||||
@ -579,7 +582,7 @@ static rc_service_state_t svc_status ()
|
|||||||
static void make_exclusive ()
|
static void make_exclusive ()
|
||||||
{
|
{
|
||||||
char *path;
|
char *path;
|
||||||
int i;
|
size_t l;
|
||||||
|
|
||||||
/* We create a fifo so that other services can wait until we complete */
|
/* We create a fifo so that other services can wait until we complete */
|
||||||
if (! exclusive)
|
if (! exclusive)
|
||||||
@ -591,9 +594,9 @@ static void make_exclusive ()
|
|||||||
applet, exclusive, strerror (errno));
|
applet, exclusive, strerror (errno));
|
||||||
|
|
||||||
path = rc_strcatpaths (RC_SVCDIR, "exclusive", applet, (char *) NULL);
|
path = rc_strcatpaths (RC_SVCDIR, "exclusive", applet, (char *) NULL);
|
||||||
i = strlen (path) + 16;
|
l = strlen (path) + 16;
|
||||||
mtime_test = xmalloc (sizeof (char) * i);
|
mtime_test = xmalloc (sizeof (char) * l);
|
||||||
snprintf (mtime_test, i, "%s.%d", path, getpid ());
|
snprintf (mtime_test, l, "%s.%d", path, getpid ());
|
||||||
free (path);
|
free (path);
|
||||||
|
|
||||||
if (exists (mtime_test) && unlink (mtime_test) != 0) {
|
if (exists (mtime_test) && unlink (mtime_test) != 0) {
|
||||||
@ -760,7 +763,7 @@ static void svc_start (bool deps)
|
|||||||
|
|
||||||
if (tmplist) {
|
if (tmplist) {
|
||||||
int n = 0;
|
int n = 0;
|
||||||
int len = 0;
|
size_t len = 0;
|
||||||
char *p;
|
char *p;
|
||||||
|
|
||||||
/* Set the state now, then unlink our exclusive so that
|
/* 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 runscript (int argc, char **argv)
|
||||||
{
|
{
|
||||||
int i;
|
size_t i;
|
||||||
bool deps = true;
|
bool deps = true;
|
||||||
bool doneone = false;
|
bool doneone = false;
|
||||||
char pid[16];
|
char pid[16];
|
||||||
@ -1136,8 +1139,8 @@ int runscript (int argc, char **argv)
|
|||||||
|
|
||||||
/* eprefix is kinda klunky, but it works for our purposes */
|
/* eprefix is kinda klunky, but it works for our purposes */
|
||||||
if (rc_conf_yesno ("rc_parallel")) {
|
if (rc_conf_yesno ("rc_parallel")) {
|
||||||
int l = 0;
|
size_t l = 0;
|
||||||
int ll;
|
size_t ll;
|
||||||
|
|
||||||
/* Get the longest service name */
|
/* Get the longest service name */
|
||||||
services = rc_services_in_runlevel (NULL);
|
services = rc_services_in_runlevel (NULL);
|
||||||
|
@ -150,7 +150,7 @@ static int parse_signal (const char *sig)
|
|||||||
};
|
};
|
||||||
|
|
||||||
unsigned int i = 0;
|
unsigned int i = 0;
|
||||||
char *s;
|
const char *s;
|
||||||
|
|
||||||
if (! sig || *sig == '\0')
|
if (! sig || *sig == '\0')
|
||||||
return (-1);
|
return (-1);
|
||||||
@ -162,7 +162,7 @@ static int parse_signal (const char *sig)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (strncmp (sig, "SIG", 3) == 0)
|
if (strncmp (sig, "SIG", 3) == 0)
|
||||||
s = (char *) sig + 3;
|
s = sig + 3;
|
||||||
else
|
else
|
||||||
s = NULL;
|
s = NULL;
|
||||||
|
|
||||||
@ -172,6 +172,7 @@ static int parse_signal (const char *sig)
|
|||||||
return (signallist[i].signal);
|
return (signallist[i].signal);
|
||||||
|
|
||||||
eerrorx ("%s: `%s' is not a valid signal", applet, sig);
|
eerrorx ("%s: `%s' is not a valid signal", applet, sig);
|
||||||
|
/* NOTREACHED */
|
||||||
}
|
}
|
||||||
|
|
||||||
static void parse_schedule_item (schedulelist_t *item, const char *string)
|
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;
|
const char *slash;
|
||||||
int count = 0;
|
int count = 0;
|
||||||
schedulelist_t *repeatat = NULL;
|
schedulelist_t *repeatat = NULL;
|
||||||
ptrdiff_t len;
|
size_t len;
|
||||||
schedulelist_t *next;
|
schedulelist_t *next;
|
||||||
|
|
||||||
if (string)
|
if (string)
|
||||||
@ -446,7 +447,6 @@ static int run_stop_schedule (const char *exec, const char *cmd,
|
|||||||
|
|
||||||
static void handle_signal (int sig)
|
static void handle_signal (int sig)
|
||||||
{
|
{
|
||||||
int pid;
|
|
||||||
int status;
|
int status;
|
||||||
int serrno = errno;
|
int serrno = errno;
|
||||||
char signame[10] = { '\0' };
|
char signame[10] = { '\0' };
|
||||||
@ -455,17 +455,20 @@ static void handle_signal (int sig)
|
|||||||
case SIGINT:
|
case SIGINT:
|
||||||
if (! signame[0])
|
if (! signame[0])
|
||||||
snprintf (signame, sizeof (signame), "SIGINT");
|
snprintf (signame, sizeof (signame), "SIGINT");
|
||||||
|
/* FALLTHROUGH */
|
||||||
case SIGTERM:
|
case SIGTERM:
|
||||||
if (! signame[0])
|
if (! signame[0])
|
||||||
snprintf (signame, sizeof (signame), "SIGTERM");
|
snprintf (signame, sizeof (signame), "SIGTERM");
|
||||||
|
/* FALLTHROUGH */
|
||||||
case SIGQUIT:
|
case SIGQUIT:
|
||||||
if (! signame[0])
|
if (! signame[0])
|
||||||
snprintf (signame, sizeof (signame), "SIGQUIT");
|
snprintf (signame, sizeof (signame), "SIGQUIT");
|
||||||
eerrorx ("%s: caught %s, aborting", applet, signame);
|
eerrorx ("%s: caught %s, aborting", applet, signame);
|
||||||
|
/* NOTREACHED */
|
||||||
|
|
||||||
case SIGCHLD:
|
case SIGCHLD:
|
||||||
while (1) {
|
for (;;) {
|
||||||
if ((pid = waitpid (-1, &status, WNOHANG)) < 0) {
|
if (waitpid (-1, &status, WNOHANG) < 0) {
|
||||||
if (errno != ECHILD)
|
if (errno != ECHILD)
|
||||||
eerror ("%s: waitpid: %s", applet, strerror (errno));
|
eerror ("%s: waitpid: %s", applet, strerror (errno));
|
||||||
break;
|
break;
|
||||||
@ -618,7 +621,7 @@ int start_stop_daemon (int argc, char **argv)
|
|||||||
if (sscanf (cu, "%d", &tid) != 1)
|
if (sscanf (cu, "%d", &tid) != 1)
|
||||||
pw = getpwnam (cu);
|
pw = getpwnam (cu);
|
||||||
else
|
else
|
||||||
pw = getpwuid (tid);
|
pw = getpwuid ((uid_t) tid);
|
||||||
|
|
||||||
if (! pw)
|
if (! pw)
|
||||||
eerrorx ("%s: user `%s' not found", applet, cu);
|
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)
|
if (sscanf (cg, "%d", &tid) != 1)
|
||||||
gr = getgrnam (cg);
|
gr = getgrnam (cg);
|
||||||
else
|
else
|
||||||
gr = getgrgid (tid);
|
gr = getgrgid ((gid_t) tid);
|
||||||
|
|
||||||
if (! gr)
|
if (! gr)
|
||||||
eerrorx ("%s: group `%s' not found", applet, cg);
|
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)
|
if (sscanf (optarg, "%d", &tid) != 1)
|
||||||
gr = getgrnam (optarg);
|
gr = getgrnam (optarg);
|
||||||
else
|
else
|
||||||
gr = getgrgid (tid);
|
gr = getgrgid ((gid_t) tid);
|
||||||
|
|
||||||
if (! gr)
|
if (! gr)
|
||||||
eerrorx ("%s: group `%s' not found", applet, optarg);
|
eerrorx ("%s: group `%s' not found", applet, optarg);
|
||||||
@ -912,7 +915,7 @@ int start_stop_daemon (int argc, char **argv)
|
|||||||
char *p = path;
|
char *p = path;
|
||||||
char *token;
|
char *token;
|
||||||
char *np;
|
char *np;
|
||||||
int l;
|
size_t l;
|
||||||
int t;
|
int t;
|
||||||
|
|
||||||
p += 5;
|
p += 5;
|
||||||
@ -1067,4 +1070,5 @@ int start_stop_daemon (int argc, char **argv)
|
|||||||
rc_service_daemon_set (svcname, exec, cmd, pidfile, true);
|
rc_service_daemon_set (svcname, exec, cmd, pidfile, true);
|
||||||
|
|
||||||
exit (EXIT_SUCCESS);
|
exit (EXIT_SUCCESS);
|
||||||
|
/* NOTREACHED */
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user