I applied bigger part of it. Thanks. See 6.patch.

7.patch is a part which is not applied, as it is slower.

On Sunday 30 September 2007 19:53, Loïc Grenié wrote:
>     While I'm at it: bb_verror_msg is written in such a way that msg can have
>   an embedded NUL char. Is it important ? Otherwise the function can be
>   simplified (using strcat or vasprintf instead of moving pointers around).

strcat and vasprintf are slower than msg[i++] = 'c' and strcpy.

No need to kill yourself for the last byte or two.

> PS: with my local gcc, whenever bb_simple_perror_msg is declared in
> networking/libiproute/iproute.c, the function do_iproute takes 40 bytes
> more. I've removed from the patch the kludge that I've used here but
> I don't know whether this is a general problem.

It's a gcc problem.

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=29950
--
vda
diff -d -urpN busybox.5/applets/applets.c busybox.6/applets/applets.c
--- busybox.5/applets/applets.c	2007-09-29 23:39:20.000000000 +0100
+++ busybox.6/applets/applets.c	2007-10-01 12:42:29.000000000 +0100
@@ -526,7 +526,7 @@ static void install_links(const char *bu
 				applets[i].name);
 		rc = lf(busybox, fpc);
 		if (rc != 0 && errno != EEXIST) {
-			bb_perror_msg("%s", fpc);
+			bb_simple_perror_msg(fpc);
 		}
 		free(fpc);
 	}
diff -d -urpN busybox.5/archival/bbunzip.c busybox.6/archival/bbunzip.c
--- busybox.5/archival/bbunzip.c	2007-09-29 23:38:02.000000000 +0100
+++ busybox.6/archival/bbunzip.c	2007-10-01 12:42:29.000000000 +0100
@@ -49,7 +49,7 @@ int bbunpack(char **argv,
 		/* Open src */
 		if (filename) {
 			if (stat(filename, &stat_buf) != 0) {
-				bb_perror_msg("%s", filename);
+				bb_simple_perror_msg(filename);
  err:
 				exitcode = 1;
 				goto free_name;
diff -d -urpN busybox.5/coreutils/chmod.c busybox.6/coreutils/chmod.c
--- busybox.5/coreutils/chmod.c	2007-09-29 23:38:26.000000000 +0100
+++ busybox.6/coreutils/chmod.c	2007-10-01 12:42:29.000000000 +0100
@@ -63,7 +63,7 @@ static int fileAction(const char *fileNa
 	}
  err:
 	if (!OPT_QUIET)
-		bb_perror_msg("%s", fileName);
+		bb_simple_perror_msg(fileName);
 	return FALSE;
 }
 
diff -d -urpN busybox.5/coreutils/chown.c busybox.6/coreutils/chown.c
--- busybox.5/coreutils/chown.c	2007-09-29 23:38:26.000000000 +0100
+++ busybox.6/coreutils/chown.c	2007-10-01 12:42:29.000000000 +0100
@@ -57,7 +57,7 @@ static int fileAction(const char *fileNa
 		return TRUE;
 	}
 	if (!OPT_QUIET)
-		bb_perror_msg("%s", fileName);	/* A filename can have % in it... */
+		bb_simple_perror_msg(fileName);	/* A filename can have % in it... */
 	return FALSE;
 }
 
diff -d -urpN busybox.5/coreutils/dd.c busybox.6/coreutils/dd.c
--- busybox.5/coreutils/dd.c	2007-09-29 23:38:26.000000000 +0100
+++ busybox.6/coreutils/dd.c	2007-10-01 12:42:29.000000000 +0100
@@ -278,7 +278,7 @@ int dd_main(int argc, char **argv)
 		if (n < 0) {
 			if (flags & FLAG_NOERROR) {
 				n = ibs;
-				bb_perror_msg("%s", infile);
+				bb_simple_perror_msg(infile);
 			} else
 				goto die_infile;
 		}
@@ -320,12 +320,12 @@ int dd_main(int argc, char **argv)
 	}
 	if (close(ifd) < 0) {
  die_infile:
-		bb_perror_msg_and_die("%s", infile);
+		bb_simple_perror_msg_and_die(infile);
 	}
 
 	if (close(ofd) < 0) {
  die_outfile:
-		bb_perror_msg_and_die("%s", outfile);
+		bb_simple_perror_msg_and_die(outfile);
 	}
  out_status:
 	dd_output_status(0);
diff -d -urpN busybox.5/coreutils/df.c busybox.6/coreutils/df.c
--- busybox.5/coreutils/df.c	2007-09-29 23:38:26.000000000 +0100
+++ busybox.6/coreutils/df.c	2007-10-01 12:42:29.000000000 +0100
@@ -100,7 +100,7 @@ int df_main(int argc, char **argv)
 		mount_point = mount_entry->mnt_dir;
 
 		if (statfs(mount_point, &s) != 0) {
-			bb_perror_msg("%s", mount_point);
+			bb_simple_perror_msg(mount_point);
 			goto SET_ERROR;
 		}
 
