preparatory patch for -Wwrite-strings #5
authorDenis Vlasenko <vda.linux@googlemail.com>
Mon, 29 Jan 2007 23:43:18 +0000 (23:43 -0000)
committerDenis Vlasenko <vda.linux@googlemail.com>
Mon, 29 Jan 2007 23:43:18 +0000 (23:43 -0000)
miscutils/devfsd.c
miscutils/mt.c
miscutils/nmeter.c
networking/ifupdown.c
networking/libiproute/ip_common.h
networking/libiproute/ip_parse_common_args.c
networking/libiproute/iplink.c
networking/libiproute/iproute.c
networking/libiproute/utils.h
networking/ping.c
networking/zcip.c

index 5435a6a0bfd0a9d6c3503bc82ecd8fb0807aeb47..7c604f6048f2b3cd8d157770788690b5f36b81e0 100644 (file)
@@ -242,7 +242,7 @@ static const char *expand_variable( char *, unsigned, unsigned *, const char *,
                                                                        const char *(*) (const char *, void *), void * );
 static const char *get_variable_v2(const char *, const char *(*) (const char *, void *), void *);
 static char get_old_ide_name (unsigned , unsigned);
-static char *write_old_sd_name (char *, unsigned, unsigned, char *);
+static char *write_old_sd_name (char *, unsigned, unsigned, const char *);
 
 /* busybox functions */
 static void msg_logger(int pri, const char * fmt, ... )__attribute__ ((format (printf, 2, 3)));
