svn commit: trunk/busybox: miscutils networking networking/libiprou etc...

vda at busybox.net vda at busybox.net
Mon Jan 29 23:43:18 UTC 2007


Author: vda
Date: 2007-01-29 15:43:18 -0800 (Mon, 29 Jan 2007)
New Revision: 17658

Log:
preparatory patch for -Wwrite-strings #5


Modified:
   trunk/busybox/miscutils/devfsd.c
   trunk/busybox/miscutils/mt.c
   trunk/busybox/miscutils/nmeter.c
   trunk/busybox/networking/ifupdown.c
   trunk/busybox/networking/libiproute/ip_common.h
   trunk/busybox/networking/libiproute/ip_parse_common_args.c
   trunk/busybox/networking/libiproute/iplink.c
   trunk/busybox/networking/libiproute/iproute.c
   trunk/busybox/networking/libiproute/utils.h
   trunk/busybox/networking/ping.c
   trunk/busybox/networking/zcip.c


Changeset:
Modified: trunk/busybox/miscutils/devfsd.c
===================================================================
--- trunk/busybox/miscutils/devfsd.c	2007-01-29 23:01:42 UTC (rev 17657)
+++ trunk/busybox/miscutils/devfsd.c	2007-01-29 23:43:18 UTC (rev 17658)
@@ -242,7 +242,7 @@
 									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_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 @@
 
 	/* 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 @@
 	/*  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 @@
 		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 @@
 	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 @@
 	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 @@
 	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 @@
 {
 	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 @@
 
 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 *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.

Modified: trunk/busybox/miscutils/mt.c
===================================================================
--- trunk/busybox/miscutils/mt.c	2007-01-29 23:01:42 UTC (rev 17657)
+++ trunk/busybox/miscutils/mt.c	2007-01-29 23:43:18 UTC (rev 17658)
@@ -7,7 +7,7 @@
 #include <sys/mtio.h>
 
 struct mt_opcodes {
-	char *name;
+	const char *name;
 	short value;
 };
 

Modified: trunk/busybox/miscutils/nmeter.c
===================================================================
--- trunk/busybox/miscutils/nmeter.c	2007-01-29 23:01:42 UTC (rev 17657)
+++ trunk/busybox/miscutils/nmeter.c	2007-01-29 23:43:18 UTC (rev 17658)
@@ -20,7 +20,7 @@
 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 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

Modified: trunk/busybox/networking/ifupdown.c
===================================================================
--- trunk/busybox/networking/ifupdown.c	2007-01-29 23:01:42 UTC (rev 17657)
+++ trunk/busybox/networking/ifupdown.c	2007-01-29 23:43:18 UTC (rev 17658)
@@ -36,22 +36,19 @@
 
 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 @@
 	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 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 @@
 
 static char **my_environ;
 
-static char *startup_PATH;
+static const char *startup_PATH;
 
 #if ENABLE_FEATURE_IFUPDOWN_IPV4 || ENABLE_FEATURE_IFUPDOWN_IPV6
 

Modified: trunk/busybox/networking/libiproute/ip_common.h
===================================================================
--- trunk/busybox/networking/libiproute/ip_common.h	2007-01-29 23:01:42 UTC (rev 17657)
+++ trunk/busybox/networking/libiproute/ip_common.h	2007-01-29 23:43:18 UTC (rev 17658)
@@ -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);

Modified: trunk/busybox/networking/libiproute/ip_parse_common_args.c
===================================================================
--- trunk/busybox/networking/libiproute/ip_parse_common_args.c	2007-01-29 23:01:42 UTC (rev 17657)
+++ trunk/busybox/networking/libiproute/ip_parse_common_args.c	2007-01-29 23:43:18 UTC (rev 17658)
@@ -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)
 {

Modified: trunk/busybox/networking/libiproute/iplink.c
===================================================================
--- trunk/busybox/networking/libiproute/iplink.c	2007-01-29 23:01:42 UTC (rev 17657)
+++ trunk/busybox/networking/libiproute/iplink.c	2007-01-29 23:43:18 UTC (rev 17658)
@@ -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;

Modified: trunk/busybox/networking/libiproute/iproute.c
===================================================================
--- trunk/busybox/networking/libiproute/iproute.c	2007-01-29 23:01:42 UTC (rev 17657)
+++ trunk/busybox/networking/libiproute/iproute.c	2007-01-29 23:43:18 UTC (rev 17658)
@@ -469,21 +469,15 @@
 
 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);

Modified: trunk/busybox/networking/libiproute/utils.h
===================================================================
--- trunk/busybox/networking/libiproute/utils.h	2007-01-29 23:01:42 UTC (rev 17657)
+++ trunk/busybox/networking/libiproute/utils.h	2007-01-29 23:43:18 UTC (rev 17658)
@@ -14,7 +14,8 @@
 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

Modified: trunk/busybox/networking/ping.c
===================================================================
--- trunk/busybox/networking/ping.c	2007-01-29 23:01:42 UTC (rev 17657)
+++ trunk/busybox/networking/ping.c	2007-01-29 23:43:18 UTC (rev 17658)
@@ -369,7 +369,7 @@
 }
 #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 @@
 #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 @@
 #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

Modified: trunk/busybox/networking/zcip.c
===================================================================
--- trunk/busybox/networking/zcip.c	2007-01-29 23:01:42 UTC (rev 17657)
+++ trunk/busybox/networking/zcip.c	2007-01-29 23:43:18 UTC (rev 17658)
@@ -130,10 +130,10 @@
 /**
  * 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 @@
 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




More information about the busybox-cvs mailing list