diff -d -urpN busybox.5/coreutils/du.c busybox.6/coreutils/du.c
--- busybox.5/coreutils/du.c	2007-09-29 23:38:26.000000000 +0100
+++ busybox.6/coreutils/du.c	2007-10-01 12:42:29.000000000 +0100
@@ -67,7 +67,7 @@ static unsigned long du(const char *file
 	unsigned long sum;
 
 	if (lstat(filename, &statbuf) != 0) {
-		bb_perror_msg("%s", filename);
+		bb_simple_perror_msg(filename);
 		G.status = EXIT_FAILURE;
 		return 0;
 	}
@@ -85,7 +85,7 @@ static unsigned long du(const char *file
 	if (S_ISLNK(statbuf.st_mode)) {
 		if (G.slink_depth > G.du_depth) {	/* -H or -L */
 			if (stat(filename, &statbuf) != 0) {
-				bb_perror_msg("%s", filename);
+				bb_simple_perror_msg(filename);
 				G.status = EXIT_FAILURE;
 				return 0;
 			}
diff -d -urpN busybox.5/coreutils/env.c busybox.6/coreutils/env.c
--- busybox.5/coreutils/env.c	2007-09-29 23:38:26.000000000 +0100
+++ busybox.6/coreutils/env.c	2007-10-01 12:42:29.000000000 +0100
@@ -81,7 +81,7 @@ int env_main(int argc, char** argv)
 		BB_EXECVP(*argv, argv);
 		/* SUSv3-mandated exit codes. */
 		xfunc_error_retval = (errno == ENOENT) ? 127 : 126;
-		bb_perror_msg_and_die("%s", *argv);
+		bb_simple_perror_msg_and_die(*argv);
 	}
 
 	for (ep = environ; *ep; ep++) {
diff -d -urpN busybox.5/coreutils/expand.c busybox.6/coreutils/expand.c
--- busybox.5/coreutils/expand.c	2007-09-29 23:38:26.000000000 +0100
+++ busybox.6/coreutils/expand.c	2007-10-01 12:42:29.000000000 +0100
@@ -192,7 +192,7 @@ int expand_main(int argc, char **argv)
 		/* Check and close the file */
 		/* We do want all of them to execute, thus | instead of || */
 		if (ferror(file) | fclose_if_not_stdin(file)) {
-			bb_perror_msg("%s", *argv);
+			bb_simple_perror_msg(*argv);
 			exit_status = EXIT_FAILURE;
 		}
 		/* If stdin also clear EOF */
diff -d -urpN busybox.5/coreutils/fold.c busybox.6/coreutils/fold.c
--- busybox.5/coreutils/fold.c	2007-09-29 23:38:26.000000000 +0100
+++ busybox.6/coreutils/fold.c	2007-10-01 12:42:29.000000000 +0100
@@ -145,7 +145,7 @@ int fold_main(int argc, char **argv)
 		}
 
 		if (ferror(istream) || fclose_if_not_stdin(istream)) {
-			bb_perror_msg("%s", *argv);	/* Avoid multibyte problems. */
+			bb_simple_perror_msg(*argv);	/* Avoid multibyte problems. */
 			errs |= EXIT_FAILURE;
 		}
 	} while (*++argv);
diff -d -urpN busybox.5/coreutils/head.c busybox.6/coreutils/head.c
--- busybox.5/coreutils/head.c	2007-09-29 23:38:26.000000000 +0100
+++ busybox.6/coreutils/head.c	2007-10-01 12:42:29.000000000 +0100
@@ -128,7 +128,7 @@ int head_main(int argc, char **argv)
 				putchar(c);
 			}
 			if (fclose_if_not_stdin(fp)) {
-				bb_perror_msg("%s", *argv);	/* Avoid multibyte problems. */
+				bb_simple_perror_msg(*argv);	/* Avoid multibyte problems. */
 				retval = EXIT_FAILURE;
 			}
 			die_if_ferror_stdout();
diff -d -urpN busybox.5/coreutils/ln.c busybox.6/coreutils/ln.c
--- busybox.5/coreutils/ln.c	2007-09-29 23:38:26.000000000 +0100
+++ busybox.6/coreutils/ln.c	2007-10-01 12:42:29.000000000 +0100
@@ -64,7 +64,7 @@ int ln_main(int argc, char **argv)
 		if (!(flag & LN_SYMLINK) && stat(*argv, &statbuf)) {
 			// coreutils: "ln dangling_symlink new_hardlink" works
 			if (lstat(*argv, &statbuf) || !S_ISLNK(statbuf.st_mode)) {
-				bb_perror_msg("%s", *argv);
+				bb_simple_perror_msg(*argv);
 				status = EXIT_FAILURE;
 				free(src_name);
 				continue;
@@ -75,7 +75,7 @@ int ln_main(int argc, char **argv)
 			char *backup;
 			backup = xasprintf("%s%s", src, suffix);
 			if (rename(src, backup) < 0 && errno != ENOENT) {
-				bb_perror_msg("%s", src);
+				bb_simple_perror_msg(src);
 				status = EXIT_FAILURE;
 				free(backup);
 				continue;
@@ -97,7 +97,7 @@ int ln_main(int argc, char **argv)
 		}
 
 		if (link_func(*argv, src) != 0) {
-			bb_perror_msg("%s", src);
+			bb_simple_perror_msg(src);
 			status = EXIT_FAILURE;
 		}
 
diff -d -urpN busybox.5/coreutils/ls.c busybox.6/coreutils/ls.c
--- busybox.5/coreutils/ls.c	2007-09-29 23:38:26.000000000 +0100
+++ busybox.6/coreutils/ls.c	2007-10-01 12:42:29.000000000 +0100
@@ -171,7 +171,7 @@ static struct dnode *my_stat(const char 
 		}
 #endif
 		if (stat(fullname, &dstat)) {
-			bb_perror_msg("%s", fullname);
+			bb_simple_perror_msg(fullname);
 			status = EXIT_FAILURE;
 			return 0;
 		}
@@ -182,7 +182,7 @@ static struct dnode *my_stat(const char 
 		}
 #endif
 		if (lstat(fullname, &dstat)) {
-			bb_perror_msg("%s", fullname);
+			bb_simple_perror_msg(fullname);
 			status = EXIT_FAILURE;
 			return 0;
 		}
diff -d -urpN busybox.5/coreutils/mkfifo.c busybox.6/coreutils/mkfifo.c
--- busybox.5/coreutils/mkfifo.c	2007-09-29 23:38:26.000000000 +0100
+++ busybox.6/coreutils/mkfifo.c	2007-10-01 12:42:29.000000000 +0100
@@ -28,7 +28,7 @@ int mkfifo_main(int argc, char **argv)
 
 	do {
 		if (mkfifo(*argv, mode) < 0) {
-			bb_perror_msg("%s", *argv);	/* Avoid multibyte problems. */
+			bb_simple_perror_msg(*argv);	/* Avoid multibyte problems. */
 			retval = EXIT_FAILURE;
 		}
 	} while (*++argv);
diff -d -urpN busybox.5/coreutils/mknod.c busybox.6/coreutils/mknod.c
--- busybox.5/coreutils/mknod.c	2007-09-29 23:38:26.000000000 +0100
+++ busybox.6/coreutils/mknod.c	2007-10-01 12:42:29.000000000 +0100
@@ -44,7 +44,7 @@ int mknod_main(int argc, char **argv)
 			if (mknod(name, mode, dev) == 0) {
 				return EXIT_SUCCESS;
 			}
-			bb_perror_msg_and_die("%s", name);
+			bb_simple_perror_msg_and_die(name);
 		}
 	}
 	bb_show_usage();
diff -d -urpN busybox.5/coreutils/nice.c busybox.6/coreutils/nice.c
--- busybox.5/coreutils/nice.c	2007-09-29 23:38:26.000000000 +0100
+++ busybox.6/coreutils/nice.c	2007-10-01 12:42:29.000000000 +0100
@@ -51,5 +51,5 @@ int nice_main(int argc, char **argv)
 
 	/* The exec failed... */
 	xfunc_error_retval = (errno == ENOENT) ? 127 : 126; /* SUSv3 */
-	bb_perror_msg_and_die("%s", *argv);
+	bb_simple_perror_msg_and_die(*argv);
 }
