svn commit: trunk/busybox: findutils libbb modutils networking netw etc...

vda at busybox.net vda at busybox.net
Mon Jan 29 22:51:59 UTC 2007


Author: vda
Date: 2007-01-29 14:51:58 -0800 (Mon, 29 Jan 2007)
New Revision: 17656

Log:
preparatory patch for -Wwrite-strings #4


Modified:
   trunk/busybox/findutils/find.c
   trunk/busybox/libbb/lineedit.c
   trunk/busybox/modutils/insmod.c
   trunk/busybox/networking/arp.c
   trunk/busybox/networking/httpd.c
   trunk/busybox/networking/ifupdown.c
   trunk/busybox/networking/libiproute/iptunnel.c
   trunk/busybox/networking/libiproute/rt_names.c
   trunk/busybox/networking/libiproute/utils.c
   trunk/busybox/networking/libiproute/utils.h
   trunk/busybox/runit/runsv.c
   trunk/busybox/runit/runsvdir.c
   trunk/busybox/runit/svlogd.c
   trunk/busybox/sysklogd/syslogd.c


Changeset:
Modified: trunk/busybox/findutils/find.c
===================================================================
--- trunk/busybox/findutils/find.c	2007-01-29 22:51:44 UTC (rev 17655)
+++ trunk/busybox/findutils/find.c	2007-01-29 22:51:58 UTC (rev 17656)
@@ -497,7 +497,7 @@
 			}
 			ap = ALLOC_ACTION(paren);
 			ap->subexpr = parse_params(argv + 1);
-			*endarg = ")"; /* restore NULLed parameter */
+			*endarg = (char*) ")"; /* restore NULLed parameter */
 			argv = endarg;
 		}
 		else if (strcmp(arg, "-prune") == 0) {
@@ -537,7 +537,7 @@
 #endif
 	}
 	if (firstopt == 1) {
-		argv[0] = ".";
+		argv[0] = (char*)".";
 		argv--;
 		firstopt++;
 	}
@@ -553,7 +553,7 @@
 	while ((arg = argp[0])) {
 		if (strcmp(arg, "-follow") == 0) {
 			dereference = TRUE;
-			argp[0] = "-a";
+			argp[0] = (char*)"-a";
 		}
 #if ENABLE_FEATURE_FIND_XDEV
 		else if (strcmp(arg, "-xdev") == 0) {
@@ -569,7 +569,7 @@
 					xdev_dev[i-1] = stbuf.st_dev;
 				}
 			}
-			argp[0] = "-a";
+			argp[0] = (char*)"-a";
 		}
 #endif
 		argp++;

Modified: trunk/busybox/libbb/lineedit.c
===================================================================
--- trunk/busybox/libbb/lineedit.c	2007-01-29 22:51:44 UTC (rev 17655)
+++ trunk/busybox/libbb/lineedit.c	2007-01-29 22:51:58 UTC (rev 17656)
@@ -81,8 +81,8 @@
 #endif
 
 #if ENABLE_FEATURE_GETUSERNAME_AND_HOMEDIR
-static char *user_buf = "";
-static char *home_pwd_buf = "";
+static char *user_buf = (char*)"";
+static char *home_pwd_buf = (char*)"";
 #endif
 
 #if ENABLE_FEATURE_TAB_COMPLETION
@@ -422,7 +422,7 @@
 	char *pfind = strrchr(command, '/');
 
 	npaths = 1;
-	path1[0] = ".";
+	path1[0] = (char*)".";
 
 	if (pfind == NULL) {
 		/* no dir, if flags==EXE_ONLY - get paths, else "." */
@@ -447,7 +447,7 @@
 
 		while ((next = readdir(dir)) != NULL) {
 			int len1;
-			char *str_found = next->d_name;
+			const char *str_found = next->d_name;
 
 			/* matched? */
 			if (strncmp(str_found, pfind, strlen(pfind)))

Modified: trunk/busybox/modutils/insmod.c
===================================================================
--- trunk/busybox/modutils/insmod.c	2007-01-29 22:51:44 UTC (rev 17655)
+++ trunk/busybox/modutils/insmod.c	2007-01-29 22:51:58 UTC (rev 17656)
@@ -2540,7 +2540,7 @@
 					} else {
 						/* last string */
 						str = q;
-						q = "";
+						q = (char*)"";
 					}
 				}
 

