summaryrefslogtreecommitdiff
path: root/networking
diff options
context:
space:
mode:
authorDenis Vlasenko <vda.linux@googlemail.com>2007-01-29 22:51:58 +0000
committerDenis Vlasenko <vda.linux@googlemail.com>2007-01-29 22:51:58 +0000
commitab2aea44479fd6f519bccd651a37f30e792b7593 (patch)
tree443636e12ffb52db95168013bbda80f78ed49fe6 /networking
parent06c0a71d2315756db874e98bc4f760ca3283b6a6 (diff)
downloadbusybox-w32-ab2aea44479fd6f519bccd651a37f30e792b7593.tar.gz
busybox-w32-ab2aea44479fd6f519bccd651a37f30e792b7593.tar.bz2
busybox-w32-ab2aea44479fd6f519bccd651a37f30e792b7593.zip
preparatory patch for -Wwrite-strings #4
Diffstat (limited to 'networking')
-rw-r--r--networking/arp.c6
-rw-r--r--networking/httpd.c13
-rw-r--r--networking/ifupdown.c2
-rw-r--r--networking/libiproute/iptunnel.c6
-rw-r--r--networking/libiproute/rt_names.c11
-rw-r--r--networking/libiproute/utils.c20
-rw-r--r--networking/libiproute/utils.h6
7 files changed, 30 insertions, 34 deletions
diff --git a/networking/arp.c b/networking/arp.c
index 6bd12656a..33191d89b 100644
--- a/networking/arp.c
+++ b/networking/arp.c
@@ -46,7 +46,7 @@ static const struct aftype *ap; /* current address family */
46static const struct hwtype *hw; /* current hardware type */ 46static const struct hwtype *hw; /* current hardware type */
47static int sockfd; /* active socket descriptor */ 47static int sockfd; /* active socket descriptor */
48static smallint hw_set; /* flag if hw-type was set (-H) */ 48static smallint hw_set; /* flag if hw-type was set (-H) */
49static char *device = ""; /* current device */ 49static const char *device = ""; /* current device */
50 50
51static const char *const options[] = { 51static const char *const options[] = {
52 "pub", 52 "pub",
@@ -317,7 +317,7 @@ static int arp_set(char **args)
317 317
318/* Print the contents of an ARP request block. */ 318/* Print the contents of an ARP request block. */
319static void 319static void
320arp_disp(char *name, char *ip, int type, int arp_flags, 320arp_disp(const char *name, char *ip, int type, int arp_flags,
321 char *hwa, char *mask, char *dev) 321 char *hwa, char *mask, char *dev)
322{ 322{
323 const struct hwtype *xhw; 323 const struct hwtype *xhw;
@@ -371,7 +371,7 @@ static int arp_show(char *name)
371 char dev[100]; 371 char dev[100];
372 int type, flags; 372 int type, flags;
373 FILE *fp; 373 FILE *fp;
374 char *hostname; 374 const char *hostname;
375 int num; 375 int num;
376 unsigned entries = 0, shown = 0; 376 unsigned entries = 0, shown = 0;
377 377
diff --git a/networking/httpd.c b/networking/httpd.c
index ea9fe0974..e3f798c4c 100644
--- a/networking/httpd.c
+++ b/networking/httpd.c
@@ -653,17 +653,16 @@ static char *encodeString(const char *string)
653 /* take the simple route and encode everything */ 653 /* take the simple route and encode everything */
654 /* could possibly scan once to get length. */ 654 /* could possibly scan once to get length. */
655 int len = strlen(string); 655 int len = strlen(string);
656 char *out = malloc(len * 6 + 1); 656 char *out = xmalloc(len * 6 + 1);
657 char *p = out; 657 char *p = out;
658 char ch; 658 char ch;
659 659
660 if (!out) return "";
661 while ((ch = *string++)) { 660 while ((ch = *string++)) {
662 // very simple check for what to encode 661 // very simple check for what to encode
663 if (isalnum(ch)) *p++ = ch; 662 if (isalnum(ch)) *p++ = ch;
664 else p += sprintf(p, "&#%d;", (unsigned char) ch); 663 else p += sprintf(p, "&#%d;", (unsigned char) ch);
665 } 664 }
666 *p = 0; 665 *p = '\0';
667 return out; 666 return out;
668} 667}
669#endif /* FEATURE_HTTPD_ENCODE_URL_STR */ 668#endif /* FEATURE_HTTPD_ENCODE_URL_STR */
@@ -1051,15 +1050,15 @@ static int sendCgi(const char *url,
1051 /* (Older versions of bbox seem to do some decoding) */ 1050 /* (Older versions of bbox seem to do some decoding) */
1052 setenv1("QUERY_STRING", config->query); 1051 setenv1("QUERY_STRING", config->query);
1053 setenv1("SERVER_SOFTWARE", httpdVersion); 1052 setenv1("SERVER_SOFTWARE", httpdVersion);
1054 putenv("SERVER_PROTOCOL=HTTP/1.0"); 1053 putenv((char*)"SERVER_PROTOCOL=HTTP/1.0");
1055 putenv("GATEWAY_INTERFACE=CGI/1.1"); 1054 putenv((char*)"GATEWAY_INTERFACE=CGI/1.1");
1056 /* Having _separate_ variables for IP and port defeats 1055 /* Having _separate_ variables for IP and port defeats
1057 * the purpose of having socket abstraction. Which "port" 1056 * the purpose of having socket abstraction. Which "port"
1058 * are you using on Unix domain socket? 1057 * are you using on Unix domain socket?
1059 * IOW - REMOTE_PEER="1.2.3.4:56" makes much more sense. 1058 * IOW - REMOTE_PEER="1.2.3.4:56" makes much more sense.
1060 * Oh well... */ 1059 * Oh well... */
1061 { 1060 {
1062 char *p = config->rmt_ip_str ? : ""; 1061 char *p = config->rmt_ip_str ? : (char*)"";
1063 char *cp = strrchr(p, ':'); 1062 char *cp = strrchr(p, ':');
1064 if (ENABLE_FEATURE_IPV6 && cp && strchr(cp, ']')) 1063 if (ENABLE_FEATURE_IPV6 && cp && strchr(cp, ']'))
1065 cp = NULL; 1064 cp = NULL;
@@ -1078,7 +1077,7 @@ static int sendCgi(const char *url,
1078#if ENABLE_FEATURE_HTTPD_BASIC_AUTH 1077#if ENABLE_FEATURE_HTTPD_BASIC_AUTH
1079 if (config->remoteuser) { 1078 if (config->remoteuser) {
1080 setenv1("REMOTE_USER", config->remoteuser); 1079 setenv1("REMOTE_USER", config->remoteuser);
1081 putenv("AUTH_TYPE=Basic"); 1080 putenv((char*)"AUTH_TYPE=Basic");
1082 } 1081 }
1083#endif 1082#endif
1084 if (config->referer) 1083 if (config->referer)
diff --git a/networking/ifupdown.c b/networking/ifupdown.c
index adbc37e43..4ec3d37a8 100644
--- a/networking/ifupdown.c
+++ b/networking/ifupdown.c
@@ -842,7 +842,7 @@ static struct interfaces_file_t *read_interfaces(const char *filename)
842 return defn; 842 return defn;
843} 843}
844 844
845static char *setlocalenv(char *format, const char *name, const char *value) 845static char *setlocalenv(const char *format, const char *name, const char *value)
846{ 846{
847 char *result; 847 char *result;
848 char *here; 848 char *here;
diff --git a/networking/libiproute/iptunnel.c b/networking/libiproute/iptunnel.c
index a67803ff4..e2e75fce0 100644
--- a/networking/libiproute/iptunnel.c
+++ b/networking/libiproute/iptunnel.c
@@ -85,7 +85,7 @@ static char *do_ioctl_get_ifname(int idx)
85 85
86 86
87 87
88static int do_get_ioctl(char *basedev, struct ip_tunnel_parm *p) 88static int do_get_ioctl(const char *basedev, struct ip_tunnel_parm *p)
89{ 89{
90 struct ifreq ifr; 90 struct ifreq ifr;
91 int fd; 91 int fd;
@@ -102,7 +102,7 @@ static int do_get_ioctl(char *basedev, struct ip_tunnel_parm *p)
102 return err; 102 return err;
103} 103}
104 104
105static int do_add_ioctl(int cmd, char *basedev, struct ip_tunnel_parm *p) 105static int do_add_ioctl(int cmd, const char *basedev, struct ip_tunnel_parm *p)
106{ 106{
107 struct ifreq ifr; 107 struct ifreq ifr;
108 int fd; 108 int fd;
@@ -123,7 +123,7 @@ static int do_add_ioctl(int cmd, char *basedev, struct ip_tunnel_parm *p)
123 return err; 123 return err;
124} 124}
125 125
126static int do_del_ioctl(char *basedev, struct ip_tunnel_parm *p) 126static int do_del_ioctl(const char *basedev, struct ip_tunnel_parm *p)
127{ 127{
128 struct ifreq ifr; 128 struct ifreq ifr;
129 int fd; 129 int fd;
diff --git a/networking/libiproute/rt_names.c b/networking/libiproute/rt_names.c
index 686326ff9..797c83b4e 100644
--- a/networking/libiproute/rt_names.c
+++ b/networking/libiproute/rt_names.c
@@ -13,7 +13,7 @@
13#include "libbb.h" 13#include "libbb.h"
14#include "rt_names.h" 14#include "rt_names.h"
15 15
16static void rtnl_tab_initialize(char *file, const char **tab, int size) 16static void rtnl_tab_initialize(const char *file, const char **tab, int size)
17{ 17{
18 char buf[512]; 18 char buf[512];
19 FILE *fp; 19 FILE *fp;
@@ -30,10 +30,11 @@ static void rtnl_tab_initialize(char *file, const char **tab, int size)
30 p++; 30 p++;
31 if (*p == '#' || *p == '\n' || *p == 0) 31 if (*p == '#' || *p == '\n' || *p == 0)
32 continue; 32 continue;
33 if (sscanf(p, "0x%x %s\n", &id, namebuf) != 2 && 33 if (sscanf(p, "0x%x %s\n", &id, namebuf) != 2
34 sscanf(p, "0x%x %s #", &id, namebuf) != 2 && 34 && sscanf(p, "0x%x %s #", &id, namebuf) != 2
35 sscanf(p, "%d %s\n", &id, namebuf) != 2 && 35 && sscanf(p, "%d %s\n", &id, namebuf) != 2
36 sscanf(p, "%d %s #", &id, namebuf) != 2) { 36 && sscanf(p, "%d %s #", &id, namebuf) != 2
37 ) {
37 bb_error_msg("database %s is corrupted at %s", 38 bb_error_msg("database %s is corrupted at %s",
38 file, p); 39 file, p);
39 return; 40 return;
diff --git a/networking/libiproute/utils.c b/networking/libiproute/utils.c
index 5e06656f6..591c8933a 100644
--- a/networking/libiproute/utils.c
+++ b/networking/libiproute/utils.c
@@ -178,7 +178,7 @@ int get_prefix_1(inet_prefix * dst, char *arg, int family)
178 178
179 slash = strchr(arg, '/'); 179 slash = strchr(arg, '/');
180 if (slash) 180 if (slash)
181 *slash = 0; 181 *slash = '\0';
182 err = get_addr_1(dst, arg, family); 182 err = get_addr_1(dst, arg, family);
183 if (err == 0) { 183 if (err == 0) {
184 switch (dst->family) { 184 switch (dst->family) {
@@ -237,26 +237,22 @@ uint32_t get_addr32(char *name)
237 237
238void incomplete_command(void) 238void incomplete_command(void)
239{ 239{
240 bb_error_msg("command line is not complete, try option \"help\""); 240 bb_error_msg_and_die("command line is not complete, try option \"help\"");
241 exit(-1);
242} 241}
243 242
244void invarg(const char * const arg, const char * const opt) 243void invarg(const char *arg, const char *opt)
245{ 244{
246 bb_error_msg(bb_msg_invalid_arg, arg, opt); 245 bb_error_msg_and_die(bb_msg_invalid_arg, arg, opt);
247 exit(-1);
248} 246}
249 247
250void duparg(char *key, char *arg) 248void duparg(const char *key, const char *arg)
251{ 249{
252 bb_error_msg("duplicate \"%s\": \"%s\" is the second value", key, arg); 250 bb_error_msg_and_die("duplicate \"%s\": \"%s\" is the second value", key, arg);
253 exit(-1);
254} 251}
255 252
256void duparg2(char *key, char *arg) 253void duparg2(const char *key, const char *arg)
257{ 254{
258 bb_error_msg("either \"%s\" is duplicate, or \"%s\" is garbage", key, arg); 255 bb_error_msg_and_die("either \"%s\" is duplicate, or \"%s\" is garbage", key, arg);
259 exit(-1);
260} 256}
261 257
262int matches(const char *cmd, const char *pattern) 258int matches(const char *cmd, const char *pattern)
diff --git a/networking/libiproute/utils.h b/networking/libiproute/utils.h
index 5af8ba744..ebf2af194 100644
--- a/networking/libiproute/utils.h
+++ b/networking/libiproute/utils.h
@@ -75,9 +75,9 @@ extern int get_s8(int8_t *val, char *arg, int base);
75extern const char *format_host(int af, int len, void *addr, char *buf, int buflen); 75extern const char *format_host(int af, int len, void *addr, char *buf, int buflen);
76extern const char *rt_addr_n2a(int af, int len, void *addr, char *buf, int buflen); 76extern const char *rt_addr_n2a(int af, int len, void *addr, char *buf, int buflen);
77 77
78void invarg(const char * const, const char * const) ATTRIBUTE_NORETURN; 78void invarg(const char *, const char *) ATTRIBUTE_NORETURN;
79void duparg(char *, char *) ATTRIBUTE_NORETURN; 79void duparg(const char *, const char *) ATTRIBUTE_NORETURN;
80void duparg2(char *, char *) ATTRIBUTE_NORETURN; 80void duparg2(const char *, const char *) ATTRIBUTE_NORETURN;
81int matches(const char *arg, const char *pattern); 81int matches(const char *arg, const char *pattern);
82extern int inet_addr_match(inet_prefix *a, inet_prefix *b, int bits); 82extern int inet_addr_match(inet_prefix *a, inet_prefix *b, int bits);
83 83