diff -d -urpN busybox.5/coreutils/nohup.c busybox.6/coreutils/nohup.c
--- busybox.5/coreutils/nohup.c	2007-09-29 23:38:26.000000000 +0100
+++ busybox.6/coreutils/nohup.c	2007-10-01 12:42:29.000000000 +0100
@@ -56,5 +56,5 @@ int nohup_main(int argc, char **argv)
 	BB_EXECVP(argv[1], argv+1);
 	if (ENABLE_FEATURE_CLEAN_UP && home)
 		free((char*)nohupout);
-	bb_perror_msg_and_die("%s", argv[1]);
+	bb_simple_perror_msg_and_die(argv[1]);
 }
diff -d -urpN busybox.5/coreutils/realpath.c busybox.6/coreutils/realpath.c
--- busybox.5/coreutils/realpath.c	2007-09-29 23:38:26.000000000 +0100
+++ busybox.6/coreutils/realpath.c	2007-10-01 12:42:29.000000000 +0100
@@ -35,7 +35,7 @@ int realpath_main(int argc, char **argv)
 			puts(resolved_path);
 		} else {
 			retval = EXIT_FAILURE;
-			bb_perror_msg("%s", *argv);
+			bb_simple_perror_msg(*argv);
 		}
 	} while (--argc);
 
diff -d -urpN busybox.5/coreutils/split.c busybox.6/coreutils/split.c
--- busybox.5/coreutils/split.c	2007-09-29 23:38:26.000000000 +0100
+++ busybox.6/coreutils/split.c	2007-10-01 12:42:29.000000000 +0100
@@ -104,7 +104,7 @@ int split_main(int argc, char **argv)
 		if (!bytes_read)
 			break;
 		if (bytes_read < 0)
-			bb_perror_msg_and_die("%s", argv[0]);
+			bb_simple_perror_msg_and_die(argv[0]);
 		src = read_buffer;
 		do {
 			if (!remaining) {
diff -d -urpN busybox.5/coreutils/touch.c busybox.6/coreutils/touch.c
--- busybox.5/coreutils/touch.c	2007-09-29 23:38:26.000000000 +0100
+++ busybox.6/coreutils/touch.c	2007-10-01 12:42:29.000000000 +0100
@@ -49,7 +49,7 @@ int touch_main(int argc, char **argv)
 				}
 			}
 			status = EXIT_FAILURE;