Modified: trunk/busybox/networking/arp.c
===================================================================
--- trunk/busybox/networking/arp.c	2007-01-29 22:51:44 UTC (rev 17655)
+++ trunk/busybox/networking/arp.c	2007-01-29 22:51:58 UTC (rev 17656)
@@ -46,7 +46,7 @@
 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 @@
 
 /* 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 @@
 	char dev[100];
 	int type, flags;
 	FILE *fp;
-	char *hostname;
+	const char *hostname;
 	int num;
 	unsigned entries = 0, shown = 0;
 

Modified: trunk/busybox/networking/httpd.c
===================================================================
--- trunk/busybox/networking/httpd.c	2007-01-29 22:51:44 UTC (rev 17655)
+++ trunk/busybox/networking/httpd.c	2007-01-29 22:51:58 UTC (rev 17656)
@@ -653,17 +653,16 @@
 	/* 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 @@
 		/* (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 @@
 #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)

Modified: trunk/busybox/networking/ifupdown.c
===================================================================
--- trunk/busybox/networking/ifupdown.c	2007-01-29 22:51:44 UTC (rev 17655)
+++ trunk/busybox/networking/ifupdown.c	2007-01-29 22:51:58 UTC (rev 17656)
@@ -842,7 +842,7 @@
 	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;

Modified: trunk/busybox/networking/libiproute/iptunnel.c
===================================================================
--- trunk/busybox/networking/libiproute/iptunnel.c	2007-01-29 22:51:44 UTC (rev 17655)
+++ trunk/busybox/networking/libiproute/iptunnel.c	2007-01-29 22:51:58 UTC (rev 17656)
@@ -85,7 +85,7 @@
 
 
 
-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 @@
 	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 @@
 	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;

Modified: trunk/busybox/networking/libiproute/rt_names.c
===================================================================
--- trunk/busybox/networking/libiproute/rt_names.c	2007-01-29 22:51:44 UTC (rev 17655)
+++ trunk/busybox/networking/libiproute/rt_names.c	2007-01-29 22:51:58 UTC (rev 17656)
@@ -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 @@
 			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;

Modified: trunk/busybox/networking/libiproute/utils.c
===================================================================
--- trunk/busybox/networking/libiproute/utils.c	2007-01-29 22:51:44 UTC (rev 17655)
+++ trunk/busybox/networking/libiproute/utils.c	2007-01-29 22:51:58 UTC (rev 17656)
@@ -178,7 +178,7 @@
 
 	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 @@
 
 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)

Modified: trunk/busybox/networking/libiproute/utils.h
===================================================================
--- trunk/busybox/networking/libiproute/utils.h	2007-01-29 22:51:44 UTC (rev 17655)
+++ trunk/busybox/networking/libiproute/utils.h	2007-01-29 22:51:58 UTC (rev 17656)
@@ -75,9 +75,9 @@
 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);
 

Modified: trunk/busybox/runit/runsv.c
===================================================================
--- trunk/busybox/runit/runsv.c	2007-01-29 22:51:44 UTC (rev 17655)
+++ trunk/busybox/runit/runsv.c	2007-01-29 22:51:58 UTC (rev 17656)
@@ -42,26 +42,26 @@
 
 #define usage() bb_show_usage()
 
-static void fatal2_cannot(char *m1, char *m2)
+static void fatal2_cannot(const char *m1, const char *m2)
 {
 	bb_perror_msg_and_die("%s: fatal: cannot %s%s", dir, m1, m2);
 	/* was exiting 111 */
 }
-static void fatal_cannot(char *m)
+static void fatal_cannot(const char *m)
 {
 	fatal2_cannot(m, "");
 	/* was exiting 111 */
 }
-static void fatal2x_cannot(char *m1, char *m2)
+static void fatal2x_cannot(const char *m1, const char *m2)
 {
 	bb_error_msg_and_die("%s: fatal: cannot %s%s", dir, m1, m2);
 	/* was exiting 111 */
 }
-static void warn_cannot(char *m)
+static void warn_cannot(const char *m)
 {
 	bb_perror_msg("%s: warning: cannot %s", dir, m);
 }
-static void warnx_cannot(char *m)
+static void warnx_cannot(const char *m)
 {
 	bb_error_msg("%s: warning: cannot %s", dir, m);
 }
@@ -280,12 +280,12 @@
 	char *run[2];
 
 	if (s->state == S_FINISH)
-		run[0] = "./finish";
+		run[0] = (char*)"./finish";
 	else {
-		run[0] = "./run";
+		run[0] = (char*)"./run";
 		custom(s, 'u');
 	}
-	run[1] = 0;
+	run[1] = NULL;
 
 	if (s->pid != 0) stopservice(s); /* should never happen */
 	while ((p = fork()) == -1) {

Modified: trunk/busybox/runit/runsvdir.c
===================================================================
--- trunk/busybox/runit/runsvdir.c	2007-01-29 22:51:44 UTC (rev 17655)
+++ trunk/busybox/runit/runsvdir.c	2007-01-29 22:51:58 UTC (rev 17656)
@@ -28,20 +28,20 @@
 static int pgrp;
 
 #define usage() bb_show_usage()
-static void fatal2_cannot(char *m1, char *m2)
+static void fatal2_cannot(const char *m1, const char *m2)
 {
 	bb_perror_msg_and_die("%s: fatal: cannot %s%s", svdir, m1, m2);
 	/* was exiting 100 */
 }
-static void warn3x(char *m1, char *m2, char *m3)
+static void warn3x(const char *m1, const char *m2, const char *m3)
 {
 	bb_error_msg("%s: warning: %s%s%s", svdir, m1, m2, m3);
 }
-static void warn2_cannot(char *m1, char *m2)
+static void warn2_cannot(const char *m1, const char *m2)
 {
 	warn3x("cannot ", m1, m2);
 }
-static void warnx(char *m1)
+static void warnx(const char *m1)
 {
 	warn3x(m1, "", "");
 }
@@ -55,7 +55,7 @@
 	exitsoon = 2;
 }
 
