svn commit: trunk/busybox: archival coreutils init miscutils networ etc...

landley at busybox.net landley at busybox.net
Wed Feb 22 17:01:04 UTC 2006


Author: landley
Date: 2006-02-22 09:01:00 -0800 (Wed, 22 Feb 2006)
New Revision: 14210

Log:
Patch from Denis Vlasenko to constify things and fix a few typos.


Modified:
   trunk/busybox/archival/dpkg.c
   trunk/busybox/archival/unzip.c
   trunk/busybox/coreutils/env.c
   trunk/busybox/coreutils/stat.c
   trunk/busybox/init/halt.c
   trunk/busybox/miscutils/devfsd.c
   trunk/busybox/miscutils/hdparm.c
   trunk/busybox/networking/libiproute/ipaddress.c
   trunk/busybox/networking/udhcp/packet.c


Changeset:
Modified: trunk/busybox/archival/dpkg.c
===================================================================
--- trunk/busybox/archival/dpkg.c	2006-02-22 15:40:38 UTC (rev 14209)
+++ trunk/busybox/archival/dpkg.c	2006-02-22 17:01:00 UTC (rev 14210)
@@ -552,9 +552,12 @@
 
 static unsigned int fill_package_struct(char *control_buffer)
 {
+	static const char *const field_names[] = { "Package", "Version",
+		"Pre-Depends", "Depends","Replaces", "Provides",
+		"Conflicts", "Suggests", "Recommends", "Enhances", 0
+	};
+
 	common_node_t *new_node = (common_node_t *) xcalloc(1, sizeof(common_node_t));
-	const char *field_names[] = { "Package", "Version", "Pre-Depends", "Depends",
-		"Replaces", "Provides", "Conflicts", "Suggests", "Recommends", "Enhances", 0};
 	char *field_name;
 	char *field_value;
 	int field_start = 0;

Modified: trunk/busybox/archival/unzip.c
===================================================================
--- trunk/busybox/archival/unzip.c	2006-02-22 15:40:38 UTC (rev 14209)
+++ trunk/busybox/archival/unzip.c	2006-02-22 17:01:00 UTC (rev 14210)
@@ -220,7 +220,7 @@
 		overwrite = (overwrite == o_prompt) ? o_never : overwrite;
 
 	} else {
-		char *extn[] = {"", ".zip", ".ZIP"};
+		static const char *const extn[] = {"", ".zip", ".ZIP"};
 		int orig_src_fn_len = strlen(src_fn);
 		for(i = 0; (i < 3) && (src_fd == -1); i++) {
 			strcpy(src_fn + orig_src_fn_len, extn[i]);

Modified: trunk/busybox/coreutils/env.c
===================================================================
--- trunk/busybox/coreutils/env.c	2006-02-22 15:40:38 UTC (rev 14209)
+++ trunk/busybox/coreutils/env.c	2006-02-22 17:01:00 UTC (rev 14210)
@@ -59,8 +59,9 @@
 
 extern int env_main(int argc, char** argv)
 {
+	static char *cleanenv[1] = { NULL };
+
 	char **ep, *p;
-	char *cleanenv[1] = { NULL };
 	unsigned long opt;
 	llist_t *unset_env = NULL;
 	extern char **environ;

Modified: trunk/busybox/coreutils/stat.c
===================================================================
--- trunk/busybox/coreutils/stat.c	2006-02-22 15:40:38 UTC (rev 14209)
+++ trunk/busybox/coreutils/stat.c	2006-02-22 17:01:00 UTC (rev 14210)
@@ -120,12 +120,11 @@
 		{ 0x858458f6, "romfs" },
 		{ 0x73717368, "squashfs" },
 		{ 0x62656572, "sysfs" },
-		{ 0, "UNKNOWN" },
-		{ 0, NULL }
+		{ 0, "UNKNOWN" }
 	};
 	for (i=0; humantypes[i].type; ++i)
 		if (humantypes[i].type == f_type)
-			return humantypes[i].fs;
+			break;
 	return humantypes[i].fs;
 }
 

Modified: trunk/busybox/init/halt.c
===================================================================
--- trunk/busybox/init/halt.c	2006-02-22 15:40:38 UTC (rev 14209)
+++ trunk/busybox/init/halt.c	2006-02-22 17:01:00 UTC (rev 14210)
@@ -15,9 +15,11 @@
 
 int halt_main(int argc, char *argv[])
 {
+	static const int magic[] = {RB_HALT_SYSTEM, RB_POWER_OFF, RB_AUTOBOOT};
+	static const int signals[] = {SIGUSR1, SIGUSR2, SIGTERM};
+
 	char *delay = "hpr";
-	int which, flags, magic[] = {RB_HALT_SYSTEM, RB_POWER_OFF, RB_AUTOBOOT},
-		signals[] = {SIGUSR1, SIGUSR2, SIGTERM}, rc = 1;
+	int which, flags, rc = 1;
 
 	/* Figure out which applet we're running */
 	for(which=0;delay[which]!=*bb_applet_name;which++);

Modified: trunk/busybox/miscutils/devfsd.c
===================================================================
--- trunk/busybox/miscutils/devfsd.c	2006-02-22 15:40:38 UTC (rev 14209)
+++ trunk/busybox/miscutils/devfsd.c	2006-02-22 17:01:00 UTC (rev 14210)
@@ -606,17 +606,18 @@
 	char name[STRING_LENGTH];
 	char * msg="";
 	char *ptr;
+	int i;
 
 	/* !!!! Only Uppercase Keywords in devsfd.conf */
-	const char *options[] = {	"CLEAR_CONFIG", "INCLUDE", "OPTIONAL_INCLUDE", "RESTORE",
-								"PERMISSIONS", "MODLOAD", "EXECUTE", "COPY", "IGNORE",
-								"MKOLDCOMPAT", "MKNEWCOMPAT","RMOLDCOMPAT", "RMNEWCOMPAT", 0 };
+	static const char *const options[] = {
+		"CLEAR_CONFIG", "INCLUDE", "OPTIONAL_INCLUDE",
+		"RESTORE", "PERMISSIONS", "MODLOAD", "EXECUTE",
+		"COPY", "IGNORE", "MKOLDCOMPAT", "MKNEWCOMPAT",
+		"RMOLDCOMPAT", "RMNEWCOMPAT", 0
+	};
 
-	int i;
-
 	debug_msg_logger(LOG_INFO, __FUNCTION__);
 
-
 	for (count = 0; count < MAX_ARGS; ++count) p[count][0] = '\0';
 	num_args = sscanf (line, "%s %s %s %s %s %s %s %s %s %s",
 			when, name, what,
@@ -678,7 +679,7 @@
 			if ( ( ptr = strchr (p[0], '.') ) == NULL )
 			{
 				msg="UID.GID";
-				goto process_config_line_err; /*"missing '.' in UID.GID */
+				goto process_config_line_err; /*"missing '.' in UID.GID"*/
 			}
 
 			*ptr++ = '\0';
@@ -993,17 +994,19 @@
 	unsigned int i;
 	char rewind_;
 	/* 1 to 5  "scsi/" , 6 to 9 "ide/host" */
-	const char *fmt[] = {	NULL ,
-							"sg/c%db%dt%du%d",			/* scsi/generic */
-							"sd/c%db%dt%du%d",			/* scsi/disc */
-							"sr/c%db%dt%du%d",			/* scsi/cd */
-							"sd/c%db%dt%du%dp%d",		/* scsi/part */
-							"st/c%db%dt%du%dm%d%c",		/* scsi/mt */
-							"ide/hd/c%db%dt%du%d",		/* ide/host/disc */
-							"ide/cd/c%db%dt%du%d",		/* ide/host/cd */
-							"ide/hd/c%db%dt%du%dp%d",	/* ide/host/part */
-							"ide/mt/c%db%dt%du%d%s",	/* ide/host/mt */
-							NULL };
+	static const char *const fmt[] = {
+		NULL ,
+		"sg/c%db%dt%du%d",		/* scsi/generic */
+		"sd/c%db%dt%du%d",		/* scsi/disc */
+		"sr/c%db%dt%du%d",		/* scsi/cd */
+		"sd/c%db%dt%du%dp%d",		/* scsi/part */
+		"st/c%db%dt%du%dm%d%c",		/* scsi/mt */
+		"ide/hd/c%db%dt%du%d",		/* ide/host/disc */
+		"ide/cd/c%db%dt%du%d",		/* ide/host/cd */
+		"ide/hd/c%db%dt%du%dp%d",	/* ide/host/part */
+		"ide/mt/c%db%dt%du%d%s",	/* ide/host/mt */
+		NULL
+	};
 
 	/*  First construct compatibility name  */
 	switch (action)
@@ -1596,20 +1599,22 @@
 	const char *pty2;
 	size_t len;
 	/* 1 to 5  "scsi/" , 6 to 9 "ide/host", 10 sbp/, 11 vcc/, 12 pty/ */
-	const char *fmt[] = {	NULL ,
-							"sg%u",			/* scsi/generic */
-							NULL,			/* scsi/disc */
-							"sr%u",			/* scsi/cd */
-							NULL,			/* scsi/part */
-							"nst%u%c",		/* scsi/mt */
-							"hd%c"	,		/* ide/host/disc */
-							"hd%c"	,		/* ide/host/cd */
-							"hd%c%s",		/* ide/host/part */
-							"%sht%d",		/* ide/host/mt */
-							"sbpcd%u",		/* sbp/ */
-							"vcs%s",		/* vcc/ */
-							"%cty%c%c",		/* pty/ */
-							NULL };
+	static const char *const fmt[] = {
+		NULL ,
+		"sg%u",			/* scsi/generic */
+		NULL,			/* scsi/disc */
+		"sr%u",			/* scsi/cd */
+		NULL,			/* scsi/part */
+		"nst%u%c",		/* scsi/mt */
+		"hd%c"	,		/* ide/host/disc */
+		"hd%c"	,		/* ide/host/cd */
+		"hd%c%s",		/* ide/host/part */
+		"%sht%d",		/* ide/host/mt */
+		"sbpcd%u",		/* sbp/ */
+		"vcs%s",		/* vcc/ */
+		"%cty%c%c",		/* pty/ */
+		NULL
+	};
 
 	debug_msg_logger(LOG_INFO, __FUNCTION__);
 

Modified: trunk/busybox/miscutils/hdparm.c
===================================================================
--- trunk/busybox/miscutils/hdparm.c	2006-02-22 15:40:38 UTC (rev 14209)
+++ trunk/busybox/miscutils/hdparm.c	2006-02-22 17:01:00 UTC (rev 14210)
@@ -1305,10 +1305,12 @@
 static void dump_identity (const struct hd_driveid *id)
 {
 	int i;
-	char pmodes[64] = {0,}, dmodes[128]={0,}, umodes[128]={0,};
+	char pmodes[64], dmodes[128], umodes[128];
 	const unsigned short int *id_regs= (const void*) id;
 	unsigned long capacity;
 
+	pmodes[0] = dmodes[0] = umodes[0] = '\0';
+
 	printf("\n Model=%.40s, FwRev=%.8s, SerialNo=%.20s\n Config={",
 				id->model, id->fw_rev, id->serial_no);
 	for (i=0; i<=15; i++)

Modified: trunk/busybox/networking/libiproute/ipaddress.c
===================================================================
--- trunk/busybox/networking/libiproute/ipaddress.c	2006-02-22 15:40:38 UTC (rev 14209)
+++ trunk/busybox/networking/libiproute/ipaddress.c	2006-02-22 17:01:00 UTC (rev 14210)
@@ -416,7 +416,8 @@
 
 extern int ipaddr_list_or_flush(int argc, char **argv, int flush)
 {
-	const char *option[] = { "to", "scope", "up", "label", "dev", 0 };
+	static const char *const option[] = { "to", "scope", "up", "label", "dev", 0 };
+
 	struct nlmsg_list *linfo = NULL;
 	struct nlmsg_list *ainfo = NULL;
 	struct nlmsg_list *l;
@@ -499,7 +500,7 @@
 	if (filter_dev) {
 		filter.ifindex = ll_name_to_index(filter_dev);
 		if (filter.ifindex <= 0) {
-			bb_error_msg("Device \"%s\" does not exist.", filter_dev);
+			bb_error_msg("Device \"%s\" does not exist", filter_dev);
 			return -1;
 		}
 	}
@@ -631,8 +632,11 @@
 
 static int ipaddr_modify(int cmd, int argc, char **argv)
 {
-	const char *option[] = { "peer", "remote", "broadcast", "brd",
-		"anycast", "scope", "dev", "label", "local", 0 };
+	static const char *const option[] = {
+		"peer", "remote", "broadcast", "brd",
+		"anycast", "scope", "dev", "label", "local", 0
+	};
+
 	struct rtnl_handle rth;
 	struct {
 		struct nlmsghdr		n;
@@ -716,7 +720,7 @@
 				uint32_t scope = 0;
 				NEXT_ARG();
 				if (rtnl_rtscope_a2n(&scope, *argv)) {
-					invarg(*argv, "invalid scope value.");
+					invarg(*argv, "invalid scope value");
 				}
 				req.ifa.ifa_scope = scope;
 				scoped = 1;
@@ -749,11 +753,11 @@
 	}
 
 	if (d == NULL) {
-		bb_error_msg("Not enough information: \"dev\" argument is required.");
+		bb_error_msg("Not enough information: \"dev\" argument is required");
 		return -1;
 	}
 	if (l && matches(d, l) != 0) {
-		bb_error_msg_and_die("\"dev\" (%s) must match \"label\" (%s).", d, l);
+		bb_error_msg_and_die("\"dev\" (%s) must match \"label\" (%s)", d, l);
 	}
 
 	if (peer_len == 0 && local_len && cmd != RTM_DELADDR) {
@@ -803,7 +807,10 @@
 
 extern int do_ipaddr(int argc, char **argv)
 {
-	const char *commands[] = { "add", "delete", "list", "show", "lst", "flush", 0 };
+	static const char *const commands[] = {
+		"add", "delete", "list", "show", "lst", "flush", 0
+	};
+
 	int command_num = 2;
 
 	if (*argv) {

Modified: trunk/busybox/networking/udhcp/packet.c
===================================================================
--- trunk/busybox/networking/udhcp/packet.c	2006-02-22 15:40:38 UTC (rev 14209)
+++ trunk/busybox/networking/udhcp/packet.c	2006-02-22 17:01:00 UTC (rev 14210)
@@ -46,12 +46,13 @@
 /* read a packet from socket fd, return -1 on read error, -2 on packet error */
 int get_packet(struct dhcpMessage *packet, int fd)
 {
-	int bytes;
-	int i;
-	const char broken_vendors[][8] = {
+	static const char broken_vendors[][8] = {
 		"MSFT 98",
 		""
 	};
+
+	int bytes;
+	int i;
 	char unsigned *vendor;
 
 	memset(packet, 0, sizeof(struct dhcpMessage));




More information about the busybox-cvs mailing list