-			bb_perror_msg("%s", *argv);
+			bb_simple_perror_msg(*argv);
 		}
 	} while (*++argv);
 
diff -d -urpN busybox.5/coreutils/wc.c busybox.6/coreutils/wc.c
--- busybox.5/coreutils/wc.c	2007-09-29 23:38:26.000000000 +0100
+++ busybox.6/coreutils/wc.c	2007-10-01 12:42:29.000000000 +0100
@@ -150,7 +150,7 @@ int wc_main(int argc, char **argv)
 				}
 			} else if (c == EOF) {
 				if (ferror(fp)) {
-					bb_perror_msg("%s", arg);
+					bb_simple_perror_msg(arg);
 					status = EXIT_FAILURE;
 				}
 				--counts[WC_CHARS];
diff -d -urpN busybox.5/e2fsprogs/fsck.c busybox.6/e2fsprogs/fsck.c
--- busybox.5/e2fsprogs/fsck.c	2007-09-29 23:38:53.000000000 +0100
+++ busybox.6/e2fsprogs/fsck.c	2007-10-01 12:42:29.000000000 +0100
@@ -659,7 +659,7 @@ static void execute(const char *type, co
 	if (!noexecute) {
 		pid = spawn(argv);
 		if (pid < 0)
-			bb_perror_msg("%s", argv[0]);
+			bb_simple_perror_msg(argv[0]);
 	}
 
 	for (i = num_args+1; i < argc; i++)
diff -d -urpN busybox.5/e2fsprogs/old_e2fsprogs/fsck.c busybox.6/e2fsprogs/old_e2fsprogs/fsck.c
--- busybox.5/e2fsprogs/old_e2fsprogs/fsck.c	2007-09-29 23:38:53.000000000 +0100
+++ busybox.6/e2fsprogs/old_e2fsprogs/fsck.c	2007-10-01 12:42:29.000000000 +0100
@@ -626,7 +626,7 @@ static int execute(const char *type, con
 		if (!interactive)
 			close(0);
 		(void) execv(s, argv);
-		bb_perror_msg_and_die("%s", argv[0]);
+		bb_simple_perror_msg_and_die(argv[0]);
 	}
 
 	for (i = 1; i < argc; i++)
diff -d -urpN busybox.5/findutils/find.c busybox.6/findutils/find.c
--- busybox.5/findutils/find.c	2007-09-29 23:39:12.000000000 +0100
+++ busybox.6/findutils/find.c	2007-10-01 12:42:29.000000000 +0100
@@ -277,7 +277,7 @@ ACTF(exec)
 
 	rc = spawn_and_wait(argv);
 	if (rc < 0)
-		bb_perror_msg("%s", argv[0]);
+		bb_simple_perror_msg(argv[0]);
 
 	i = 0;
 	while (argv[i])
@@ -347,7 +347,7 @@ ACTF(delete)
 		rc = unlink(fileName);
 	}
 	if (rc < 0)
-		bb_perror_msg("%s", fileName);
+		bb_simple_perror_msg(fileName);
 	return TRUE;
 }
 #endif
