preparatory patch for -Wwrite-strings #6
This commit is contained in:
parent
89ef65f024
commit
322661d025
@ -123,8 +123,8 @@
|
|||||||
|
|
||||||
/* This structure defines protocol families and their handlers. */
|
/* This structure defines protocol families and their handlers. */
|
||||||
struct aftype {
|
struct aftype {
|
||||||
char *name;
|
const char *name;
|
||||||
char *title;
|
const char *title;
|
||||||
int af;
|
int af;
|
||||||
int alen;
|
int alen;
|
||||||
char *(*print) (unsigned char *);
|
char *(*print) (unsigned char *);
|
||||||
@ -143,8 +143,8 @@ struct aftype {
|
|||||||
|
|
||||||
/* This structure defines hardware protocols and their handlers. */
|
/* This structure defines hardware protocols and their handlers. */
|
||||||
struct hwtype {
|
struct hwtype {
|
||||||
char *name;
|
const char *name;
|
||||||
char *title;
|
const char *title;
|
||||||
int type;
|
int type;
|
||||||
int alen;
|
int alen;
|
||||||
char *(*print) (unsigned char *);
|
char *(*print) (unsigned char *);
|
||||||
|
@ -37,9 +37,9 @@ struct dep_t { /* one-way list of dependency rules */
|
|||||||
|
|
||||||
struct mod_list_t { /* two-way list of modules to process */
|
struct mod_list_t { /* two-way list of modules to process */
|
||||||
/* a module description */
|
/* a module description */
|
||||||
char * m_name;
|
const char * m_name;
|
||||||
char * m_path;
|
char * m_path;
|
||||||
struct mod_opt_t * m_options;
|
struct mod_opt_t * m_options;
|
||||||
|
|
||||||
struct mod_list_t * m_prev;
|
struct mod_list_t * m_prev;
|
||||||
struct mod_list_t * m_next;
|
struct mod_list_t * m_next;
|
||||||
@ -577,7 +577,7 @@ done:
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int mod_process(struct mod_list_t *list, int do_insert)
|
static int mod_process(const struct mod_list_t *list, int do_insert)
|
||||||
{
|
{
|
||||||
int rc = 0;
|
int rc = 0;
|
||||||
char **argv = NULL;
|
char **argv = NULL;
|
||||||
@ -603,16 +603,16 @@ static int mod_process(struct mod_list_t *list, int do_insert)
|
|||||||
argv = xmalloc(6 * sizeof(char*));
|
argv = xmalloc(6 * sizeof(char*));
|
||||||
if (do_insert) {
|
if (do_insert) {
|
||||||
if (already_loaded(list->m_name) != 1) {
|
if (already_loaded(list->m_name) != 1) {
|
||||||
argv[argc++] = "insmod";
|
argv[argc++] = (char*)"insmod";
|
||||||
if (ENABLE_FEATURE_2_4_MODULES) {
|
if (ENABLE_FEATURE_2_4_MODULES) {
|
||||||
if (do_syslog)
|
if (do_syslog)
|
||||||
argv[argc++] = "-s";
|
argv[argc++] = (char*)"-s";
|
||||||
if (autoclean)
|
if (autoclean)
|
||||||
argv[argc++] = "-k";
|
argv[argc++] = (char*)"-k";
|
||||||
if (quiet)
|
if (quiet)
|
||||||
argv[argc++] = "-q";
|
argv[argc++] = (char*)"-q";
|
||||||
else if (verbose) /* verbose and quiet are mutually exclusive */
|
else if (verbose) /* verbose and quiet are mutually exclusive */
|
||||||
argv[argc++] = "-v";
|
argv[argc++] = (char*)"-v";
|
||||||
}
|
}
|
||||||
argv[argc++] = list->m_path;
|
argv[argc++] = list->m_path;
|
||||||
if (ENABLE_FEATURE_CLEAN_UP)
|
if (ENABLE_FEATURE_CLEAN_UP)
|
||||||
@ -629,10 +629,10 @@ static int mod_process(struct mod_list_t *list, int do_insert)
|
|||||||
} else {
|
} else {
|
||||||
/* modutils uses short name for removal */
|
/* modutils uses short name for removal */
|
||||||
if (already_loaded(list->m_name) != 0) {
|
if (already_loaded(list->m_name) != 0) {
|
||||||
argv[argc++] = "rmmod";
|
argv[argc++] = (char*)"rmmod";
|
||||||
if (do_syslog)
|
if (do_syslog)
|
||||||
argv[argc++] = "-s";
|
argv[argc++] = (char*)"-s";
|
||||||
argv[argc++] = list->m_name;
|
argv[argc++] = (char*)list->m_name;
|
||||||
if (ENABLE_FEATURE_CLEAN_UP)
|
if (ENABLE_FEATURE_CLEAN_UP)
|
||||||
argc_malloc = argc;
|
argc_malloc = argc;
|
||||||
}
|
}
|
||||||
@ -810,13 +810,14 @@ static void check_dep(char *mod, struct mod_list_t **head, struct mod_list_t **t
|
|||||||
|
|
||||||
static int mod_insert(char *mod, int argc, char **argv)
|
static int mod_insert(char *mod, int argc, char **argv)
|
||||||
{
|
{
|
||||||
struct mod_list_t *tail = 0;
|
struct mod_list_t *tail = NULL;
|
||||||
struct mod_list_t *head = 0;
|
struct mod_list_t *head = NULL;
|
||||||
int rc;
|
int rc;
|
||||||
|
|
||||||
// get dep list for module mod
|
// get dep list for module mod
|
||||||
check_dep(mod, &head, &tail);
|
check_dep(mod, &head, &tail);
|
||||||
|
|
||||||
|
rc = 1;
|
||||||
if (head && tail) {
|
if (head && tail) {
|
||||||
if (argc) {
|
if (argc) {
|
||||||
int i;
|
int i;
|
||||||
@ -826,7 +827,8 @@ static int mod_insert(char *mod, int argc, char **argv)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// process tail ---> head
|
// process tail ---> head
|
||||||
if ((rc = mod_process(tail, 1)) != 0) {
|
rc = mod_process(tail, 1);
|
||||||
|
if (rc) {
|
||||||
/*
|
/*
|
||||||
* In case of using udev, multiple instances of modprobe can be
|
* In case of using udev, multiple instances of modprobe can be
|
||||||
* spawned to load the same module (think of two same usb devices,
|
* spawned to load the same module (think of two same usb devices,
|
||||||
@ -837,31 +839,26 @@ static int mod_insert(char *mod, int argc, char **argv)
|
|||||||
rc = 0;
|
rc = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
|
||||||
rc = 1;
|
|
||||||
|
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int mod_remove(char *mod)
|
static int mod_remove(char *mod)
|
||||||
{
|
{
|
||||||
int rc;
|
int rc;
|
||||||
static struct mod_list_t rm_a_dummy = { "-a", NULL, NULL, NULL, NULL };
|
static const struct mod_list_t rm_a_dummy = { "-a", NULL, NULL, NULL, NULL };
|
||||||
|
|
||||||
struct mod_list_t *head = 0;
|
struct mod_list_t *head = NULL;
|
||||||
struct mod_list_t *tail = 0;
|
struct mod_list_t *tail = NULL;
|
||||||
|
|
||||||
if (mod)
|
if (mod)
|
||||||
check_dep(mod, &head, &tail);
|
check_dep(mod, &head, &tail);
|
||||||
else // autoclean
|
else // autoclean
|
||||||
head = tail = &rm_a_dummy;
|
head = tail = (struct mod_list_t*) &rm_a_dummy;
|
||||||
|
|
||||||
|
rc = 1;
|
||||||
if (head && tail)
|
if (head && tail)
|
||||||
rc = mod_process(head, 0); // process head ---> tail
|
rc = mod_process(head, 0); // process head ---> tail
|
||||||
else
|
|
||||||
rc = 1;
|
|
||||||
return rc;
|
return rc;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int modprobe_main(int argc, char** argv)
|
int modprobe_main(int argc, char** argv)
|
||||||
|
@ -31,18 +31,9 @@
|
|||||||
* (default AF was wrong)
|
* (default AF was wrong)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "inet_common.h"
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <errno.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <string.h>
|
|
||||||
#include <unistd.h>
|
|
||||||
#include <fcntl.h>
|
|
||||||
#include <ctype.h>
|
|
||||||
#include <sys/ioctl.h>
|
|
||||||
#include <sys/types.h>
|
|
||||||
#include <net/if.h>
|
#include <net/if.h>
|
||||||
#include <net/if_arp.h>
|
#include <net/if_arp.h>
|
||||||
|
#include "inet_common.h"
|
||||||
#include "busybox.h"
|
#include "busybox.h"
|
||||||
|
|
||||||
#ifdef CONFIG_FEATURE_IPV6
|
#ifdef CONFIG_FEATURE_IPV6
|
||||||
@ -178,8 +169,7 @@ static char *INET6_sprint(struct sockaddr *sap, int numeric)
|
|||||||
|
|
||||||
if (sap->sa_family == 0xFFFF || sap->sa_family == 0)
|
if (sap->sa_family == 0xFFFF || sap->sa_family == 0)
|
||||||
return safe_strncpy(buff, "[NONE SET]", sizeof(buff));
|
return safe_strncpy(buff, "[NONE SET]", sizeof(buff));
|
||||||
if (INET6_rresolve
|
if (INET6_rresolve(buff, sizeof(buff), (struct sockaddr_in6 *) sap, numeric))
|
||||||
(buff, sizeof(buff), (struct sockaddr_in6 *) sap, numeric) != 0)
|
|
||||||
return safe_strncpy(buff, "[UNKNOWN]", sizeof(buff));
|
return safe_strncpy(buff, "[UNKNOWN]", sizeof(buff));
|
||||||
return buff;
|
return buff;
|
||||||
}
|
}
|
||||||
@ -771,7 +761,7 @@ static int if_fetch(struct interface *ife)
|
|||||||
static int do_if_fetch(struct interface *ife)
|
static int do_if_fetch(struct interface *ife)
|
||||||
{
|
{
|
||||||
if (if_fetch(ife) < 0) {
|
if (if_fetch(ife) < 0) {
|
||||||
char *errmsg;
|
const char *errmsg;
|
||||||
|
|
||||||
if (errno == ENODEV) {
|
if (errno == ENODEV) {
|
||||||
/* Give better error message for this case. */
|
/* Give better error message for this case. */
|
||||||
|
@ -24,7 +24,7 @@
|
|||||||
#define __PF(f,n) { ETH_P_##f, #n },
|
#define __PF(f,n) { ETH_P_##f, #n },
|
||||||
static struct {
|
static struct {
|
||||||
int id;
|
int id;
|
||||||
char *name;
|
const char *name;
|
||||||
} llproto_names[] = {
|
} llproto_names[] = {
|
||||||
__PF(LOOP,loop)
|
__PF(LOOP,loop)
|
||||||
__PF(PUP,pup)
|
__PF(PUP,pup)
|
||||||
|
@ -13,11 +13,10 @@
|
|||||||
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#include "rt_names.h"
|
#include "rt_names.h"
|
||||||
#include "utils.h"
|
#include "utils.h"
|
||||||
|
|
||||||
char *rtnl_rtntype_n2a(int id, char *buf, int len)
|
const char *rtnl_rtntype_n2a(int id, char *buf, int len)
|
||||||
{
|
{
|
||||||
switch (id) {
|
switch (id) {
|
||||||
case RTN_UNSPEC:
|
case RTN_UNSPEC:
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
#ifndef __RTM_MAP_H__
|
#ifndef __RTM_MAP_H__
|
||||||
#define __RTM_MAP_H__ 1
|
#define __RTM_MAP_H__ 1
|
||||||
|
|
||||||
char *rtnl_rtntype_n2a(int id, char *buf, int len);
|
const char *rtnl_rtntype_n2a(int id, char *buf, int len);
|
||||||
int rtnl_rtntype_a2n(int *id, char *arg);
|
int rtnl_rtntype_a2n(int *id, char *arg);
|
||||||
|
|
||||||
int get_rt_realms(uint32_t *realms, char *arg);
|
int get_rt_realms(uint32_t *realms, char *arg);
|
||||||
|
72
runit/sv.c
72
runit/sv.c
@ -7,33 +7,33 @@
|
|||||||
#include "runit_lib.h"
|
#include "runit_lib.h"
|
||||||
|
|
||||||
static char *action;
|
static char *action;
|
||||||
static char *acts;
|
static const char *acts;
|
||||||
static char *varservice = "/var/service/";
|
static const char *varservice = "/var/service/";
|
||||||
static char **service;
|
static char **service;
|
||||||
static char **servicex;
|
static char **servicex;
|
||||||
static unsigned services;
|
static unsigned services;
|
||||||
static unsigned rc = 0;
|
static unsigned rc;
|
||||||
static unsigned verbose = 0;
|
static unsigned verbose;
|
||||||
static unsigned long waitsec = 7;
|
static unsigned long waitsec = 7;
|
||||||
static unsigned kll = 0;
|
static unsigned kll;
|
||||||
static struct taia tstart, tnow, tdiff;
|
static struct taia tstart, tnow, tdiff;
|
||||||
static struct tai tstatus;
|
static struct tai tstatus;
|
||||||
|
|
||||||
static int (*act)(char*) = 0;
|
static int (*act)(const char*);
|
||||||
static int (*cbk)(char*) = 0;
|
static int (*cbk)(const char*);
|
||||||
|
|
||||||
static int curdir, fd, r;
|
static int curdir, fd, r;
|
||||||
static char svstatus[20];
|
static char svstatus[20];
|
||||||
|
|
||||||
#define usage() bb_show_usage()
|
#define usage() bb_show_usage()
|
||||||
|
|
||||||
static void fatal_cannot(char *m1)
|
static void fatal_cannot(const char *m1)
|
||||||
{
|
{
|
||||||
bb_perror_msg("fatal: cannot %s", m1);
|
bb_perror_msg("fatal: cannot %s", m1);
|
||||||
_exit(151);
|
_exit(151);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void out(char *p, char *m1)
|
static void out(const char *p, const char *m1)
|
||||||
{
|
{
|
||||||
printf("%s%s: %s", p, *service, m1);
|
printf("%s%s: %s", p, *service, m1);
|
||||||
if (errno) {
|
if (errno) {
|
||||||
@ -51,15 +51,16 @@ static void out(char *p, char *m1)
|
|||||||
#define TIMEOUT "timeout: "
|
#define TIMEOUT "timeout: "
|
||||||
#define KILL "kill: "
|
#define KILL "kill: "
|
||||||
|
|
||||||
static void fail(char *m1) { ++rc; out(FAIL, m1); }
|
static void fail(const char *m1) { ++rc; out(FAIL, m1); }
|
||||||
static void failx(char *m1) { errno = 0; fail(m1); }
|
static void failx(const char *m1) { errno = 0; fail(m1); }
|
||||||
static void warn_cannot(char *m1) { ++rc; out("warning: cannot ", m1); }
|
static void warn_cannot(const char *m1) { ++rc; out("warning: cannot ", m1); }
|
||||||
static void warnx_cannot(char *m1) { errno = 0; warn_cannot(m1); }
|
static void warnx_cannot(const char *m1) { errno = 0; warn_cannot(m1); }
|
||||||
static void ok(char *m1) { errno = 0; out(OK, m1); }
|
static void ok(const char *m1) { errno = 0; out(OK, m1); }
|
||||||
|
|
||||||
static int svstatus_get(void)
|
static int svstatus_get(void)
|
||||||
{
|
{
|
||||||
if ((fd = open_write("supervise/ok")) == -1) {
|
fd = open_write("supervise/ok");
|
||||||
|
if (fd == -1) {
|
||||||
if (errno == ENODEV) {
|
if (errno == ENODEV) {
|
||||||
*acts == 'x' ? ok("runsv not running")
|
*acts == 'x' ? ok("runsv not running")
|
||||||
: failx("runsv not running");
|
: failx("runsv not running");
|
||||||
@ -69,7 +70,8 @@ static int svstatus_get(void)
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
close(fd);
|
close(fd);
|
||||||
if ((fd = open_read("supervise/status")) == -1) {
|
fd = open_read("supervise/status");
|
||||||
|
if (fd == -1) {
|
||||||
warn_cannot("open supervise/status");
|
warn_cannot("open supervise/status");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@ -83,7 +85,7 @@ static int svstatus_get(void)
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static unsigned svstatus_print(char *m)
|
static unsigned svstatus_print(const char *m)
|
||||||
{
|
{
|
||||||
int pid;
|
int pid;
|
||||||
int normallyup = 0;
|
int normallyup = 0;
|
||||||
@ -121,7 +123,7 @@ static unsigned svstatus_print(char *m)
|
|||||||
return pid ? 1 : 2;
|
return pid ? 1 : 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int status(char *unused)
|
static int status(const char *unused)
|
||||||
{
|
{
|
||||||
r = svstatus_get();
|
r = svstatus_get();
|
||||||
switch (r) { case -1: case 0: return 0; }
|
switch (r) { case -1: case 0: return 0; }
|
||||||
@ -156,8 +158,8 @@ static int checkscript(void)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
if (!pid) {
|
if (!pid) {
|
||||||
prog[0] = "./check";
|
prog[0] = (char*)"./check";
|
||||||
prog[1] = 0;
|
prog[1] = NULL;
|
||||||
close(1);
|
close(1);
|
||||||
execve("check", prog, environ);
|
execve("check", prog, environ);
|
||||||
bb_perror_msg(WARN"cannot run %s/check", *service);
|
bb_perror_msg(WARN"cannot run %s/check", *service);
|
||||||
@ -171,7 +173,7 @@ static int checkscript(void)
|
|||||||
return !wait_exitcode(w);
|
return !wait_exitcode(w);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int check(char *a)
|
static int check(const char *a)
|
||||||
{
|
{
|
||||||
unsigned pid;
|
unsigned pid;
|
||||||
|
|
||||||
@ -200,15 +202,18 @@ static int check(char *a)
|
|||||||
if ((!pid && tstart.sec.x > tstatus.x) || (pid && svstatus[17] != 'd'))
|
if ((!pid && tstart.sec.x > tstatus.x) || (pid && svstatus[17] != 'd'))
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
printf(OK); svstatus_print(*service); puts(""); /* will also flush the output */
|
printf(OK);
|
||||||
|
svstatus_print(*service);
|
||||||
|
puts(""); /* will also flush the output */
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int control(char *a)
|
static int control(const char *a)
|
||||||
{
|
{
|
||||||
if (svstatus_get() <= 0) return -1;
|
if (svstatus_get() <= 0) return -1;
|
||||||
if (svstatus[17] == *a) return 0;
|
if (svstatus[17] == *a) return 0;
|
||||||
if ((fd = open_write("supervise/control")) == -1) {
|
fd = open_write("supervise/control");
|
||||||
|
if (fd == -1) {
|
||||||
if (errno != ENODEV)
|
if (errno != ENODEV)
|
||||||
warn_cannot("open supervise/control");
|
warn_cannot("open supervise/control");
|
||||||
else
|
else
|
||||||
@ -245,15 +250,20 @@ int sv_main(int argc, char **argv)
|
|||||||
if (opt & 4) usage();
|
if (opt & 4) usage();
|
||||||
if (!(action = *argv++)) usage();
|
if (!(action = *argv++)) usage();
|
||||||
--argc;
|
--argc;
|
||||||
service = argv; services = argc;
|
service = argv;
|
||||||
|
services = argc;
|
||||||
if (!*service) usage();
|
if (!*service) usage();
|
||||||
|
|
||||||
taia_now(&tnow); tstart = tnow;
|
taia_now(&tnow);
|
||||||
if ((curdir = open_read(".")) == -1)
|
tstart = tnow;
|
||||||
|
curdir = open_read(".");
|
||||||
|
if (curdir == -1)
|
||||||
fatal_cannot("open current directory");
|
fatal_cannot("open current directory");
|
||||||
|
|
||||||
act = &control; acts = "s";
|
act = &control;
|
||||||
if (verbose) cbk = ✓
|
acts = "s";
|
||||||
|
if (verbose)
|
||||||
|
cbk = ✓
|
||||||
switch (*action) {
|
switch (*action) {
|
||||||
case 'x': case 'e':
|
case 'x': case 'e':
|
||||||
acts = "x"; break;
|
acts = "x"; break;
|
||||||
@ -289,7 +299,9 @@ int sv_main(int argc, char **argv)
|
|||||||
cbk = ✓
|
cbk = ✓
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
act = &status; cbk = 0; break;
|
act = &status;
|
||||||
|
cbk = NULL;
|
||||||
|
break;
|
||||||
case 'r':
|
case 'r':
|
||||||
if (!str_diff(action, "restart")) {
|
if (!str_diff(action, "restart")) {
|
||||||
acts = "tcu";
|
acts = "tcu";
|
||||||
|
Loading…
x
Reference in New Issue
Block a user