aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorvda <vda@69ca8d6d-28ef-0310-b511-8ec308f3f277>2007-01-29 23:43:52 +0000
committervda <vda@69ca8d6d-28ef-0310-b511-8ec308f3f277>2007-01-29 23:43:52 +0000
commit86b5dc62b34295eeb85a78082f81d113c0199a4b (patch)
tree66dcf2c776adea8556d2ebac5e3f7d8a27f05074
parent1a0a65f68efe01e93ef3c083c21a77dee97ca036 (diff)
downloadbusybox-w32-86b5dc62b34295eeb85a78082f81d113c0199a4b.tar.gz
busybox-w32-86b5dc62b34295eeb85a78082f81d113c0199a4b.tar.bz2
busybox-w32-86b5dc62b34295eeb85a78082f81d113c0199a4b.zip
preparatory patch for -Wwrite-strings #6
git-svn-id: svn://busybox.net/trunk/busybox@17659 69ca8d6d-28ef-0310-b511-8ec308f3f277
-rw-r--r--include/libbb.h8
-rw-r--r--modutils/modprobe.c47
-rw-r--r--networking/interface.c16
-rw-r--r--networking/libiproute/ll_proto.c2
-rw-r--r--networking/libiproute/rtm_map.c3
-rw-r--r--networking/libiproute/rtm_map.h2
-rw-r--r--runit/sv.c72
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 @@
123 123
124/* This structure defines protocol families and their handlers. */ 124/* This structure defines protocol families and their handlers. */
125struct aftype { 125struct aftype {
126 char *name; 126 const char *name;
127 char *title; 127 const char *title;
128 int af; 128 int af;
129 int alen; 129 int alen;
130 char *(*print) (unsigned char *); 130 char *(*print) (unsigned char *);
@@ -143,8 +143,8 @@ struct aftype {
143 143
144/* This structure defines hardware protocols and their handlers. */ 144/* This structure defines hardware protocols and their handlers. */
145struct hwtype { 145struct hwtype {
146 char *name; 146 const char *name;
147 char *title; 147 const char *title;
148 int type; 148 int type;
149 int alen; 149 int alen;
150 char *(*print) (unsigned char *); 150 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 */
37 37
38struct mod_list_t { /* two-way list of modules to process */ 38struct mod_list_t { /* two-way list of modules to process */
39 /* a module description */ 39 /* a module description */
40 char * m_name; 40 const char * m_name;
41 char * m_path; 41 char * m_path;
42 struct mod_opt_t * m_options; 42 struct mod_opt_t * m_options;
43 43
44 struct mod_list_t * m_prev; 44 struct mod_list_t * m_prev;
45 struct mod_list_t * m_next; 45 struct mod_list_t * m_next;
@@ -577,7 +577,7 @@ done:
577 return ret; 577 return ret;
578} 578}
579 579
580static int mod_process(struct mod_list_t *list, int do_insert) 580static int mod_process(const struct mod_list_t *list, int do_insert)
581{ 581{
582 int rc = 0; 582 int rc = 0;
583 char **argv = NULL; 583 char **argv = NULL;
@@ -603,16 +603,16 @@ static int mod_process(struct mod_list_t *list, int do_insert)
603 argv = xmalloc(6 * sizeof(char*)); 603 argv = xmalloc(6 * sizeof(char*));
604 if (do_insert) { 604 if (do_insert) {
605 if (already_loaded(list->m_name) != 1) { 605 if (already_loaded(list->m_name) != 1) {
606 argv[argc++] = "insmod"; 606 argv[argc++] = (char*)"insmod";
607 if (ENABLE_FEATURE_2_4_MODULES) { 607 if (ENABLE_FEATURE_2_4_MODULES) {
608 if (do_syslog) 608 if (do_syslog)
609 argv[argc++] = "-s"; 609 argv[argc++] = (char*)"-s";
610 if (autoclean) 610 if (autoclean)
611 argv[argc++] = "-k"; 611 argv[argc++] = (char*)"-k";
612 if (quiet) 612 if (quiet)
613 argv[argc++] = "-q"; 613 argv[argc++] = (char*)"-q";
614 else if (verbose) /* verbose and quiet are mutually exclusive */ 614 else if (verbose) /* verbose and quiet are mutually exclusive */
615 argv[argc++] = "-v"; 615 argv[argc++] = (char*)"-v";
616 } 616 }
617 argv[argc++] = list->m_path; 617 argv[argc++] = list->m_path;
618 if (ENABLE_FEATURE_CLEAN_UP) 618 if (ENABLE_FEATURE_CLEAN_UP)
@@ -629,10 +629,10 @@ static int mod_process(struct mod_list_t *list, int do_insert)
629 } else { 629 } else {
630 /* modutils uses short name for removal */ 630 /* modutils uses short name for removal */
631 if (already_loaded(list->m_name) != 0) { 631 if (already_loaded(list->m_name) != 0) {
632 argv[argc++] = "rmmod"; 632 argv[argc++] = (char*)"rmmod";
633 if (do_syslog) 633 if (do_syslog)
634 argv[argc++] = "-s"; 634 argv[argc++] = (char*)"-s";
635 argv[argc++] = list->m_name; 635 argv[argc++] = (char*)list->m_name;
636 if (ENABLE_FEATURE_CLEAN_UP) 636 if (ENABLE_FEATURE_CLEAN_UP)
637 argc_malloc = argc; 637 argc_malloc = argc;
638 } 638 }
@@ -810,13 +810,14 @@ static void check_dep(char *mod, struct mod_list_t **head, struct mod_list_t **t
810 810
811static int mod_insert(char *mod, int argc, char **argv) 811static int mod_insert(char *mod, int argc, char **argv)
812{ 812{
813 struct mod_list_t *tail = 0; 813 struct mod_list_t *tail = NULL;
814 struct mod_list_t *head = 0; 814 struct mod_list_t *head = NULL;
815 int rc; 815 int rc;
816 816
817 // get dep list for module mod 817 // get dep list for module mod
818 check_dep(mod, &head, &tail); 818 check_dep(mod, &head, &tail);
819 819
820 rc = 1;
820 if (head && tail) { 821 if (head && tail) {
821 if (argc) { 822 if (argc) {
822 int i; 823 int i;
@@ -826,7 +827,8 @@ static int mod_insert(char *mod, int argc, char **argv)
826 } 827 }
827 828
828 // process tail ---> head 829 // process tail ---> head
829 if ((rc = mod_process(tail, 1)) != 0) { 830 rc = mod_process(tail, 1);
831 if (rc) {
830 /* 832 /*
831 * In case of using udev, multiple instances of modprobe can be 833 * In case of using udev, multiple instances of modprobe can be
832 * spawned to load the same module (think of two same usb devices, 834 * 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)
837 rc = 0; 839 rc = 0;
838 } 840 }
839 } 841 }
840 else
841 rc = 1;
842
843 return rc; 842 return rc;
844} 843}
845 844
846static int mod_remove(char *mod) 845static int mod_remove(char *mod)
847{ 846{
848 int rc; 847 int rc;
849 static struct mod_list_t rm_a_dummy = { "-a", NULL, NULL, NULL, NULL }; 848 static const struct mod_list_t rm_a_dummy = { "-a", NULL, NULL, NULL, NULL };
850 849
851 struct mod_list_t *head = 0; 850 struct mod_list_t *head = NULL;
852 struct mod_list_t *tail = 0; 851 struct mod_list_t *tail = NULL;
853 852
854 if (mod) 853 if (mod)
855 check_dep(mod, &head, &tail); 854 check_dep(mod, &head, &tail);
856 else // autoclean 855 else // autoclean
857 head = tail = &rm_a_dummy; 856 head = tail = (struct mod_list_t*) &rm_a_dummy;
858 857
858 rc = 1;
859 if (head && tail) 859 if (head && tail)
860 rc = mod_process(head, 0); // process head ---> tail 860 rc = mod_process(head, 0); // process head ---> tail
861 else
862 rc = 1;
863 return rc; 861 return rc;
864
865} 862}
866 863
867int modprobe_main(int argc, char** argv) 864int 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 @@
31 * (default AF was wrong) 31 * (default AF was wrong)
32 */ 32 */
33 33
34#include "inet_common.h"
35#include <stdio.h>
36#include <errno.h>
37#include <stdlib.h>
38#include <string.h>
39#include <unistd.h>
40#include <fcntl.h>
41#include <ctype.h>
42#include <sys/ioctl.h>
43#include <sys/types.h>
44#include <net/if.h> 34#include <net/if.h>
45#include <net/if_arp.h> 35#include <net/if_arp.h>
36#include "inet_common.h"
46#include "busybox.h" 37#include "busybox.h"
47 38
48#ifdef CONFIG_FEATURE_IPV6 39#ifdef CONFIG_FEATURE_IPV6
@@ -178,8 +169,7 @@ static char *INET6_sprint(struct sockaddr *sap, int numeric)
178 169
179 if (sap->sa_family == 0xFFFF || sap->sa_family == 0) 170 if (sap->sa_family == 0xFFFF || sap->sa_family == 0)
180 return safe_strncpy(buff, "[NONE SET]", sizeof(buff)); 171 return safe_strncpy(buff, "[NONE SET]", sizeof(buff));
181 if (INET6_rresolve 172 if (INET6_rresolve(buff, sizeof(buff), (struct sockaddr_in6 *) sap, numeric))
182 (buff, sizeof(buff), (struct sockaddr_in6 *) sap, numeric) != 0)
183 return safe_strncpy(buff, "[UNKNOWN]", sizeof(buff)); 173 return safe_strncpy(buff, "[UNKNOWN]", sizeof(buff));
184 return buff; 174 return buff;
185} 175}
@@ -771,7 +761,7 @@ static int if_fetch(struct interface *ife)
771static int do_if_fetch(struct interface *ife) 761static int do_if_fetch(struct interface *ife)
772{ 762{
773 if (if_fetch(ife) < 0) { 763 if (if_fetch(ife) < 0) {
774 char *errmsg; 764 const char *errmsg;
775 765
776 if (errno == ENODEV) { 766 if (errno == ENODEV) {
777 /* Give better error message for this case. */ 767 /* 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 @@
24#define __PF(f,n) { ETH_P_##f, #n }, 24#define __PF(f,n) { ETH_P_##f, #n },
25static struct { 25static struct {
26 int id; 26 int id;
27 char *name; 27 const char *name;
28} llproto_names[] = { 28} llproto_names[] = {
29__PF(LOOP,loop) 29__PF(LOOP,loop)
30__PF(PUP,pup) 30__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 @@
13 13
14#include <stdlib.h> 14#include <stdlib.h>
15#include <string.h> 15#include <string.h>
16
17#include "rt_names.h" 16#include "rt_names.h"
18#include "utils.h" 17#include "utils.h"
19 18
20char *rtnl_rtntype_n2a(int id, char *buf, int len) 19const char *rtnl_rtntype_n2a(int id, char *buf, int len)
21{ 20{
22 switch (id) { 21 switch (id) {
23 case RTN_UNSPEC: 22 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 @@
2#ifndef __RTM_MAP_H__ 2#ifndef __RTM_MAP_H__
3#define __RTM_MAP_H__ 1 3#define __RTM_MAP_H__ 1
4 4
5char *rtnl_rtntype_n2a(int id, char *buf, int len); 5const char *rtnl_rtntype_n2a(int id, char *buf, int len);
6int rtnl_rtntype_a2n(int *id, char *arg); 6int rtnl_rtntype_a2n(int *id, char *arg);
7 7
8int get_rt_realms(uint32_t *realms, char *arg); 8int 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 @@
7#include "runit_lib.h" 7#include "runit_lib.h"
8 8
9static char *action; 9static char *action;
10static char *acts; 10static const char *acts;
11static char *varservice = "/var/service/"; 11static const char *varservice = "/var/service/";
12static char **service; 12static char **service;
13static char **servicex; 13static char **servicex;
14static unsigned services; 14static unsigned services;
15static unsigned rc = 0; 15static unsigned rc;
16static unsigned verbose = 0; 16static unsigned verbose;
17static unsigned long waitsec = 7; 17static unsigned long waitsec = 7;
18static unsigned kll = 0; 18static unsigned kll;
19static struct taia tstart, tnow, tdiff; 19static struct taia tstart, tnow, tdiff;
20static struct tai tstatus; 20static struct tai tstatus;
21 21
22static int (*act)(char*) = 0; 22static int (*act)(const char*);
23static int (*cbk)(char*) = 0; 23static int (*cbk)(const char*);
24 24
25static int curdir, fd, r; 25static int curdir, fd, r;
26static char svstatus[20]; 26static char svstatus[20];
27 27
28#define usage() bb_show_usage() 28#define usage() bb_show_usage()
29 29
30static void fatal_cannot(char *m1) 30static void fatal_cannot(const char *m1)
31{ 31{
32 bb_perror_msg("fatal: cannot %s", m1); 32 bb_perror_msg("fatal: cannot %s", m1);
33 _exit(151); 33 _exit(151);
34} 34}
35 35
36static void out(char *p, char *m1) 36static void out(const char *p, const char *m1)
37{ 37{
38 printf("%s%s: %s", p, *service, m1); 38 printf("%s%s: %s", p, *service, m1);
39 if (errno) { 39 if (errno) {
@@ -51,15 +51,16 @@ static void out(char *p, char *m1)
51#define TIMEOUT "timeout: " 51#define TIMEOUT "timeout: "
52#define KILL "kill: " 52#define KILL "kill: "
53 53
54static void fail(char *m1) { ++rc; out(FAIL, m1); } 54static void fail(const char *m1) { ++rc; out(FAIL, m1); }
55static void failx(char *m1) { errno = 0; fail(m1); } 55static void failx(const char *m1) { errno = 0; fail(m1); }
56static void warn_cannot(char *m1) { ++rc; out("warning: cannot ", m1); } 56static void warn_cannot(const char *m1) { ++rc; out("warning: cannot ", m1); }
57static void warnx_cannot(char *m1) { errno = 0; warn_cannot(m1); } 57static void warnx_cannot(const char *m1) { errno = 0; warn_cannot(m1); }
58static void ok(char *m1) { errno = 0; out(OK, m1); } 58static void ok(const char *m1) { errno = 0; out(OK, m1); }
59 59
60static int svstatus_get(void) 60static int svstatus_get(void)
61{ 61{
62 if ((fd = open_write("supervise/ok")) == -1) { 62 fd = open_write("supervise/ok");
63 if (fd == -1) {
63 if (errno == ENODEV) { 64 if (errno == ENODEV) {
64 *acts == 'x' ? ok("runsv not running") 65 *acts == 'x' ? ok("runsv not running")
65 : failx("runsv not running"); 66 : failx("runsv not running");
@@ -69,7 +70,8 @@ static int svstatus_get(void)
69 return -1; 70 return -1;
70 } 71 }
71 close(fd); 72 close(fd);
72 if ((fd = open_read("supervise/status")) == -1) { 73 fd = open_read("supervise/status");
74 if (fd == -1) {
73 warn_cannot("open supervise/status"); 75 warn_cannot("open supervise/status");
74 return -1; 76 return -1;
75 } 77 }
@@ -83,7 +85,7 @@ static int svstatus_get(void)
83 return 1; 85 return 1;
84} 86}
85 87
86static unsigned svstatus_print(char *m) 88static unsigned svstatus_print(const char *m)
87{ 89{
88 int pid; 90 int pid;
89 int normallyup = 0; 91 int normallyup = 0;
@@ -121,7 +123,7 @@ static unsigned svstatus_print(char *m)
121 return pid ? 1 : 2; 123 return pid ? 1 : 2;
122} 124}
123 125
124static int status(char *unused) 126static int status(const char *unused)
125{ 127{
126 r = svstatus_get(); 128 r = svstatus_get();
127 switch (r) { case -1: case 0: return 0; } 129 switch (r) { case -1: case 0: return 0; }
@@ -156,8 +158,8 @@ static int checkscript(void)
156 return 0; 158 return 0;
157 } 159 }
158 if (!pid) { 160 if (!pid) {
159 prog[0] = "./check"; 161 prog[0] = (char*)"./check";
160 prog[1] = 0; 162 prog[1] = NULL;
161 close(1); 163 close(1);
162 execve("check", prog, environ); 164 execve("check", prog, environ);
163 bb_perror_msg(WARN"cannot run %s/check", *service); 165 bb_perror_msg(WARN"cannot run %s/check", *service);
@@ -171,7 +173,7 @@ static int checkscript(void)
171 return !wait_exitcode(w); 173 return !wait_exitcode(w);
172} 174}
173 175
174static int check(char *a) 176static int check(const char *a)
175{ 177{
176 unsigned pid; 178 unsigned pid;
177 179
@@ -200,15 +202,18 @@ static int check(char *a)
200 if ((!pid && tstart.sec.x > tstatus.x) || (pid && svstatus[17] != 'd')) 202 if ((!pid && tstart.sec.x > tstatus.x) || (pid && svstatus[17] != 'd'))
201 return 0; 203 return 0;
202 } 204 }
203 printf(OK); svstatus_print(*service); puts(""); /* will also flush the output */ 205 printf(OK);
206 svstatus_print(*service);
207 puts(""); /* will also flush the output */
204 return 1; 208 return 1;
205} 209}
206 210
207static int control(char *a) 211static int control(const char *a)
208{ 212{
209 if (svstatus_get() <= 0) return -1; 213 if (svstatus_get() <= 0) return -1;
210 if (svstatus[17] == *a) return 0; 214 if (svstatus[17] == *a) return 0;
211 if ((fd = open_write("supervise/control")) == -1) { 215 fd = open_write("supervise/control");
216 if (fd == -1) {
212 if (errno != ENODEV) 217 if (errno != ENODEV)
213 warn_cannot("open supervise/control"); 218 warn_cannot("open supervise/control");
214 else 219 else
@@ -245,15 +250,20 @@ int sv_main(int argc, char **argv)
245 if (opt & 4) usage(); 250 if (opt & 4) usage();
246 if (!(action = *argv++)) usage(); 251 if (!(action = *argv++)) usage();
247 --argc; 252 --argc;
248 service = argv; services = argc; 253 service = argv;
254 services = argc;
249 if (!*service) usage(); 255 if (!*service) usage();
250 256
251 taia_now(&tnow); tstart = tnow; 257 taia_now(&tnow);
252 if ((curdir = open_read(".")) == -1) 258 tstart = tnow;
259 curdir = open_read(".");
260 if (curdir == -1)
253 fatal_cannot("open current directory"); 261 fatal_cannot("open current directory");
254 262
255 act = &control; acts = "s"; 263 act = &control;
256 if (verbose) cbk = &check; 264 acts = "s";
265 if (verbose)
266 cbk = &check;
257 switch (*action) { 267 switch (*action) {
258 case 'x': case 'e': 268 case 'x': case 'e':
259 acts = "x"; break; 269 acts = "x"; break;
@@ -289,7 +299,9 @@ int sv_main(int argc, char **argv)
289 cbk = &check; 299 cbk = &check;
290 break; 300 break;
291 } 301 }
292 act = &status; cbk = 0; break; 302 act = &status;
303 cbk = NULL;
304 break;
293 case 'r': 305 case 'r':
294 if (!str_diff(action, "restart")) { 306 if (!str_diff(action, "restart")) {
295 acts = "tcu"; 307 acts = "tcu";