@@ -780,7 +780,7 @@ static action*** parse_params(char **arg
 			ap->context = NULL;
 			/* SELinux headers erroneously declare non-const parameter */
 			if (selinux_raw_to_trans_context((char*)arg1, &ap->context))
-				bb_perror_msg("%s", arg1);
+				bb_simple_perror_msg(arg1);
 		}
 #endif
 		else {
diff -d -urpN busybox.5/findutils/grep.c busybox.6/findutils/grep.c
--- busybox.5/findutils/grep.c	2007-09-29 23:39:12.000000000 +0100
+++ busybox.6/findutils/grep.c	2007-10-01 12:42:29.000000000 +0100
@@ -369,7 +369,7 @@ static int file_action_grep(const char *
 	FILE *file = fopen(filename, "r");
 	if (file == NULL) {
 		if (!SUPPRESS_ERR_MSGS)
-			bb_perror_msg("%s", cur_file);
+			bb_simple_perror_msg(cur_file);
 		open_errors = 1;
 		return 0;
 	}
@@ -517,7 +517,7 @@ int grep_main(int argc, char **argv)
 			file = fopen(cur_file, "r");
 			if (file == NULL) {
 				if (!SUPPRESS_ERR_MSGS)
-					bb_perror_msg("%s", cur_file);
+					bb_simple_perror_msg(cur_file);
 				open_errors = 1;
 				continue;
 			}
diff -d -urpN busybox.5/findutils/xargs.c busybox.6/findutils/xargs.c
--- busybox.5/findutils/xargs.c	2007-09-29 23:39:12.000000000 +0100
+++ busybox.6/findutils/xargs.c	2007-10-01 12:42:29.000000000 +0100
@@ -57,7 +57,7 @@ static int xargs_exec(char **args)
 
 	status = spawn_and_wait(args);
 	if (status < 0) {
-		bb_perror_msg("%s", args[0]);
+		bb_simple_perror_msg(args[0]);
 		return errno == ENOENT ? 127 : 126;
 	}
 	if (status == 255) {
diff -d -urpN busybox.5/include/libbb.h busybox.6/include/libbb.h
--- busybox.5/include/libbb.h	2007-09-30 19:32:31.000000000 +0100
+++ busybox.6/include/libbb.h	2007-10-01 12:42:29.000000000 +0100
@@ -677,7 +677,9 @@ extern void bb_show_usage(void) ATTRIBUT
 extern void bb_error_msg(const char *s, ...) __attribute__ ((format (printf, 1, 2)));
 extern void bb_error_msg_and_die(const char *s, ...) __attribute__ ((noreturn, format (printf, 1, 2)));
 extern void bb_perror_msg(const char *s, ...) __attribute__ ((format (printf, 1, 2)));
+extern void bb_simple_perror_msg(const char *s);
 extern void bb_perror_msg_and_die(const char *s, ...) __attribute__ ((noreturn, format (printf, 1, 2)));
+extern void bb_simple_perror_msg_and_die(const char *s) __attribute__ ((noreturn));
 extern void bb_herror_msg(const char *s, ...) __attribute__ ((format (printf, 1, 2)));
 extern void bb_herror_msg_and_die(const char *s, ...) __attribute__ ((noreturn, format (printf, 1, 2)));
 extern void bb_perror_nomsg_and_die(void) ATTRIBUTE_NORETURN;
@@ -1185,7 +1187,6 @@ extern const char bb_default_login_shell
 #include <dmalloc.h>
 #endif
 
-
 #define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
 
 #endif /* __LIBBUSYBOX_H__ */
diff -d -urpN busybox.5/init/mesg.c busybox.6/init/mesg.c
--- busybox.5/init/mesg.c	2007-09-29 23:39:15.000000000 +0100
+++ busybox.6/init/mesg.c	2007-10-01 12:42:29.000000000 +0100
@@ -40,7 +40,7 @@ int mesg_main(int argc, char **argv)
 				return EXIT_SUCCESS;
 			}
 		}
-		bb_perror_msg_and_die("%s", tty);
+		bb_simple_perror_msg_and_die(tty);
 	}
 	bb_show_usage();
 }
diff -d -urpN busybox.5/libbb/change_identity.c busybox.6/libbb/change_identity.c
--- busybox.5/libbb/change_identity.c	2007-09-29 23:38:37.000000000 +0100
+++ busybox.6/libbb/change_identity.c	2007-10-01 12:42:29.000000000 +0100
@@ -47,5 +47,5 @@ void change_identity(const struct passwd
 	const char *err_msg = change_identity_e2str(pw);
 
 	if (err_msg)
-		bb_perror_msg_and_die("%s", err_msg);
+		bb_simple_perror_msg_and_die(err_msg);
 }