-static void runsv(int no, char *name)
+static void runsv(int no, const char *name)
 {
 	int pid = fork();
 
@@ -67,8 +67,8 @@
 		/* child */
 		char *prog[3];
 
-		prog[0] = "runsv";
-		prog[1] = name;
+		prog[0] = (char*)"runsv";
+		prog[1] = (char*)name;
 		prog[2] = NULL;
 		sig_uncatch(SIGHUP);
 		sig_uncatch(SIGTERM);

Modified: trunk/busybox/runit/svlogd.c
===================================================================
--- trunk/busybox/runit/svlogd.c	2007-01-29 22:51:44 UTC (rev 17655)
+++ trunk/busybox/runit/svlogd.c	2007-01-29 22:51:58 UTC (rev 17656)
@@ -75,7 +75,7 @@
 	char match;
 	char matcherr;
 } *dir;
-static unsigned dirn = 0;
+static unsigned dirn;
 
 #define FATAL "fatal: "
 #define WARNING "warning: "
@@ -83,18 +83,18 @@
 #define INFO "info: "
 
 #define usage() bb_show_usage()
-static void fatalx(char *m0)
+static void fatalx(const char *m0)
 {
 	bb_error_msg_and_die(FATAL"%s", m0);
 }
-static void warn(char *m0) {
+static void warn(const char *m0) {
 	bb_perror_msg(WARNING"%s", m0);
 }
-static void warn2(char *m0, char *m1)
+static void warn2(const char *m0, const char *m1)
 {
 	bb_perror_msg(WARNING"%s: %s", m0, m1);
 }
-static void warnx(char *m0, char *m1)
+static void warnx(const char *m0, const char *m1)
 {
 	bb_error_msg(WARNING"%s: %s", m0, m1);
 }
@@ -103,12 +103,12 @@
 	bb_error_msg(PAUSE"out of memory");
 	sleep(3);
 }
-static void pause1cannot(char *m0)
+static void pause1cannot(const char *m0)
 {
 	bb_perror_msg(PAUSE"cannot %s", m0);
 	sleep(3);
 }
-static void pause2cannot(char *m0, char *m1)
+static void pause2cannot(const char *m0, const char *m1)
 {
 	bb_perror_msg(PAUSE"cannot %s %s", m0, m1);
 	sleep(3);
@@ -168,8 +168,8 @@
 			bb_perror_msg_and_die(FATAL"cannot %s processor %s", "move filedescriptor for", ld->name);
 
 // getenv("SHELL")?
-		prog[0] = "sh";
-		prog[1] = "-c";
+		prog[0] = (char*)"sh";
+		prog[1] = (char*)"-c";
 		prog[2] = ld->processor;
 		prog[3] = '\0';
 		execve("/bin/sh", prog, environ);

Modified: trunk/busybox/sysklogd/syslogd.c
===================================================================
--- trunk/busybox/sysklogd/syslogd.c	2007-01-29 22:51:44 UTC (rev 17655)
+++ trunk/busybox/sysklogd/syslogd.c	2007-01-29 22:51:58 UTC (rev 17656)
@@ -25,7 +25,7 @@
 #define DEBUG 0
 
 /* Path to the unix socket */
-static char *dev_log_name;
+static const char *dev_log_name;
 
 /* Path for the file where all log messages are written */
 static const char *logFilePath = "/var/log/messages";
@@ -444,7 +444,7 @@
 
 static void quit_signal(int sig)
 {
-	timestamp_and_log(LOG_SYSLOG | LOG_INFO, "syslogd exiting", 0);
+	timestamp_and_log(LOG_SYSLOG | LOG_INFO, (char*)"syslogd exiting", 0);
 	puts("syslogd exiting");
 	unlink(dev_log_name);
 	if (ENABLE_FEATURE_IPC_SYSLOG)
@@ -455,7 +455,7 @@
 static void do_mark(int sig)
 {
 	if (markInterval) {
-		timestamp_and_log(LOG_SYSLOG | LOG_INFO, "-- MARK --", 0);
+		timestamp_and_log(LOG_SYSLOG | LOG_INFO, (char*)"-- MARK --", 0);
 		alarm(markInterval);
 	}
 }
@@ -501,7 +501,8 @@
 		ipcsyslog_init();
 	}
 
-	timestamp_and_log(LOG_SYSLOG | LOG_INFO, "syslogd started: BusyBox v" BB_VER, 0);
+	timestamp_and_log(LOG_SYSLOG | LOG_INFO,
+			(char*)"syslogd started: BusyBox v" BB_VER, 0);
 
 	for (;;) {
 		FD_ZERO(&fds);




More information about the busybox-cvs mailing list