svn commit: trunk/busybox: applets archival coreutils editors inclu etc...

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


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

Log:
preparatory patch for -Wwrite-strings #1


Modified:
   trunk/busybox/applets/applets.c
   trunk/busybox/archival/tar.c
   trunk/busybox/coreutils/cat.c
   trunk/busybox/coreutils/date.c
   trunk/busybox/coreutils/du.c
   trunk/busybox/coreutils/expr.c
   trunk/busybox/coreutils/fold.c
   trunk/busybox/coreutils/head.c
   trunk/busybox/coreutils/ln.c
   trunk/busybox/coreutils/md5_sha1_sum.c
   trunk/busybox/coreutils/printf.c
   trunk/busybox/coreutils/tail.c
   trunk/busybox/coreutils/yes.c
   trunk/busybox/editors/awk.c
   trunk/busybox/editors/ed.c
   trunk/busybox/include/libbb.h
   trunk/busybox/libbb/find_root_device.c


Changeset:
Modified: trunk/busybox/applets/applets.c
===================================================================
--- trunk/busybox/applets/applets.c	2007-01-29 22:40:38 UTC (rev 17652)
+++ trunk/busybox/applets/applets.c	2007-01-29 22:51:00 UTC (rev 17653)
@@ -106,7 +106,7 @@
 }
 
 
-#define parse_error(x)  { err=x; goto pe_label; }
+#define parse_error(x)  do { errmsg = x; goto pe_label; } while(0)
 
 /* Don't depend on the tools to combine strings. */
 static const char config_file[] = CONFIG_FILE;
@@ -130,7 +130,7 @@
 	struct BB_suid_config *sct;
 	struct BB_applet *applet;
 	FILE *f;
-	char *err;
+	const char *errmsg;
 	char *s;
 	char *e;
 	int i, lc, section;
@@ -307,7 +307,7 @@
 
  pe_label:
 	fprintf(stderr, "Parse error in %s, line %d: %s\n",
-			config_file, lc, err);
+			config_file, lc, errmsg);
 
 	fclose(f);
 	/* Release any allocated memory before returning. */

Modified: trunk/busybox/archival/tar.c
===================================================================
--- trunk/busybox/archival/tar.c	2007-01-29 22:40:38 UTC (rev 17652)
+++ trunk/busybox/archival/tar.c	2007-01-29 22:51:00 UTC (rev 17653)
@@ -504,7 +504,7 @@
 		int gzipDataPipe[2] = { -1, -1 };
 		int gzipStatusPipe[2] = { -1, -1 };
 		volatile int vfork_exec_errno = 0;
-		char *zip_exec = (gzip == 1) ? "gzip" : "bzip2";
+		const char *zip_exec = (gzip == 1) ? "gzip" : "bzip2";
 
 		if (pipe(gzipDataPipe) < 0 || pipe(gzipStatusPipe) < 0)
 			bb_perror_msg_and_die("pipe");

Modified: trunk/busybox/coreutils/cat.c
===================================================================
--- trunk/busybox/coreutils/cat.c	2007-01-29 22:40:38 UTC (rev 17652)
+++ trunk/busybox/coreutils/cat.c	2007-01-29 22:51:00 UTC (rev 17653)
@@ -14,7 +14,7 @@
 
 int bb_cat(char **argv)
 {
-	static char *const argv_dash[] = { "-", NULL };
+	static const char *const argv_dash[] = { "-", NULL };
 	FILE *f;
 	int retval = EXIT_SUCCESS;
 

Modified: trunk/busybox/coreutils/date.c
===================================================================
--- trunk/busybox/coreutils/date.c	2007-01-29 22:40:38 UTC (rev 17652)
+++ trunk/busybox/coreutils/date.c	2007-01-29 22:51:00 UTC (rev 17653)
@@ -41,7 +41,7 @@
 static void maybe_set_utc(int opt)
 {
 	if (opt & DATE_OPT_UTC)
-		xputenv("TZ=UTC0");
+		xputenv((char*)"TZ=UTC0");
 }
 
 int date_main(int argc, char **argv)
@@ -218,7 +218,7 @@
 			i = 22;
 			goto format_utc;
 		} else /* default case */
