preparatory patch for -Wwrite-strings #5

This commit is contained in:
Denis Vlasenko
2007-01-29 23:43:18 +00:00
parent ab2aea4447
commit 89ef65f024
11 changed files with 49 additions and 60 deletions

View File

@@ -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

View File

@@ -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);

View File

@@ -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)
{

View File

@@ -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;

View File

@@ -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);

View File

@@ -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

View File

@@ -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

View File

@@ -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