diff -d -urpN busybox.5/libbb/dump.c busybox.6/libbb/dump.c
--- busybox.5/libbb/dump.c	2007-09-29 23:38:37.000000000 +0100
+++ busybox.6/libbb/dump.c	2007-10-01 12:42:29.000000000 +0100
@@ -297,7 +297,7 @@ static void do_skip(const char *fname, i
 
 	if (statok) {
 		if (fstat(STDIN_FILENO, &sbuf)) {
-			bb_perror_msg_and_die("%s", fname);
+			bb_simple_perror_msg_and_die(fname);
 		}
 		if ((!(S_ISCHR(sbuf.st_mode) ||
 			   S_ISBLK(sbuf.st_mode) ||
@@ -309,7 +309,7 @@ static void do_skip(const char *fname, i
 		}
 	}
 	if (fseek(stdin, bb_dump_skip, SEEK_SET)) {
-		bb_perror_msg_and_die("%s", fname);
+		bb_simple_perror_msg_and_die(fname);
 	}
 	savaddress = address += bb_dump_skip;
 	bb_dump_skip = 0;
@@ -328,7 +328,7 @@ static int next(char **argv)
 	for (;;) {
 		if (*_argv) {
 			if (!(freopen(*_argv, "r", stdin))) {
-				bb_perror_msg("%s", *_argv);
+				bb_simple_perror_msg(*_argv);
 				exitval = 1;
 				++_argv;
 				continue;
@@ -393,7 +393,7 @@ static unsigned char *get(void)
 				  bb_dump_length == -1 ? need : MIN(bb_dump_length, need), stdin);
 		if (!n) {
 			if (ferror(stdin)) {
-				bb_perror_msg("%s", _argv[-1]);
+				bb_simple_perror_msg(_argv[-1]);
 			}
 			ateof = 1;
 			continue;
diff -d -urpN busybox.5/libbb/perror_msg.c busybox.6/libbb/perror_msg.c
--- busybox.5/libbb/perror_msg.c	2007-09-29 23:38:37.000000000 +0100
+++ busybox.6/libbb/perror_msg.c	2007-10-01 12:42:29.000000000 +0100
@@ -18,3 +18,8 @@ void bb_perror_msg(const char *s, ...)
 	bb_verror_msg(s, p, errno ? strerror(errno) : NULL);
 	va_end(p);
 }
+
+void bb_simple_perror_msg(const char *s)
+{
+	bb_perror_msg("%s", s);
+}
diff -d -urpN busybox.5/libbb/perror_msg_and_die.c busybox.6/libbb/perror_msg_and_die.c
--- busybox.5/libbb/perror_msg_and_die.c	2007-09-29 23:38:37.000000000 +0100
+++ busybox.6/libbb/perror_msg_and_die.c	2007-10-01 12:42:29.000000000 +0100
@@ -19,3 +19,8 @@ void bb_perror_msg_and_die(const char *s
 	va_end(p);
 	xfunc_die();
 }
+
+void bb_simple_perror_msg_and_die(const char *s)
+{
+	bb_perror_msg_and_die("%s", s);
+}
diff -d -urpN busybox.5/libbb/recursive_action.c busybox.6/libbb/recursive_action.c
--- busybox.5/libbb/recursive_action.c	2007-09-29 23:38:37.000000000 +0100
+++ busybox.6/libbb/recursive_action.c	2007-10-01 12:42:29.000000000 +0100
@@ -120,6 +120,6 @@ int recursive_action(const char *fileNam
 	return TRUE;
 
  done_nak_warn:
-	bb_perror_msg("%s", fileName);
+	bb_simple_perror_msg(fileName);
 	return FALSE;
 }
diff -d -urpN busybox.5/libbb/vfork_daemon_rexec.c busybox.6/libbb/vfork_daemon_rexec.c
--- busybox.5/libbb/vfork_daemon_rexec.c	2007-09-29 23:38:37.000000000 +0100
+++ busybox.6/libbb/vfork_daemon_rexec.c	2007-10-01 12:42:29.000000000 +0100
@@ -62,7 +62,7 @@ pid_t xspawn(char **argv)
 {
 	pid_t pid = spawn(argv);
 	if (pid < 0)
-		bb_perror_msg_and_die("%s", *argv);
+		bb_simple_perror_msg_and_die(*argv);
 	return pid;
 }
 
diff -d -urpN busybox.5/libbb/wfopen.c busybox.6/libbb/wfopen.c
--- busybox.5/libbb/wfopen.c	2007-09-29 23:38:37.000000000 +0100
+++ busybox.6/libbb/wfopen.c	2007-10-01 12:42:29.000000000 +0100
@@ -13,7 +13,7 @@ FILE *fopen_or_warn(const char *path, co
 {
 	FILE *fp = fopen(path, mode);
 	if (!fp) {
-		bb_perror_msg("%s", path);
+		bb_simple_perror_msg(path);
 		errno = 0;
 	}
 	return fp;
diff -d -urpN busybox.5/libbb/xfuncs.c busybox.6/libbb/xfuncs.c
--- busybox.5/libbb/xfuncs.c	2007-09-30 19:32:40.000000000 +0100
+++ busybox.6/libbb/xfuncs.c	2007-10-01 12:42:29.000000000 +0100
@@ -704,13 +704,13 @@ int bb_ioctl_or_warn(int fd, int request
 
 	ret = ioctl(fd, request, argp);
 	if (ret < 0)
-		bb_perror_msg("%s", ioctl_name);
+		bb_simple_perror_msg(ioctl_name);
 	return ret;
 }
 void bb_xioctl(int fd, int request, void *argp, const char *ioctl_name)
 {
 	if (ioctl(fd, request, argp) < 0)
-		bb_perror_msg_and_die("%s", ioctl_name);
+		bb_simple_perror_msg_and_die(ioctl_name);
 }
 #else
 int bb_ioctl_or_warn(int fd, int request, void *argp)
diff -d -urpN busybox.5/loginutils/adduser.c busybox.6/loginutils/adduser.c
--- busybox.5/loginutils/adduser.c	2007-09-29 23:39:07.000000000 +0100
+++ busybox.6/loginutils/adduser.c	2007-10-01 12:42:29.000000000 +0100
@@ -144,7 +144,7 @@ static int adduser(struct passwd *p)
 		if (mkdir(p->pw_dir, 0755)
 		|| chown(p->pw_dir, p->pw_uid, p->pw_gid)
 		|| chmod(p->pw_dir, 02755)) {
-			bb_perror_msg("%s", p->pw_dir);
+			bb_simple_perror_msg(p->pw_dir);
 		}
 	}
 
diff -d -urpN busybox.5/miscutils/chrt.c busybox.6/miscutils/chrt.c
--- busybox.5/miscutils/chrt.c	2007-09-29 23:38:59.000000000 +0100
+++ busybox.6/miscutils/chrt.c	2007-10-01 12:42:29.000000000 +0100
@@ -115,7 +115,7 @@ print_rt_info:
 	}
 	++argv;
 	BB_EXECVP(*argv, argv);
-	bb_perror_msg_and_die("%s", *argv);
+	bb_simple_perror_msg_and_die(*argv);
 }
 #undef OPT_p
 #undef OPT_r
diff -d -urpN busybox.5/miscutils/mountpoint.c busybox.6/miscutils/mountpoint.c
--- busybox.5/miscutils/mountpoint.c	2007-09-29 23:38:59.000000000 +0100
+++ busybox.6/miscutils/mountpoint.c	2007-10-01 12:42:29.000000000 +0100
@@ -61,6 +61,6 @@ int mountpoint_main(int argc, char **arg
 		}
 	}
 	if (!(opt & OPT_q))
-		bb_perror_msg("%s", arg);
+		bb_simple_perror_msg(arg);
 	return EXIT_FAILURE;
 }
diff -d -urpN busybox.5/miscutils/setsid.c busybox.6/miscutils/setsid.c
--- busybox.5/miscutils/setsid.c	2007-09-29 23:38:59.000000000 +0100
+++ busybox.6/miscutils/setsid.c	2007-10-01 12:42:29.000000000 +0100
@@ -29,5 +29,5 @@ int setsid_main(int argc, char **argv)
 	setsid();  /* no error possible */
 
 	BB_EXECVP(argv[1], argv + 1);
-	bb_perror_msg_and_die("%s", argv[1]);
+	bb_simple_perror_msg_and_die(argv[1]);
 }
diff -d -urpN busybox.5/miscutils/taskset.c busybox.6/miscutils/taskset.c
--- busybox.5/miscutils/taskset.c	2007-09-29 23:38:59.000000000 +0100
+++ busybox.6/miscutils/taskset.c	2007-10-01 12:42:29.000000000 +0100
@@ -92,7 +92,7 @@ int taskset_main(int argc, char** argv)
 	}
 	++argv;
 	BB_EXECVP(*argv, argv);
-	bb_perror_msg_and_die("%s", *argv);
+	bb_simple_perror_msg_and_die(*argv);
 }
 #undef OPT_p
 #undef TASKSET_PRINTF_MASK