-			date_fmt = "%a %b %e %H:%M:%S %Z %Y";
+			date_fmt = (char*)"%a %b %e %H:%M:%S %Z %Y";
 	}
 
 	if (*date_fmt == '\0') {
@@ -228,7 +228,7 @@
 		/* Handle special conversions */
 
 		if (strncmp(date_fmt, "%f", 2) == 0) {
-			date_fmt = "%Y.%m.%d-%H:%M:%S";
+			date_fmt = (char*)"%Y.%m.%d-%H:%M:%S";
 		}
 
 		/* Generate output string */

Modified: trunk/busybox/coreutils/du.c
===================================================================
--- trunk/busybox/coreutils/du.c	2007-01-29 22:40:38 UTC (rev 17652)
+++ trunk/busybox/coreutils/du.c	2007-01-29 22:51:00 UTC (rev 17653)
@@ -222,7 +222,7 @@
 	/* go through remaining args (if any) */
 	argv += optind;
 	if (optind >= argc) {
-		*--argv = ".";
+		*--argv = (char*)".";
 		if (slink_depth == 1) {
 			slink_depth = 0;
 		}

Modified: trunk/busybox/coreutils/expr.c
===================================================================
--- trunk/busybox/coreutils/expr.c	2007-01-29 22:40:38 UTC (rev 17652)
+++ trunk/busybox/coreutils/expr.c	2007-01-29 22:51:00 UTC (rev 17653)
@@ -67,8 +67,8 @@
 static VALUE *docolon(VALUE * sv, VALUE * pv);
 static VALUE *eval(void);
 static VALUE *int_value(arith_t i);
-static VALUE *str_value(char *s);
-static int nextarg(char *str);
+static VALUE *str_value(const char *s);
+static int nextarg(const char *str);
 static int null(VALUE * v);
 static int toarith(VALUE * v);
 static void freev(VALUE * v);
@@ -110,7 +110,7 @@
 
 /* Return a VALUE for S.  */
 
-static VALUE *str_value(char *s)
+static VALUE *str_value(const char *s)
 {
 	VALUE *v;
 
@@ -172,7 +172,7 @@
 /* Return nonzero if the next token matches STR exactly.
    STR must not be NULL.  */
 
-static int nextarg(char *str)
+static int nextarg(const char *str)
 {
 	if (*args == NULL)
 		return 0;

Modified: trunk/busybox/coreutils/fold.c
===================================================================
--- trunk/busybox/coreutils/fold.c	2007-01-29 22:40:38 UTC (rev 17652)
+++ trunk/busybox/coreutils/fold.c	2007-01-29 22:51:00 UTC (rev 17653)
@@ -66,7 +66,7 @@
 
 	argv += optind;
 	if (!*argv) {
-		*--argv = "-";
+		*--argv = (char*)"-";
 	}
 
 	do {

Modified: trunk/busybox/coreutils/head.c
===================================================================
--- trunk/busybox/coreutils/head.c	2007-01-29 22:40:38 UTC (rev 17652)
+++ trunk/busybox/coreutils/head.c	2007-01-29 22:51:00 UTC (rev 17653)
@@ -92,7 +92,7 @@
 
 	argv += optind;
 	if (!*argv) {
-		*--argv = "-";
+		*--argv = (char*)"-";
 	}
 
 	fmt = header_fmt_str + 1;

Modified: trunk/busybox/coreutils/ln.c
===================================================================
--- trunk/busybox/coreutils/ln.c	2007-01-29 22:40:38 UTC (rev 17652)
+++ trunk/busybox/coreutils/ln.c	2007-01-29 22:51:00 UTC (rev 17653)
@@ -26,7 +26,7 @@
 	char *last;
 	char *src_name;
 	char *src;
-	char *suffix = "~";
+	char *suffix = (char*)"~";
 	struct stat statbuf;
 	int (*link_func)(const char *, const char *);
 

Modified: trunk/busybox/coreutils/md5_sha1_sum.c
===================================================================
--- trunk/busybox/coreutils/md5_sha1_sum.c	2007-01-29 22:40:38 UTC (rev 17652)
+++ trunk/busybox/coreutils/md5_sha1_sum.c	2007-01-29 22:51:00 UTC (rev 17653)
@@ -102,7 +102,7 @@
 	}
 
 	if (argc == optind) {
-		argv[argc++] = "-";
+		argv[argc++] = (char*)"-";
 	}
 
 	if (ENABLE_FEATURE_MD5_SHA1_SUM_CHECK && (flags & FLAG_CHECK)) {

Modified: trunk/busybox/coreutils/printf.c
===================================================================
--- trunk/busybox/coreutils/printf.c	2007-01-29 22:40:38 UTC (rev 17652)
+++ trunk/busybox/coreutils/printf.c	2007-01-29 22:51:00 UTC (rev 17653)
@@ -42,11 +42,11 @@
 
 static int print_formatted(char *format, int argc, char **argv);
 static void print_direc(char *start, size_t length,
-			int field_width, int precision, char *argument);
+		int field_width, int precision, const char *argument);
 
-typedef void (*converter)(char *arg, void *result);
+typedef void (*converter)(const char *arg, void *result);
 
-static void multiconvert(char *arg, void *result, converter convert)
+static void multiconvert(const char *arg, void *result, converter convert)
 {
 	char s[16];
 	if (*arg == '"' || *arg == '\'') {
@@ -58,15 +58,15 @@
 		fputs(arg, stderr);
 }
 
-static void conv_strtoul(char *arg, void *result)
+static void conv_strtoul(const char *arg, void *result)
 {
 	*(unsigned long*)result = bb_strtoul(arg, NULL, 10);
 }
-static void conv_strtol(char *arg, void *result)
+static void conv_strtol(const char *arg, void *result)
 {
 	*(long*)result = bb_strtol(arg, NULL, 10);
 }
-static void conv_strtod(char *arg, void *result)
+static void conv_strtod(const char *arg, void *result)
 {
 	char *end;
 	/* Well, this one allows leading whitespace... so what */
@@ -75,21 +75,21 @@
 	if (end[0]) errno = ERANGE;
 }
 
-static unsigned long my_xstrtoul(char *arg)
+static unsigned long my_xstrtoul(const char *arg)
 {
 	unsigned long result;
 	multiconvert(arg, &result, conv_strtoul);
 	return result;
 }
 
-static long my_xstrtol(char *arg)
+static long my_xstrtol(const char *arg)
 {
 	long result;
 	multiconvert(arg, &result, conv_strtol);
 	return result;
 }
 
-static double my_xstrtod(char *arg)
+static double my_xstrtod(const char *arg)
 {
 	double result;
 	multiconvert(arg, &result, conv_strtod);
@@ -239,7 +239,7 @@
 
 static void
 print_direc(char *start, size_t length, int field_width, int precision,
-			char *argument)
+		const char *argument)
 {
 	char *p;		/* Null-terminated copy of % directive. */
 

Modified: trunk/busybox/coreutils/tail.c
===================================================================
--- trunk/busybox/coreutils/tail.c	2007-01-29 22:40:38 UTC (rev 17652)
+++ trunk/busybox/coreutils/tail.c	2007-01-29 22:51:00 UTC (rev 17653)
@@ -91,7 +91,7 @@
 	if (argc >= 2 && (argv[1][0] == '+' || argv[1][0] == '-')
 	 && isdigit(argv[1][1])
 	) {
-		argv[0] = "-n";
+		argv[0] = (char*)"-n";
 		argv--;
 		argc++;
 	}

Modified: trunk/busybox/coreutils/yes.c
===================================================================
--- trunk/busybox/coreutils/yes.c	2007-01-29 22:40:38 UTC (rev 17652)
+++ trunk/busybox/coreutils/yes.c	2007-01-29 22:51:00 UTC (rev 17653)
@@ -22,7 +22,7 @@
 	const char *fmt;
 	char **first_arg;
 
-	*argv = "y";
+	*argv = (char*)"y";
 	if (argc != 1) {
 		++argv;
 	}

Modified: trunk/busybox/editors/awk.c
===================================================================
--- trunk/busybox/editors/awk.c	2007-01-29 22:40:38 UTC (rev 17652)
+++ trunk/busybox/editors/awk.c	2007-01-29 22:51:00 UTC (rev 17653)
@@ -47,7 +47,7 @@
 typedef struct chain_s {
 	struct node_s *first;
 	struct node_s *last;
-	char *programname;
+	const char *programname;
 } chain;
 
 /* Function */
@@ -399,7 +399,7 @@
 static node *break_ptr, *continue_ptr;
 static rstream *iF;
 static xhash *vhash, *ahash, *fdhash, *fnhash;
-static char *programname;
+static const char *programname;
 static short lineno;
 static int is_f0_split;
 static int nfields;
@@ -703,7 +703,7 @@
 	return v;
 }
 
-static char *getvar_s(var *v)
+static const char *getvar_s(var *v)
 {
 	/* if v is numeric and has no cached string, convert it to string */
 	if ((v->type & (VF_NUMBER | VF_CACHED)) == VF_NUMBER) {
@@ -995,7 +995,7 @@
 	return n;
 }
 
-static node *mk_re_node(char *s, node *n, regex_t *re)
+static node *mk_re_node(const char *s, node *n, regex_t *re)
 {
 	n->info = OC_REGEXP;
 	n->l.re = re;
@@ -1347,7 +1347,7 @@
 
 /* -------- program execution part -------- */
 
-static node *mk_splitter(char *s, tsplitter *spl)
+static node *mk_splitter(const char *s, tsplitter *spl)
 {
 	regex_t *re, *ire;
 	node *n;
@@ -1375,7 +1375,7 @@
 static regex_t *as_regex(node *op, regex_t *preg)
 {
 	var *v;
-	char *s;
+	const char *s;
 
 	if ((op->info & OPCLSMASK) == OC_REGEXP) {
 		return icase ? op->r.ire : op->l.re;
@@ -1419,7 +1419,7 @@
 	nfields = size;
 }
 
-static int awk_split(char *s, node *spl, char **slist)
+static int awk_split(const char *s, node *spl, char **slist)
 {
 	int l, n = 0;
 	char c[4];
@@ -1427,7 +1427,8 @@
 	regmatch_t pmatch[2];
 
 	/* in worst case, each char would be a separate field */
-	*slist = s1 = xstrndup(s, strlen(s) * 2 + 3);
+	*slist = s1 = xzalloc(strlen(s) * 2 + 3);
+	strcpy(s1, s);
 
 	c[0] = c[1] = (char)spl->info;
 	c[2] = c[3] = '\0';
@@ -1436,8 +1437,9 @@
 	if ((spl->info & OPCLSMASK) == OC_REGEXP) {		/* regex split */
 		while (*s) {
 			l = strcspn(s, c+2);
-			if (regexec(icase ? spl->r.ire : spl->l.re, s, 1, pmatch, 0) == 0 &&
-			pmatch[0].rm_so <= l) {
+			if (regexec(icase ? spl->r.ire : spl->l.re, s, 1, pmatch, 0) == 0
+			 && pmatch[0].rm_so <= l
+			) {
 				l = pmatch[0].rm_so;
 				if (pmatch[0].rm_eo == 0) { l++; pmatch[0].rm_eo++; }
 			} else {
@@ -1510,7 +1512,8 @@
 static void handle_special(var *v)
 {
 	int n;
-	char *b, *sep, *s;
+	char *b;
+	const char *sep, *s;
 	int sl, l, len, i, bsize;
 
 	if (!(v->type & VF_SPECIAL))
@@ -1737,7 +1740,8 @@
 static char *awk_printf(node *n)
 {
 	char *b = NULL;
-	char *fmt, *s, *s1, *f;
+	char *fmt, *s, *f;
+	const char *s1;
 	int i, j, incr, bsize;
 	char c, c1;
 	var *v, *arg;
@@ -1793,10 +1797,11 @@
  * all matches. If src or dst is NULL, use $0. If ex=TRUE, enable
  * subexpression matching (\1-\9)
  */
-static int awk_sub(node *rn, char *repl, int nm, var *src, var *dest, int ex)
+static int awk_sub(node *rn, const char *repl, int nm, var *src, var *dest, int ex)
 {
 	char *ds = NULL;
-	char *sp, *s;
+	const char *s;
+	const char *sp;
 	int c, i, j, di, rl, so, eo, nbs, n, dssize;
 	regmatch_t pmatch[10];
 	regex_t sreg, *re;
@@ -1865,7 +1870,7 @@
 	var *tv;
 	node *an[4];
 	var  *av[4];
-	char *as[4];
+	const char *as[4];
 	regmatch_t pmatch[2];
 	regex_t sreg, *re;
 	static tsplitter tspl;
@@ -1998,8 +2003,10 @@
 			tt = getvar_i(av[1]);
 		else
 			time(&tt);
-		s = (nargs > 0) ? as[0] : "%a %b %d %H:%M:%S %Z %Y";
-		i = strftime(buf, MAXVARFMT, s, localtime(&tt));
+		//s = (nargs > 0) ? as[0] : "%a %b %d %H:%M:%S %Z %Y";
+		i = strftime(buf, MAXVARFMT,
+			((nargs > 0) ? as[0] : "%a %b %d %H:%M:%S %Z %Y"),
+			localtime(&tt));
 		buf[i] = '\0';
 		setvar_s(res, buf);
 		break;
@@ -2054,7 +2061,7 @@
 	var *v1;
 	union {
 		var *v;
-		char *s;
+		const char *s;
 		double d;
 		int i;
 	} L, R;
@@ -2168,7 +2175,7 @@
 			} else {	/* OC_PRINTF */
 				L.s = awk_printf(op1);
 				fputs(L.s, X.F);
-				free(L.s);
+				free((char*)L.s);
 			}
 			fflush(X.F);
 			break;
@@ -2610,7 +2617,7 @@
 {
 	static rstream rsm;
 	FILE *F = NULL;
-	char *fname, *ind;
+	const char *fname, *ind;
 	static int files_happen = FALSE;
 
 	if (rsm.F) fclose(rsm.F);

Modified: trunk/busybox/editors/ed.c
===================================================================
--- trunk/busybox/editors/ed.c	2007-01-29 22:40:38 UTC (rev 17652)
+++ trunk/busybox/editors/ed.c	2007-01-29 22:51:00 UTC (rev 17653)
@@ -401,7 +401,7 @@
 	if (cp)
 		*cp++ = '\0';
 	else
-		cp = "";
+		cp = (char*)"";
 
 	while (*cp) switch (*cp++) {
 		case 'g':

Modified: trunk/busybox/include/libbb.h
===================================================================
--- trunk/busybox/include/libbb.h	2007-01-29 22:40:38 UTC (rev 17652)
+++ trunk/busybox/include/libbb.h	2007-01-29 22:51:00 UTC (rev 17653)
@@ -239,7 +239,7 @@
 	void* userData, int depth);
 extern int device_open(const char *device, int mode);
 extern int get_console_fd(void);
-extern char *find_block_device(char *path);
+extern char *find_block_device(const char *path);
 /* bb_copyfd_XX print read/write errors and return -1 if they occur */
 extern off_t bb_copyfd_eof(int fd1, int fd2);
 extern off_t bb_copyfd_size(int fd1, int fd2, off_t size);

Modified: trunk/busybox/libbb/find_root_device.c
===================================================================
--- trunk/busybox/libbb/find_root_device.c	2007-01-29 22:40:38 UTC (rev 17652)
+++ trunk/busybox/libbb/find_root_device.c	2007-01-29 22:51:00 UTC (rev 17653)
@@ -9,7 +9,7 @@
 
 #include "libbb.h"
 
-char *find_block_device(char *path)
+char *find_block_device(const char *path)
 {
 	DIR *dir;
 	struct dirent *entry;




More information about the busybox-cvs mailing list