@@ -262,8 +262,8 @@ static volatile int caught_signal = FALSE;
 static volatile int caught_sighup = FALSE;
 static struct initial_symlink_struct
 {
-    char *dest;
-    char *name;
+    const char *dest;
+    const char *name;
 } initial_symlinks[] =
 {
     {"/proc/self/fd", "fd"},
@@ -479,9 +479,8 @@ int devfsd_main (int argc, char **argv)
 
        /* NB: The check for CONFIG_FILE is done in read_config_file() */
 
-       if ( print_version  || (DEVFSD_PROTOCOL_REVISION_DAEMON != proto_rev) )
-       {
-               printf( "%s v%s\nDaemon %s:\t%d\nKernel-side %s:\t%d\n",
+       if (print_version || (DEVFSD_PROTOCOL_REVISION_DAEMON != proto_rev)) {
+               printf("%s v%s\nDaemon %s:\t%d\nKernel-side %s:\t%d\n",
                                applet_name,DEVFSD_VERSION,bb_msg_proto_rev,
                                DEVFSD_PROTOCOL_REVISION_DAEMON,bb_msg_proto_rev, proto_rev);
                if (DEVFSD_PROTOCOL_REVISION_DAEMON != proto_rev)
@@ -491,19 +490,19 @@ int devfsd_main (int argc, char **argv)
        /*  Tell kernel we are special (i.e. we get to see hidden entries)  */
        do_ioctl_and_die(fd, DEVFSDIOC_SET_EVENT_MASK, 0);
 
-       sigemptyset (&new_action.sa_mask);
+       sigemptyset(&new_action.sa_mask);
        new_action.sa_flags = 0;
 
        /*  Set up SIGHUP and SIGUSR1 handlers  */
        new_action.sa_handler = signal_handler;
-       if (sigaction (SIGHUP, &new_action, NULL) != 0 || sigaction (SIGUSR1, &new_action, NULL) != 0 )
+       if (sigaction(SIGHUP, &new_action, NULL) != 0 || sigaction (SIGUSR1, &new_action, NULL) != 0 )
                devfsd_error_msg_and_die( "sigaction");
 
        printf("%s v%s  started for %s\n",applet_name, DEVFSD_VERSION, mount_point);
 
        /*  Set umask so that mknod(2), open(2) and mkdir(2) have complete control over permissions  */
-       umask (0);
-       read_config_file (CONFIG_FILE, FALSE, &event_mask);
+       umask(0);
+       read_config_file((char*)CONFIG_FILE, FALSE, &event_mask);
        /*  Do the scan before forking, so that boot scripts see the finished product  */
        dir_operation(SERVICE,mount_point,0,NULL);
 
@@ -524,7 +523,7 @@ int devfsd_main (int argc, char **argv)
                do_scan = do_servicing (fd, event_mask);
 
                free_config ();
-               read_config_file (CONFIG_FILE, FALSE, &event_mask);
+               read_config_file ((char*)CONFIG_FILE, FALSE, &event_mask);
                if (do_scan)
                        dir_operation(SERVICE,mount_point,0,NULL);
        }
@@ -545,7 +544,7 @@ static void read_config_file (char *path, int optional, unsigned long *event_mas
        struct stat statbuf;
        FILE *fp;
        char buf[STRING_LENGTH];
-       char *line=NULL;
+       char *line = NULL;
 
        debug_msg_logger(LOG_INFO, "%s: %s", __FUNCTION__, path);
 
@@ -598,7 +597,7 @@ static void process_config_line (const char *line, unsigned long *event_mask)
        char p[MAX_ARGS][STRING_LENGTH];
        char when[STRING_LENGTH], what[STRING_LENGTH];
        char name[STRING_LENGTH];
-       char * msg="";
+       const char *msg = "";
        char *ptr;
        int i;
 
@@ -876,10 +875,10 @@ static void action_modload (const struct devfsd_notify_struct *info,
        char *argv[6];
        char device[STRING_LENGTH];
 
-       argv[0] = MODPROBE;
-       argv[1] = MODPROBE_SWITCH_1; /* "-k" */
-       argv[2] = MODPROBE_SWITCH_2; /* "-C" */
-       argv[3] = CONFIG_MODULES_DEVFS;
+       argv[0] = (char*)MODPROBE;
+       argv[1] = (char*)MODPROBE_SWITCH_1; /* "-k" */
+       argv[2] = (char*)MODPROBE_SWITCH_2; /* "-C" */
+       argv[3] = (char*)CONFIG_MODULES_DEVFS;
        argv[4] = device;
        argv[5] = NULL;
 
@@ -1221,7 +1220,7 @@ static int get_uid_gid (int flag, const char *string)
 {
        struct passwd *pw_ent;
        struct group *grp_ent;
-       static char *msg;
+       static const char *msg;
 
        if (ENABLE_DEVFSD_VERBOSE)
                msg="user";
@@ -1532,8 +1531,8 @@ static void expand_regexp (char *output, size_t outsize, const char *input,
 
 struct translate_struct
 {
-       char *match;    /*  The string to match to (up to length)                */
-       char *format;   /*  Format of output, "%s" takes data past match string,
+       const char *match;    /*  The string to match to (up to length)                */
+       const char *format;   /*  Format of output, "%s" takes data past match string,
                        NULL is effectively "%s" (just more efficient)       */
 };
 
@@ -1719,7 +1718,7 @@ static char get_old_ide_name (unsigned int major, unsigned int minor)
 
 static char *write_old_sd_name (char *buffer,
                                unsigned int major, unsigned int minor,
-                               char *part)
+                               const char *part)
 /*  [SUMMARY] Write the old SCSI disc name to a buffer.
     <buffer> The buffer to write to.
     <major> The major number for the device.
index 9ecec82a1acb90894493075b92673e5cf9d68932..a4b527f1b301cb278d4e0885ff45bd74c8450d26 100644 (file)
@@ -7,7 +7,7 @@
 #include <sys/mtio.h>
 
 struct mt_opcodes {
-       char *name;
+       const char *name;
        short value;
 };
 
index 1fa35b2935a07446ad16a5a4eba10bfef8e839b2..966131af51e095855a670fc72ea9bd356f6bf9d3 100644 (file)
@@ -20,7 +20,7 @@ typedef unsigned long long ullong;
 enum { proc_file_size = 4096 };
 
 typedef struct proc_file {
-       char *name;
+       const char *name;
        int gen;
        char *file;
 } proc_file;
@@ -38,7 +38,7 @@ static struct timeval tv;
 static int delta = 1000000;
 static int deltanz = 1000000;
 static int need_seconds = 0;
-static char *final_str = "\n";
+static const char *final_str = "\n";
 
 // We depend on this being a char[], not char* - we take sizeof() of it
 #define outbuf bb_common_bufsiz1
index 4ec3d37a88266c7e359110fb148455c9d0106f96..834c7fa7ddbb2c966216b23ab4c6c3f8c74eabc7 100644 (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
 
index 15291780e57acaf1603852aaf9390977b87b401f..05a6a95f57949fe5712c58bd7f6f66d1a264b6a3 100644 (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);
index 64386c9ddbfba8cb42e183bb52880875f3d897f5..00a891232a259bea41a6d7397fe4f5810e7987e3 100644 (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)
 {
index ae41ab308183c35efea33c3dcd088e1a7e3e1f6b..cb6ee962b8db02641b55e4f4824c5f7bd6084a3a 100644 (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;
index c8a58c11cd86b803ead55825a0e07b3269c04544..27d37ac79a86df9548f04ce5abe5909b21030c1f 100644 (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);
index ebf2af1943a1959b4336070bbe7a401e16a42c49..556541f792f1eef62f2d8de9e85489be0f3b8b9a 100644 (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
index 52e48867e3347388eedeebafd400439a8d87d1e6..53aabb6d7c20754bf939f098d1ed5eff13a9e9a6 100644 (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
index 5d57c4287a4daf4a1a3b54f171931184c3da9a29..b5687065268b6cfceb5c0bb8529c985aea0f8507 100644 (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