diff -d -urpN busybox.5/modutils/rmmod.c busybox.6/modutils/rmmod.c
--- busybox.5/modutils/rmmod.c	2007-09-29 23:38:04.000000000 +0100
+++ busybox.6/modutils/rmmod.c	2007-10-01 12:42:29.000000000 +0100
@@ -85,7 +85,7 @@ int rmmod_main(int argc, char **argv)
 		}
 
 		if (syscall(__NR_delete_module, ENABLE_FEATURE_2_6_MODULES ? misc_buf : argv[n], flags)) {
-			bb_perror_msg("%s", argv[n]);
+			bb_simple_perror_msg(argv[n]);
 			ret = EXIT_FAILURE;
 		}
 	}
diff -d -urpN busybox.5/networking/httpd.c busybox.6/networking/httpd.c
--- busybox.5/networking/httpd.c	2007-09-29 23:37:40.000000000 +0100
+++ busybox.6/networking/httpd.c	2007-10-01 12:42:29.000000000 +0100
@@ -504,7 +504,7 @@ static void parse_conf(const char *path,
 			return;
 		}
 		if (configFile && flag == FIRST_PARSE) /* if -c option given */
-			bb_perror_msg_and_die("%s", cf);
+			bb_simple_perror_msg_and_die(cf);
 		flag = FIND_FROM_HTTPD_ROOT;
 		cf = httpd_conf;
 	}
