diff options
author | Denis Vlasenko <vda.linux@googlemail.com> | 2007-01-29 23:43:52 +0000 |
---|---|---|
committer | Denis Vlasenko <vda.linux@googlemail.com> | 2007-01-29 23:43:52 +0000 |
commit | 322661d025626d7a92482fec232d29f4450dd4b0 (patch) | |
tree | 66dcf2c776adea8556d2ebac5e3f7d8a27f05074 | |
parent | 89ef65f02463b27313ff0eba806aa6e4aec10716 (diff) | |
download | busybox-322661d025626d7a92482fec232d29f4450dd4b0.tar.gz |
preparatory patch for -Wwrite-strings #6
-rw-r--r-- | include/libbb.h | 8 | ||||
-rw-r--r-- | modutils/modprobe.c | 47 | ||||
-rw-r--r-- | networking/interface.c | 16 | ||||
-rw-r--r-- | networking/libiproute/ll_proto.c | 2 | ||||
-rw-r--r-- | networking/libiproute/rtm_map.c | 3 | ||||
-rw-r--r-- | networking/libiproute/rtm_map.h | 2 | ||||
-rw-r--r-- | runit/sv.c | 72 |
7 files changed, 74 insertions, 76 deletions
diff --git a/include/libbb.h b/include/libbb.h index 99a9422f0..ed1c41a02 100644 --- a/include/libbb.h +++ b/include/libbb.h @@ -123,8 +123,8 @@ /* This structure defines protocol families and their handlers. */ struct aftype { - char *name; - char *title; + const char *name; + const char *title; int af; int alen; char *(*print) (unsigned char *); @@ -143,8 +143,8 @@ struct aftype { /* This structure defines hardware protocols and their handlers. */ struct hwtype { - char *name; - char *title; + const char *name; + const char *title; int type; int alen; char *(*print) (unsigned char *); diff --git a/modutils/modprobe.c b/modutils/modprobe.c index dcab493f1..94f7b22c2 100644 --- a/modutils/modprobe.c +++ b/modutils/modprobe.c @@ -37,9 +37,9 @@ struct dep_t { /* one-way list of dependency rules */ struct mod_list_t { /* two-way list of modules to process */ /* a module description */ - char * m_name; - char * m_path; - struct mod_opt_t * m_options; + const char * m_name; + char * m_path; + struct mod_opt_t * m_options; struct mod_list_t * m_prev; struct mod_list_t * m_next; @@ -577,7 +577,7 @@ done: 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; char **argv = NULL; @@ -603,16 +603,16 @@ static int mod_process(struct mod_list_t *list, int do_insert) argv = xmalloc(6 * sizeof(char*)); if (do_insert) { if (already_loaded(list->m_name) != 1) { - argv[argc++] = "insmod"; + argv[argc++] = (char*)"insmod"; if (ENABLE_FEATURE_2_4_MODULES) { if (do_syslog) - argv[argc++] = "-s"; + argv[argc++] = (char*)"-s"; if (autoclean) - argv[argc++] = "-k"; + argv[argc++] = (char*)"-k"; if (quiet) - argv[argc++] = "-q"; + argv[argc++] = (char*)"-q"; else if (verbose) /* verbose and quiet are mutually exclusive */ - argv[argc++] = "-v"; + argv[argc++] = (char*)"-v"; } argv[argc++] = list->m_path; if (ENABLE_FEATURE_CLEAN_UP) @@ -629,10 +629,10 @@ static int mod_process(struct mod_list_t *list, int do_insert) } else { /* modutils uses short name for removal */ if (already_loaded(list->m_name) != 0) { - argv[argc++] = "rmmod"; + argv[argc++] = (char*)"rmmod"; if (do_syslog) - argv[argc++] = "-s"; - argv[argc++] = list->m_name; + argv[argc++] = (char*)"-s"; + argv[argc++] = (char*)list->m_name; if (ENABLE_FEATURE_CLEAN_UP) 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) { - struct mod_list_t *tail = 0; - struct mod_list_t *head = 0; + struct mod_list_t *tail = NULL; + struct mod_list_t *head = NULL; int rc; // get dep list for module mod check_dep(mod, &head, &tail); + rc = 1; if (head && tail) { if (argc) { int i; @@ -826,7 +827,8 @@ static int mod_insert(char *mod, int argc, char **argv) } // 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 * 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; } } - else - rc = 1; - return rc; } static int mod_remove(char *mod) { 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 *tail = 0; + struct mod_list_t *head = NULL; + struct mod_list_t *tail = NULL; if (mod) check_dep(mod, &head, &tail); else // autoclean - head = tail = &rm_a_dummy; + head = tail = (struct mod_list_t*) &rm_a_dummy; + rc = 1; if (head && tail) rc = mod_process(head, 0); // process head ---> tail - else - rc = 1; return rc; - } int modprobe_main(int argc, char** argv) diff --git a/networking/interface.c b/networking/interface.c index fbcf50152..f345cb09d 100644 --- a/networking/interface.c +++ b/networking/interface.c @@ -31,18 +31,9 @@ * (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_arp.h> +#include "inet_common.h" #include "busybox.h" #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) return safe_strncpy(buff, "[NONE SET]", sizeof(buff)); - if (INET6_rresolve - (buff, sizeof(buff), (struct sockaddr_in6 *) sap, numeric) != 0) + if (INET6_rresolve(buff, sizeof(buff), (struct sockaddr_in6 *) sap, numeric)) return safe_strncpy(buff, "[UNKNOWN]", sizeof(buff)); return buff; } @@ -771,7 +761,7 @@ static int if_fetch(struct interface *ife) static int do_if_fetch(struct interface *ife) { if (if_fetch(ife) < 0) { - char *errmsg; + const char *errmsg; if (errno == ENODEV) { /* Give better error message for this case. */ diff --git a/networking/libiproute/ll_proto.c b/networking/libiproute/ll_proto.c index 20f26ca3f..aad460b5f 100644 --- a/networking/libiproute/ll_proto.c +++ b/networking/libiproute/ll_proto.c @@ -24,7 +24,7 @@ #define __PF(f,n) { ETH_P_##f, #n }, static struct { int id; - char *name; + const char *name; } llproto_names[] = { __PF(LOOP,loop) __PF(PUP,pup) diff --git a/networking/libiproute/rtm_map.c b/networking/libiproute/rtm_map.c index 7eb4c7122..c16406b8b 100644 --- a/networking/libiproute/rtm_map.c +++ b/networking/libiproute/rtm_map.c @@ -13,11 +13,10 @@ #include <stdlib.h> #include <string.h> - #include "rt_names.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) { case RTN_UNSPEC: diff --git a/networking/libiproute/rtm_map.h b/networking/libiproute/rtm_map.h index b9c8c503f..cbbcc214d 100644 --- a/networking/libiproute/rtm_map.h +++ b/networking/libiproute/rtm_map.h @@ -2,7 +2,7 @@ #ifndef __RTM_MAP_H__ #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 get_rt_realms(uint32_t *realms, char *arg); diff --git a/runit/sv.c b/runit/sv.c index 6594e1451..6b154c1a8 100644 --- a/runit/sv.c +++ b/runit/sv.c @@ -7,33 +7,33 @@ #include "runit_lib.h" static char *action; -static char *acts; -static char *varservice = "/var/service/"; +static const char *acts; +static const char *varservice = "/var/service/"; static char **service; static char **servicex; static unsigned services; -static unsigned rc = 0; -static unsigned verbose = 0; +static unsigned rc; +static unsigned verbose; static unsigned long waitsec = 7; -static unsigned kll = 0; +static unsigned kll; static struct taia tstart, tnow, tdiff; static struct tai tstatus; -static int (*act)(char*) = 0; -static int (*cbk)(char*) = 0; +static int (*act)(const char*); +static int (*cbk)(const char*); static int curdir, fd, r; static char svstatus[20]; #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); _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); if (errno) { @@ -51,15 +51,16 @@ static void out(char *p, char *m1) #define TIMEOUT "timeout: " #define KILL "kill: " -static void fail(char *m1) { ++rc; out(FAIL, m1); } -static void failx(char *m1) { errno = 0; fail(m1); } -static void warn_cannot(char *m1) { ++rc; out("warning: cannot ", m1); } -static void warnx_cannot(char *m1) { errno = 0; warn_cannot(m1); } -static void ok(char *m1) { errno = 0; out(OK, m1); } +static void fail(const char *m1) { ++rc; out(FAIL, m1); } +static void failx(const char *m1) { errno = 0; fail(m1); } +static void warn_cannot(const char *m1) { ++rc; out("warning: cannot ", m1); } +static void warnx_cannot(const char *m1) { errno = 0; warn_cannot(m1); } +static void ok(const char *m1) { errno = 0; out(OK, m1); } static int svstatus_get(void) { - if ((fd = open_write("supervise/ok")) == -1) { + fd = open_write("supervise/ok"); + if (fd == -1) { if (errno == ENODEV) { *acts == 'x' ? ok("runsv not running") : failx("runsv not running"); @@ -69,7 +70,8 @@ static int svstatus_get(void) return -1; } close(fd); - if ((fd = open_read("supervise/status")) == -1) { + fd = open_read("supervise/status"); + if (fd == -1) { warn_cannot("open supervise/status"); return -1; } @@ -83,7 +85,7 @@ static int svstatus_get(void) return 1; } -static unsigned svstatus_print(char *m) +static unsigned svstatus_print(const char *m) { int pid; int normallyup = 0; @@ -121,7 +123,7 @@ static unsigned svstatus_print(char *m) return pid ? 1 : 2; } -static int status(char *unused) +static int status(const char *unused) { r = svstatus_get(); switch (r) { case -1: case 0: return 0; } @@ -156,8 +158,8 @@ static int checkscript(void) return 0; } if (!pid) { - prog[0] = "./check"; - prog[1] = 0; + prog[0] = (char*)"./check"; + prog[1] = NULL; close(1); execve("check", prog, environ); bb_perror_msg(WARN"cannot run %s/check", *service); @@ -171,7 +173,7 @@ static int checkscript(void) return !wait_exitcode(w); } -static int check(char *a) +static int check(const char *a) { unsigned pid; @@ -200,15 +202,18 @@ static int check(char *a) if ((!pid && tstart.sec.x > tstatus.x) || (pid && svstatus[17] != 'd')) 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; } -static int control(char *a) +static int control(const char *a) { if (svstatus_get() <= 0) return -1; if (svstatus[17] == *a) return 0; - if ((fd = open_write("supervise/control")) == -1) { + fd = open_write("supervise/control"); + if (fd == -1) { if (errno != ENODEV) warn_cannot("open supervise/control"); else @@ -245,15 +250,20 @@ int sv_main(int argc, char **argv) if (opt & 4) usage(); if (!(action = *argv++)) usage(); --argc; - service = argv; services = argc; + service = argv; + services = argc; if (!*service) usage(); - taia_now(&tnow); tstart = tnow; - if ((curdir = open_read(".")) == -1) + taia_now(&tnow); + tstart = tnow; + curdir = open_read("."); + if (curdir == -1) fatal_cannot("open current directory"); - act = &control; acts = "s"; - if (verbose) cbk = ✓ + act = &control; + acts = "s"; + if (verbose) + cbk = ✓ switch (*action) { case 'x': case 'e': acts = "x"; break; @@ -289,7 +299,9 @@ int sv_main(int argc, char **argv) cbk = ✓ break; } - act = &status; cbk = 0; break; + act = &status; + cbk = NULL; + break; case 'r': if (!str_diff(action, "restart")) { acts = "tcu"; |