diff options
author | Denis Vlasenko <vda.linux@googlemail.com> | 2007-01-30 01:51:58 +0300 |
---|---|---|
committer | Denis Vlasenko <vda.linux@googlemail.com> | 2007-01-30 01:51:58 +0300 |
commit | ab2aea44479fd6f519bccd651a37f30e792b7593 (patch) | |
tree | 443636e12ffb52db95168013bbda80f78ed49fe6 /networking | |
parent | 06c0a71d2315756db874e98bc4f760ca3283b6a6 (diff) |
preparatory patch for -Wwrite-strings #4
Diffstat (limited to 'networking')
-rw-r--r-- | networking/arp.c | 6 | ||||
-rw-r--r-- | networking/httpd.c | 13 | ||||
-rw-r--r-- | networking/ifupdown.c | 2 | ||||
-rw-r--r-- | networking/libiproute/iptunnel.c | 6 | ||||
-rw-r--r-- | networking/libiproute/rt_names.c | 11 | ||||
-rw-r--r-- | networking/libiproute/utils.c | 20 | ||||
-rw-r--r-- | networking/libiproute/utils.h | 6 |
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 */ static const struct hwtype *hw; /* current hardware type */ static int sockfd; /* active socket descriptor */ static smallint hw_set; /* flag if hw-type was set (-H) */ -static char *device = ""; /* current device */ +static const char *device = ""; /* current device */ static const char *const options[] = { "pub", @@ -317,7 +317,7 @@ static int arp_set(char **args) /* Print the contents of an ARP request block. */ static void -arp_disp(char *name, char *ip, int type, int arp_flags, +arp_disp(const char *name, char *ip, int type, int arp_flags, char *hwa, char *mask, char *dev) { const struct hwtype *xhw; @@ -371,7 +371,7 @@ static int arp_show(char *name) char dev[100]; int type, flags; FILE *fp; - char *hostname; + const char *hostname; int num; unsigned entries = 0, shown = 0; 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) /* take the simple route and encode everything */ /* could possibly scan once to get length. */ int len = strlen(string); - char *out = malloc(len * 6 + 1); + char *out = xmalloc(len * 6 + 1); char *p = out; char ch; - if (!out) return ""; while ((ch = *string++)) { // very simple check for what to encode if (isalnum(ch)) *p++ = ch; else p += sprintf(p, "&#%d;", (unsigned char) ch); } - *p = 0; + *p = '\0'; return out; } #endif /* FEATURE_HTTPD_ENCODE_URL_STR */ @@ -1051,15 +1050,15 @@ static int sendCgi(const char *url, /* (Older versions of bbox seem to do some decoding) */ setenv1("QUERY_STRING", config->query); setenv1("SERVER_SOFTWARE", httpdVersion); - putenv("SERVER_PROTOCOL=HTTP/1.0"); - putenv("GATEWAY_INTERFACE=CGI/1.1"); + putenv((char*)"SERVER_PROTOCOL=HTTP/1.0"); + putenv((char*)"GATEWAY_INTERFACE=CGI/1.1"); /* Having _separate_ variables for IP and port defeats * the purpose of having socket abstraction. Which "port" * are you using on Unix domain socket? * IOW - REMOTE_PEER="1.2.3.4:56" makes much more sense. * Oh well... */ { - char *p = config->rmt_ip_str ? : ""; + char *p = config->rmt_ip_str ? : (char*)""; char *cp = strrchr(p, ':'); if (ENABLE_FEATURE_IPV6 && cp && strchr(cp, ']')) cp = NULL; @@ -1078,7 +1077,7 @@ static int sendCgi(const char *url, #if ENABLE_FEATURE_HTTPD_BASIC_AUTH if (config->remoteuser) { setenv1("REMOTE_USER", config->remoteuser); - putenv("AUTH_TYPE=Basic"); + putenv((char*)"AUTH_TYPE=Basic"); } #endif 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) return defn; } -static char *setlocalenv(char *format, const char *name, const char *value) +static char *setlocalenv(const char *format, const char *name, const char *value) { char *result; 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) -static int do_get_ioctl(char *basedev, struct ip_tunnel_parm *p) +static int do_get_ioctl(const char *basedev, struct ip_tunnel_parm *p) { struct ifreq ifr; int fd; @@ -102,7 +102,7 @@ static int do_get_ioctl(char *basedev, struct ip_tunnel_parm *p) return err; } -static int do_add_ioctl(int cmd, char *basedev, struct ip_tunnel_parm *p) +static int do_add_ioctl(int cmd, const char *basedev, struct ip_tunnel_parm *p) { struct ifreq ifr; int fd; @@ -123,7 +123,7 @@ static int do_add_ioctl(int cmd, char *basedev, struct ip_tunnel_parm *p) return err; } -static int do_del_ioctl(char *basedev, struct ip_tunnel_parm *p) +static int do_del_ioctl(const char *basedev, struct ip_tunnel_parm *p) { struct ifreq ifr; 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 @@ #include "libbb.h" #include "rt_names.h" -static void rtnl_tab_initialize(char *file, const char **tab, int size) +static void rtnl_tab_initialize(const char *file, const char **tab, int size) { char buf[512]; FILE *fp; @@ -30,10 +30,11 @@ static void rtnl_tab_initialize(char *file, const char **tab, int size) p++; if (*p == '#' || *p == '\n' || *p == 0) continue; - if (sscanf(p, "0x%x %s\n", &id, namebuf) != 2 && - sscanf(p, "0x%x %s #", &id, namebuf) != 2 && - sscanf(p, "%d %s\n", &id, namebuf) != 2 && - sscanf(p, "%d %s #", &id, namebuf) != 2) { + if (sscanf(p, "0x%x %s\n", &id, namebuf) != 2 + && sscanf(p, "0x%x %s #", &id, namebuf) != 2 + && sscanf(p, "%d %s\n", &id, namebuf) != 2 + && sscanf(p, "%d %s #", &id, namebuf) != 2 + ) { bb_error_msg("database %s is corrupted at %s", file, p); 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) slash = strchr(arg, '/'); if (slash) - *slash = 0; + *slash = '\0'; err = get_addr_1(dst, arg, family); if (err == 0) { switch (dst->family) { @@ -237,26 +237,22 @@ uint32_t get_addr32(char *name) void incomplete_command(void) { - bb_error_msg("command line is not complete, try option \"help\""); - exit(-1); + bb_error_msg_and_die("command line is not complete, try option \"help\""); } -void invarg(const char * const arg, const char * const opt) +void invarg(const char *arg, const char *opt) { - bb_error_msg(bb_msg_invalid_arg, arg, opt); - exit(-1); + bb_error_msg_and_die(bb_msg_invalid_arg, arg, opt); } -void duparg(char *key, char *arg) +void duparg(const char *key, const char *arg) { - bb_error_msg("duplicate \"%s\": \"%s\" is the second value", key, arg); - exit(-1); + bb_error_msg_and_die("duplicate \"%s\": \"%s\" is the second value", key, arg); } -void duparg2(char *key, char *arg) +void duparg2(const char *key, const char *arg) { - bb_error_msg("either \"%s\" is duplicate, or \"%s\" is garbage", key, arg); - exit(-1); + bb_error_msg_and_die("either \"%s\" is duplicate, or \"%s\" is garbage", key, arg); } int 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); extern const char *format_host(int af, int len, void *addr, char *buf, int buflen); extern const char *rt_addr_n2a(int af, int len, void *addr, char *buf, int buflen); -void invarg(const char * const, const char * const) ATTRIBUTE_NORETURN; -void duparg(char *, char *) ATTRIBUTE_NORETURN; -void duparg2(char *, char *) ATTRIBUTE_NORETURN; +void invarg(const char *, const char *) ATTRIBUTE_NORETURN; +void duparg(const char *, const char *) ATTRIBUTE_NORETURN; +void duparg2(const char *, const char *) ATTRIBUTE_NORETURN; int matches(const char *arg, const char *pattern); extern int inet_addr_match(inet_prefix *a, inet_prefix *b, int bits); |