diff -d -urpN busybox.5/networking/inetd.c busybox.6/networking/inetd.c
--- busybox.5/networking/inetd.c	2007-09-29 23:37:40.000000000 +0100
+++ busybox.6/networking/inetd.c	2007-10-01 12:42:29.000000000 +0100
@@ -983,7 +983,7 @@ static void config(int sig ATTRIBUTE_UNU
 	char protoname[10];
 
 	if (!setconfig()) {
-		bb_perror_msg("%s", config_filename);
+		bb_simple_perror_msg(config_filename);
 		return;
 	}
 	for (sep = servtab; sep; sep = sep->se_next)
diff -d -urpN busybox.5/networking/netstat.c busybox.6/networking/netstat.c
--- busybox.5/networking/netstat.c	2007-09-29 23:37:40.000000000 +0100
+++ busybox.6/networking/netstat.c	2007-10-01 12:42:29.000000000 +0100
@@ -464,7 +464,7 @@ static void do_info(const char *file, co
 	procinfo = fopen(file, "r");
 	if (procinfo == NULL) {
 		if (errno != ENOENT) {
-			bb_perror_msg("%s", file);
+			bb_simple_perror_msg(file);
 		} else {
 			bb_error_msg("no support for '%s' on this system", name);
 		}
diff -d -urpN busybox.5/selinux/setfiles.c busybox.6/selinux/setfiles.c
--- busybox.5/selinux/setfiles.c	2007-09-29 23:39:06.000000000 +0100
+++ busybox.6/selinux/setfiles.c	2007-10-01 12:42:29.000000000 +0100
@@ -595,7 +595,7 @@ int setfiles_main(int argc, char **argv)
 		if (argc == 1)
 			bb_show_usage();
 		if (stat(argv[optind], &sb) < 0) {
-			bb_perror_msg_and_die("%s", argv[optind]);
+			bb_simple_perror_msg_and_die(argv[optind]);
 		}
 		if (!S_ISREG(sb.st_mode)) {
 			bb_error_msg_and_die("spec file %s is not a regular file", argv[optind]);
@@ -603,7 +603,7 @@ int setfiles_main(int argc, char **argv)
 		/* Load the file contexts configuration and check it. */
 		rc = matchpathcon_init(argv[optind]);
 		if (rc < 0) {
-			bb_perror_msg_and_die("%s", argv[optind]);
+			bb_simple_perror_msg_and_die(argv[optind]);
 		}
 
 		optind++;
diff -d -urpN busybox.5/shell/lash.c busybox.6/shell/lash.c
--- busybox.5/shell/lash.c	2007-09-30 19:32:48.000000000 +0100
+++ busybox.6/shell/lash.c	2007-10-01 12:42:29.000000000 +0100
@@ -1159,7 +1159,7 @@ static int pseudo_exec(struct child_prog
 
 	/* Do not use bb_perror_msg_and_die() here, since we must not
 	 * call exit() but should call _exit() instead */
-	bb_perror_msg("%s", child->argv[0]);
+	bb_simple_perror_msg(child->argv[0]);
 	_exit(EXIT_FAILURE);
 }
 
diff -d -urpN busybox.5/util-linux/mount.c busybox.6/util-linux/mount.c
--- busybox.5/util-linux/mount.c	2007-09-29 23:39:28.000000000 +0100
+++ busybox.6/util-linux/mount.c	2007-10-01 12:42:29.000000000 +0100
@@ -1655,7 +1655,7 @@ int mount_main(int argc, char **argv)
 	 && (i & (MS_SHARED | MS_PRIVATE | MS_SLAVE | MS_UNBINDABLE))
 	) {
 		rc = mount("", argv[0], "", i, "");
-		if (rc) bb_perror_msg_and_die("%s", argv[0]);
+		if (rc) bb_simple_perror_msg_and_die(argv[0]);
 		goto clean_up;
 	}
 
diff -d -urpN busybox.5/util-linux/setarch.c busybox.6/util-linux/setarch.c
--- busybox.5/util-linux/setarch.c	2007-09-29 23:39:28.000000000 +0100
+++ busybox.6/util-linux/setarch.c	2007-10-01 12:42:29.000000000 +0100
@@ -44,5 +44,5 @@ retry:
 		BB_EXECVP(argv[0], argv);
 	}
 
-	bb_perror_msg_and_die("%s", argv[0]);
+	bb_simple_perror_msg_and_die(argv[0]);
 }
diff -d -urpN busybox.5/util-linux/swaponoff.c busybox.6/util-linux/swaponoff.c
--- busybox.5/util-linux/swaponoff.c	2007-09-29 23:39:28.000000000 +0100
+++ busybox.6/util-linux/swaponoff.c	2007-10-01 12:42:29.000000000 +0100
@@ -31,7 +31,7 @@ static int swap_enable_disable(char *dev
 		status = swapoff(device);
 
 	if (status != 0) {
-		bb_perror_msg("%s", device);
+		bb_simple_perror_msg(device);
 		return 1;
 	}
 
diff -d -urpN busybox.6/libbb/verror_msg.c busybox.7/libbb/verror_msg.c
--- busybox.6/libbb/verror_msg.c	2007-09-29 23:38:37.000000000 +0100
+++ busybox.7/libbb/verror_msg.c	2007-10-01 12:43:46.000000000 +0100
@@ -15,8 +15,8 @@ const char *msg_eol = "\n";
 
 void bb_verror_msg(const char *s, va_list p, const char* strerr)
 {
-	char *msg;
-	int applet_len, strerr_len, msgeol_len, used;
+	char *msg, *msgend;
+	int applet_len, append_len, used;
 
 	if (!logmode)
 		return;
@@ -34,27 +34,26 @@ void bb_verror_msg(const char *s, va_lis
 	 * children can produce log messages simultaneously. */
 
 	applet_len = strlen(applet_name) + 2; /* "applet: " */
-	strerr_len = strerr ? strlen(strerr) : 0;
-	msgeol_len = strlen(msg_eol);
-	/* +3 is for ": " before strerr and for terminating NUL */
-	msg = xrealloc(msg, applet_len + used + strerr_len + msgeol_len + 3);
+	append_len = (strerr ? strlen(strerr) + 2 : 0) + strlen(msg_eol);
+	/* +1 is for terminating NUL */
+	msg = xrealloc(msg, applet_len + used + append_len + 1);
 	/* TODO: maybe use writev instead of memmoving? Need full_writev? */
 	memmove(msg + applet_len, msg, used);
 	used += applet_len;
 	strcpy(msg, applet_name);
 	msg[applet_len - 2] = ':';
 	msg[applet_len - 1] = ' ';
+	msgend = &msg[used];
 	if (strerr) {
-		msg[used++] = ':';
-		msg[used++] = ' ';
-		strcpy(&msg[used], strerr);
-		used += strerr_len;
+		strcat(msgend, ": ");
+		strcat(msgend, strerr);
 	}
-	strcpy(&msg[used], msg_eol);
+	strcat(msgend, msg_eol);
 
 	if (logmode & LOGMODE_STDIO) {
+		/* stdout or stderr (or both) ? */
 		fflush(stdout);
-		full_write(2, msg, used + msgeol_len);
+		full_write(2, msg, used + append_len);
 	}
 	if (logmode & LOGMODE_SYSLOG) {
 		syslog(LOG_ERR, "%s", msg + applet_len);
_______________________________________________
busybox mailing list
[email protected]
http://busybox.net/cgi-bin/mailman/listinfo/busybox

Reply via email to