svn commit: trunk/busybox/procps

vda at busybox.net vda at busybox.net
Wed Oct 15 08:29:18 UTC 2008


Author: vda
Date: 2008-10-15 01:29:17 -0700 (Wed, 15 Oct 2008)
New Revision: 23680

Log:
sysctl: remove special-cased reporting of EPERM,
 common code path gives nearly the same message. -50 bytes



Modified:
   trunk/busybox/procps/sysctl.c


Changeset:
Modified: trunk/busybox/procps/sysctl.c
===================================================================
--- trunk/busybox/procps/sysctl.c	2008-10-15 08:22:55 UTC (rev 23679)
+++ trunk/busybox/procps/sysctl.c	2008-10-15 08:29:17 UTC (rev 23680)
@@ -1,4 +1,3 @@
-/* vi: set sw=4 ts=4: */
 /*
  * Sysctl 1.01 - A utility to read and manipulate the sysctl parameters
  *
@@ -26,23 +25,9 @@
 static const char PROC_SYS[] ALIGN1 = "/proc/sys/";
 enum { strlen_PROC_SYS = sizeof(PROC_SYS) - 1 };
 
-/* error messages */
-static const char ERR_MALFORMED_SETTING[] ALIGN1 =
-	"error: malformed setting '%s'";
-static const char ERR_NO_EQUALS[] ALIGN1 =
-	"error: '%s' must be of the form name=value";
-static const char ERR_INVALID_KEY[] ALIGN1 =
+static const char msg_unknown_key[] ALIGN1 =
 	"error: '%s' is an unknown key";
-static const char ERR_UNKNOWN_WRITING[] ALIGN1 =
-	"error setting key '%s'";
-static const char ERR_UNKNOWN_READING[] ALIGN1 =
-	"error reading key '%s'";
-static const char ERR_PERMISSION_DENIED[] ALIGN1 =
-	"error: permission denied on key '%s'";
-static const char WARN_BAD_LINE[] ALIGN1 =
-	"warning: %s(%d): invalid syntax, continuing";
 
-
 static void dwrite_str(int fd, const char *buf)
 {
 	write(fd, buf, strlen(buf));
@@ -98,7 +83,8 @@
 	parser = config_open(filename);
 	while (config_read(parser, token, 2, 2, "# \t=", PARSE_NORMAL)) { // TODO: ';' is comment char too
 //		if (!token[1]) {
-//			bb_error_msg(WARN_BAD_LINE, filename, parser->lineno);
+//			bb_error_msg("warning: %s(%d): invalid syntax, continuing",
+//					filename, parser->lineno);
 //		} else {
 		{
 #if 0
@@ -131,13 +117,13 @@
 	name = setting;
 	equals = strchr(setting, '=');
 	if (!equals) {
-		bb_error_msg(ERR_NO_EQUALS, setting);
+		bb_error_msg("error: '%s' must be of the form name=value", setting);
 		return EXIT_FAILURE;
 	}
 
 	value = equals + 1;	/* point to the value in name=value */
 	if (name == equals || !*value) {
-		bb_error_msg(ERR_MALFORMED_SETTING, setting);
+		bb_error_msg("error: malformed setting '%s'", setting);
 		return EXIT_FAILURE;
 	}
 
@@ -154,13 +140,10 @@
 		switch (errno) {
 		case ENOENT:
 			if (option_mask32 & FLAG_SHOW_KEY_ERRORS)
-				bb_error_msg(ERR_INVALID_KEY, outname);
+				bb_error_msg(msg_unknown_key, outname);
 			break;
-		case EACCES:
-			bb_perror_msg(ERR_PERMISSION_DENIED, outname);
-			break;
 		default:
-			bb_perror_msg(ERR_UNKNOWN_WRITING, outname);
+			bb_perror_msg("error setting key '%s'", outname);
 			break;
 		}
 		retval = EXIT_FAILURE;
@@ -191,7 +174,7 @@
 
 	if (!*name) {
 		if (option_mask32 & FLAG_SHOW_KEY_ERRORS)
-			bb_error_msg(ERR_INVALID_KEY, name);
+			bb_error_msg(msg_unknown_key, name);
 		return -1;
 	}
 
@@ -208,13 +191,10 @@
 		switch (errno) {
 		case ENOENT:
 			if (option_mask32 & FLAG_SHOW_KEY_ERRORS)
-				bb_error_msg(ERR_INVALID_KEY, outname);
+				bb_error_msg(msg_unknown_key, outname);
 			break;
-		case EACCES:
-			bb_error_msg(ERR_PERMISSION_DENIED, outname);
-			break;
 		default:
-			bb_perror_msg(ERR_UNKNOWN_READING, outname);
+			bb_perror_msg("error reading key '%s'", outname);
 			break;
 		}
 		retval = EXIT_FAILURE;




More information about the busybox-cvs mailing list