From 89ef65f02463b27313ff0eba806aa6e4aec10716 Mon Sep 17 00:00:00 2001 From: Denis Vlasenko Date: Mon, 29 Jan 2007 23:43:18 +0000 Subject: preparatory patch for -Wwrite-strings #5 --- networking/ifupdown.c | 24 +++++++++--------------- networking/libiproute/ip_common.h | 3 ++- networking/libiproute/ip_parse_common_args.c | 2 +- networking/libiproute/iplink.c | 2 +- networking/libiproute/iproute.c | 16 +++++----------- networking/libiproute/utils.h | 3 ++- networking/ping.c | 6 +++--- networking/zcip.c | 6 +++--- 8 files changed, 26 insertions(+), 36 deletions(-) (limited to 'networking') diff --git a/networking/ifupdown.c b/networking/ifupdown.c index 4ec3d37a8..834c7fa7d 100644 --- a/networking/ifupdown.c +++ b/networking/ifupdown.c @@ -36,22 +36,19 @@ struct interface_defn_t; typedef int execfn(char *command); -struct method_t -{ - char *name; +struct method_t { + const char *name; int (*up)(struct interface_defn_t *ifd, execfn *e); int (*down)(struct interface_defn_t *ifd, execfn *e); }; -struct address_family_t -{ - char *name; +struct address_family_t { + const char *name; int n_methods; const struct method_t *method; }; -struct mapping_defn_t -{ +struct mapping_defn_t { struct mapping_defn_t *next; int max_matches; @@ -65,14 +62,12 @@ struct mapping_defn_t char **mapping; }; -struct variable_t -{ +struct variable_t { char *name; char *value; }; -struct interface_defn_t -{ +struct interface_defn_t { const struct address_family_t *address_family; const struct method_t *method; @@ -82,8 +77,7 @@ struct interface_defn_t struct variable_t *option; }; -struct interfaces_file_t -{ +struct interfaces_file_t { llist_t *autointerfaces; llist_t *ifaces; struct mapping_defn_t *mappings; @@ -105,7 +99,7 @@ enum { static char **my_environ; -static char *startup_PATH; +static const char *startup_PATH; #if ENABLE_FEATURE_IFUPDOWN_IPV4 || ENABLE_FEATURE_IFUPDOWN_IPV6 diff --git a/networking/libiproute/ip_common.h b/networking/libiproute/ip_common.h index 15291780e..05a6a95f5 100644 --- a/networking/libiproute/ip_common.h +++ b/networking/libiproute/ip_common.h @@ -14,7 +14,8 @@ #endif extern int preferred_family; -extern char * _SL_; +//FIXME! Appears in two .h files! +extern const char * _SL_; extern void ip_parse_common_args(int *argcp, char ***argvp); extern int print_neigh(struct sockaddr_nl *who, struct nlmsghdr *n, void *arg); diff --git a/networking/libiproute/ip_parse_common_args.c b/networking/libiproute/ip_parse_common_args.c index 64386c9dd..00a891232 100644 --- a/networking/libiproute/ip_parse_common_args.c +++ b/networking/libiproute/ip_parse_common_args.c @@ -24,7 +24,7 @@ int preferred_family = AF_UNSPEC; int oneline = 0; -char * _SL_ = NULL; +const char * _SL_ = NULL; void ip_parse_common_args(int *argcp, char ***argvp) { diff --git a/networking/libiproute/iplink.c b/networking/libiproute/iplink.c index ae41ab308..cb6ee962b 100644 --- a/networking/libiproute/iplink.c +++ b/networking/libiproute/iplink.c @@ -25,7 +25,7 @@ /* take from linux/sockios.h */ #define SIOCSIFNAME 0x8923 /* set interface name */ -static int on_off(char *msg) +static int on_off(const char *msg) { bb_error_msg("error: argument of \"%s\" must be \"on\" or \"off\"", msg); return -1; diff --git a/networking/libiproute/iproute.c b/networking/libiproute/iproute.c index c8a58c11c..27d37ac79 100644 --- a/networking/libiproute/iproute.c +++ b/networking/libiproute/iproute.c @@ -469,21 +469,15 @@ static int rtnl_rtcache_request(struct rtnl_handle *rth, int family) static int iproute_flush_cache(void) { -#define ROUTE_FLUSH_PATH "/proc/sys/net/ipv4/route/flush" - - int len; - int flush_fd = open (ROUTE_FLUSH_PATH, O_WRONLY); - char *buffer = "-1"; - + static const char fn[] = "/proc/sys/net/ipv4/route/flush"; + int flush_fd = open(fn, O_WRONLY); if (flush_fd < 0) { - fprintf(stderr, "Cannot open \"%s\"\n", ROUTE_FLUSH_PATH); + bb_perror_msg("cannot open '%s'", fn); return -1; } - len = strlen (buffer); - - if ((write (flush_fd, (void *)buffer, len)) < len) { - fprintf(stderr, "Cannot flush routing cache\n"); + if (write(flush_fd, "-1", 2) < 2) { + bb_perror_msg("cannot flush routing cache"); return -1; } close(flush_fd); diff --git a/networking/libiproute/utils.h b/networking/libiproute/utils.h index ebf2af194..556541f79 100644 --- a/networking/libiproute/utils.h +++ b/networking/libiproute/utils.h @@ -14,7 +14,8 @@ extern int show_details; extern int show_raw; extern int resolve_hosts; extern int oneline; -extern char * _SL_; +//FIXME! Appears in two .h files! +extern const char * _SL_; #ifndef IPPROTO_ESP #define IPPROTO_ESP 50 diff --git a/networking/ping.c b/networking/ping.c index 52e48867e..53aabb6d7 100644 --- a/networking/ping.c +++ b/networking/ping.c @@ -369,7 +369,7 @@ static void sendping6(int junk ATTRIBUTE_UNUSED) } #endif -static char *icmp_type_name(int id) +static const char *icmp_type_name(int id) { switch (id) { case ICMP_ECHOREPLY: return "Echo Reply"; @@ -400,7 +400,7 @@ static char *icmp_type_name(int id) #ifndef MLD_LISTENER_REDUCTION # define MLD_LISTENER_REDUCTION ICMP6_MEMBERSHIP_REDUCTION #endif -static char *icmp6_type_name(int id) +static const char *icmp6_type_name(int id) { switch (id) { case ICMP6_DST_UNREACH: return "Destination Unreachable"; @@ -761,7 +761,7 @@ int ping_main(int argc, char **argv) #if ENABLE_PING6 int ping6_main(int argc, char **argv) { - argv[0] = "-6"; + argv[0] = (char*)"-6"; return ping_main(argc + 1, argv - 1); } #endif diff --git a/networking/zcip.c b/networking/zcip.c index 5d57c4287..b56870652 100644 --- a/networking/zcip.c +++ b/networking/zcip.c @@ -130,10 +130,10 @@ static void arp(int fd, struct sockaddr *saddr, int op, /** * Run a script. */ -static int run(char *script, char *arg, char *intf, struct in_addr *ip) +static int run(const char *script, const char *arg, const char *intf, struct in_addr *ip) { int pid, status; - char *why; + const char *why; if(1) { //always true: if (script != NULL) VDBG("%s run %s %s\n", intf, script, arg); @@ -207,7 +207,7 @@ static int state = PROBE; int zcip_main(int argc, char *argv[]) { struct ether_addr eth_addr; - char *why; + const char *why; int fd; // parse commandline: prog [options] ifname script -- cgit v1.2.3