aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRob Landley <rob@landley.net>2006-02-22 17:01:00 +0000
committerRob Landley <rob@landley.net>2006-02-22 17:01:00 +0000
commit0a7c8ef6e220b5f8fff4f2cb0af630255a2a6a58 (patch)
treef32eb89325299a3abade721ffe149b0e516747c1
parentfb16d5c6aa8aef30d313356b5a83ef0a60114c9a (diff)
downloadbusybox-w32-0a7c8ef6e220b5f8fff4f2cb0af630255a2a6a58.tar.gz
busybox-w32-0a7c8ef6e220b5f8fff4f2cb0af630255a2a6a58.tar.bz2
busybox-w32-0a7c8ef6e220b5f8fff4f2cb0af630255a2a6a58.zip
Patch from Denis Vlasenko to constify things and fix a few typos.
-rw-r--r--archival/dpkg.c7
-rw-r--r--archival/unzip.c2
-rw-r--r--coreutils/env.c3
-rw-r--r--coreutils/stat.c5
-rw-r--r--init/halt.c6
-rw-r--r--miscutils/devfsd.c69
-rw-r--r--miscutils/hdparm.c4
-rw-r--r--networking/libiproute/ipaddress.c23
-rw-r--r--networking/udhcp/packet.c7
9 files changed, 73 insertions, 53 deletions
diff --git a/archival/dpkg.c b/archival/dpkg.c
index 7ed17d711..70eaefb94 100644
--- a/archival/dpkg.c
+++ b/archival/dpkg.c
@@ -552,9 +552,12 @@ static void free_package(common_node_t *node)
552 552
553static unsigned int fill_package_struct(char *control_buffer) 553static unsigned int fill_package_struct(char *control_buffer)
554{ 554{
555 static const char *const field_names[] = { "Package", "Version",
556 "Pre-Depends", "Depends","Replaces", "Provides",
557 "Conflicts", "Suggests", "Recommends", "Enhances", 0
558 };
559
555 common_node_t *new_node = (common_node_t *) xcalloc(1, sizeof(common_node_t)); 560 common_node_t *new_node = (common_node_t *) xcalloc(1, sizeof(common_node_t));
556 const char *field_names[] = { "Package", "Version", "Pre-Depends", "Depends",
557 "Replaces", "Provides", "Conflicts", "Suggests", "Recommends", "Enhances", 0};
558 char *field_name; 561 char *field_name;
559 char *field_value; 562 char *field_value;
560 int field_start = 0; 563 int field_start = 0;
diff --git a/archival/unzip.c b/archival/unzip.c
index f602db12d..ff2b1a266 100644
--- a/archival/unzip.c
+++ b/archival/unzip.c
@@ -220,7 +220,7 @@ extern int unzip_main(int argc, char **argv)
220 overwrite = (overwrite == o_prompt) ? o_never : overwrite; 220 overwrite = (overwrite == o_prompt) ? o_never : overwrite;
221 221
222 } else { 222 } else {
223 char *extn[] = {"", ".zip", ".ZIP"}; 223 static const char *const extn[] = {"", ".zip", ".ZIP"};
224 int orig_src_fn_len = strlen(src_fn); 224 int orig_src_fn_len = strlen(src_fn);
225 for(i = 0; (i < 3) && (src_fd == -1); i++) { 225 for(i = 0; (i < 3) && (src_fd == -1); i++) {
226 strcpy(src_fn + orig_src_fn_len, extn[i]); 226 strcpy(src_fn + orig_src_fn_len, extn[i]);
diff --git a/coreutils/env.c b/coreutils/env.c
index d59e738f1..156f4e77d 100644
--- a/coreutils/env.c
+++ b/coreutils/env.c
@@ -59,8 +59,9 @@ static const struct option env_long_options[] = {
59 59
60extern int env_main(int argc, char** argv) 60extern int env_main(int argc, char** argv)
61{ 61{
62 static char *cleanenv[1] = { NULL };
63
62 char **ep, *p; 64 char **ep, *p;
63 char *cleanenv[1] = { NULL };
64 unsigned long opt; 65 unsigned long opt;
65 llist_t *unset_env = NULL; 66 llist_t *unset_env = NULL;
66 extern char **environ; 67 extern char **environ;
diff --git a/coreutils/stat.c b/coreutils/stat.c
index 44289fbaa..c845a2aa7 100644
--- a/coreutils/stat.c
+++ b/coreutils/stat.c
@@ -120,12 +120,11 @@ static char const *human_fstype(long f_type)
120 { 0x858458f6, "romfs" }, 120 { 0x858458f6, "romfs" },
121 { 0x73717368, "squashfs" }, 121 { 0x73717368, "squashfs" },
122 { 0x62656572, "sysfs" }, 122 { 0x62656572, "sysfs" },
123 { 0, "UNKNOWN" }, 123 { 0, "UNKNOWN" }
124 { 0, NULL }
125 }; 124 };
126 for (i=0; humantypes[i].type; ++i) 125 for (i=0; humantypes[i].type; ++i)
127 if (humantypes[i].type == f_type) 126 if (humantypes[i].type == f_type)
128 return humantypes[i].fs; 127 break;
129 return humantypes[i].fs; 128 return humantypes[i].fs;
130} 129}
131 130
diff --git a/init/halt.c b/init/halt.c
index 34479742e..38ca38222 100644
--- a/init/halt.c
+++ b/init/halt.c
@@ -15,9 +15,11 @@
15 15
16int halt_main(int argc, char *argv[]) 16int halt_main(int argc, char *argv[])
17{ 17{
18 static const int magic[] = {RB_HALT_SYSTEM, RB_POWER_OFF, RB_AUTOBOOT};
19 static const int signals[] = {SIGUSR1, SIGUSR2, SIGTERM};
20
18 char *delay = "hpr"; 21 char *delay = "hpr";
19 int which, flags, magic[] = {RB_HALT_SYSTEM, RB_POWER_OFF, RB_AUTOBOOT}, 22 int which, flags, rc = 1;
20 signals[] = {SIGUSR1, SIGUSR2, SIGTERM}, rc = 1;
21 23
22 /* Figure out which applet we're running */ 24 /* Figure out which applet we're running */
23 for(which=0;delay[which]!=*bb_applet_name;which++); 25 for(which=0;delay[which]!=*bb_applet_name;which++);
diff --git a/miscutils/devfsd.c b/miscutils/devfsd.c
index fd5f54763..f99a94628 100644
--- a/miscutils/devfsd.c
+++ b/miscutils/devfsd.c
@@ -606,17 +606,18 @@ static void process_config_line (const char *line, unsigned long *event_mask)
606 char name[STRING_LENGTH]; 606 char name[STRING_LENGTH];
607 char * msg=""; 607 char * msg="";
608 char *ptr; 608 char *ptr;
609 int i;
609 610
610 /* !!!! Only Uppercase Keywords in devsfd.conf */ 611 /* !!!! Only Uppercase Keywords in devsfd.conf */
611 const char *options[] = { "CLEAR_CONFIG", "INCLUDE", "OPTIONAL_INCLUDE", "RESTORE", 612 static const char *const options[] = {
612 "PERMISSIONS", "MODLOAD", "EXECUTE", "COPY", "IGNORE", 613 "CLEAR_CONFIG", "INCLUDE", "OPTIONAL_INCLUDE",
613 "MKOLDCOMPAT", "MKNEWCOMPAT","RMOLDCOMPAT", "RMNEWCOMPAT", 0 }; 614 "RESTORE", "PERMISSIONS", "MODLOAD", "EXECUTE",
614 615 "COPY", "IGNORE", "MKOLDCOMPAT", "MKNEWCOMPAT",
615 int i; 616 "RMOLDCOMPAT", "RMNEWCOMPAT", 0
617 };
616 618
617 debug_msg_logger(LOG_INFO, __FUNCTION__); 619 debug_msg_logger(LOG_INFO, __FUNCTION__);
618 620
619
620 for (count = 0; count < MAX_ARGS; ++count) p[count][0] = '\0'; 621 for (count = 0; count < MAX_ARGS; ++count) p[count][0] = '\0';
621 num_args = sscanf (line, "%s %s %s %s %s %s %s %s %s %s", 622 num_args = sscanf (line, "%s %s %s %s %s %s %s %s %s %s",
622 when, name, what, 623 when, name, what,
@@ -678,7 +679,7 @@ static void process_config_line (const char *line, unsigned long *event_mask)
678 if ( ( ptr = strchr (p[0], '.') ) == NULL ) 679 if ( ( ptr = strchr (p[0], '.') ) == NULL )
679 { 680 {
680 msg="UID.GID"; 681 msg="UID.GID";
681 goto process_config_line_err; /*"missing '.' in UID.GID */ 682 goto process_config_line_err; /*"missing '.' in UID.GID"*/
682 } 683 }
683 684
684 *ptr++ = '\0'; 685 *ptr++ = '\0';
@@ -993,17 +994,19 @@ static void action_compat (const struct devfsd_notify_struct *info, unsigned int
993 unsigned int i; 994 unsigned int i;
994 char rewind_; 995 char rewind_;
995 /* 1 to 5 "scsi/" , 6 to 9 "ide/host" */ 996 /* 1 to 5 "scsi/" , 6 to 9 "ide/host" */
996 const char *fmt[] = { NULL , 997 static const char *const fmt[] = {
997 "sg/c%db%dt%du%d", /* scsi/generic */ 998 NULL ,
998 "sd/c%db%dt%du%d", /* scsi/disc */ 999 "sg/c%db%dt%du%d", /* scsi/generic */
999 "sr/c%db%dt%du%d", /* scsi/cd */ 1000 "sd/c%db%dt%du%d", /* scsi/disc */
1000 "sd/c%db%dt%du%dp%d", /* scsi/part */ 1001 "sr/c%db%dt%du%d", /* scsi/cd */
1001 "st/c%db%dt%du%dm%d%c", /* scsi/mt */ 1002 "sd/c%db%dt%du%dp%d", /* scsi/part */
1002 "ide/hd/c%db%dt%du%d", /* ide/host/disc */ 1003 "st/c%db%dt%du%dm%d%c", /* scsi/mt */
1003 "ide/cd/c%db%dt%du%d", /* ide/host/cd */ 1004 "ide/hd/c%db%dt%du%d", /* ide/host/disc */
1004 "ide/hd/c%db%dt%du%dp%d", /* ide/host/part */ 1005 "ide/cd/c%db%dt%du%d", /* ide/host/cd */
1005 "ide/mt/c%db%dt%du%d%s", /* ide/host/mt */ 1006 "ide/hd/c%db%dt%du%dp%d", /* ide/host/part */
1006 NULL }; 1007 "ide/mt/c%db%dt%du%d%s", /* ide/host/mt */
1008 NULL
1009 };
1007 1010
1008 /* First construct compatibility name */ 1011 /* First construct compatibility name */
1009 switch (action) 1012 switch (action)
@@ -1596,20 +1599,22 @@ const char *get_old_name (const char *devname, unsigned int namelen,
1596 const char *pty2; 1599 const char *pty2;
1597 size_t len; 1600 size_t len;
1598 /* 1 to 5 "scsi/" , 6 to 9 "ide/host", 10 sbp/, 11 vcc/, 12 pty/ */ 1601 /* 1 to 5 "scsi/" , 6 to 9 "ide/host", 10 sbp/, 11 vcc/, 12 pty/ */
1599 const char *fmt[] = { NULL , 1602 static const char *const fmt[] = {
1600 "sg%u", /* scsi/generic */ 1603 NULL ,
1601 NULL, /* scsi/disc */ 1604 "sg%u", /* scsi/generic */
1602 "sr%u", /* scsi/cd */ 1605 NULL, /* scsi/disc */
1603 NULL, /* scsi/part */ 1606 "sr%u", /* scsi/cd */
1604 "nst%u%c", /* scsi/mt */ 1607 NULL, /* scsi/part */
1605 "hd%c" , /* ide/host/disc */ 1608 "nst%u%c", /* scsi/mt */
1606 "hd%c" , /* ide/host/cd */ 1609 "hd%c" , /* ide/host/disc */
1607 "hd%c%s", /* ide/host/part */ 1610 "hd%c" , /* ide/host/cd */
1608 "%sht%d", /* ide/host/mt */ 1611 "hd%c%s", /* ide/host/part */
1609 "sbpcd%u", /* sbp/ */ 1612 "%sht%d", /* ide/host/mt */
1610 "vcs%s", /* vcc/ */ 1613 "sbpcd%u", /* sbp/ */
1611 "%cty%c%c", /* pty/ */ 1614 "vcs%s", /* vcc/ */
1612 NULL }; 1615 "%cty%c%c", /* pty/ */
1616 NULL
1617 };
1613 1618
1614 debug_msg_logger(LOG_INFO, __FUNCTION__); 1619 debug_msg_logger(LOG_INFO, __FUNCTION__);
1615 1620
diff --git a/miscutils/hdparm.c b/miscutils/hdparm.c
index 750cb499b..e733c9172 100644
--- a/miscutils/hdparm.c
+++ b/miscutils/hdparm.c
@@ -1305,10 +1305,12 @@ static const char * const BuffType[] = {"unknown", "1Sect", "DualPort", "DualPor
1305static void dump_identity (const struct hd_driveid *id) 1305static void dump_identity (const struct hd_driveid *id)
1306{ 1306{
1307 int i; 1307 int i;
1308 char pmodes[64] = {0,}, dmodes[128]={0,}, umodes[128]={0,}; 1308 char pmodes[64], dmodes[128], umodes[128];
1309 const unsigned short int *id_regs= (const void*) id; 1309 const unsigned short int *id_regs= (const void*) id;
1310 unsigned long capacity; 1310 unsigned long capacity;
1311 1311
1312 pmodes[0] = dmodes[0] = umodes[0] = '\0';
1313
1312 printf("\n Model=%.40s, FwRev=%.8s, SerialNo=%.20s\n Config={", 1314 printf("\n Model=%.40s, FwRev=%.8s, SerialNo=%.20s\n Config={",
1313 id->model, id->fw_rev, id->serial_no); 1315 id->model, id->fw_rev, id->serial_no);
1314 for (i=0; i<=15; i++) 1316 for (i=0; i<=15; i++)
diff --git a/networking/libiproute/ipaddress.c b/networking/libiproute/ipaddress.c
index 9db79eacb..d7a0c5177 100644
--- a/networking/libiproute/ipaddress.c
+++ b/networking/libiproute/ipaddress.c
@@ -416,7 +416,8 @@ static void ipaddr_reset_filter(int _oneline)
416 416
417extern int ipaddr_list_or_flush(int argc, char **argv, int flush) 417extern int ipaddr_list_or_flush(int argc, char **argv, int flush)
418{ 418{
419 const char *option[] = { "to", "scope", "up", "label", "dev", 0 }; 419 static const char *const option[] = { "to", "scope", "up", "label", "dev", 0 };
420
420 struct nlmsg_list *linfo = NULL; 421 struct nlmsg_list *linfo = NULL;
421 struct nlmsg_list *ainfo = NULL; 422 struct nlmsg_list *ainfo = NULL;
422 struct nlmsg_list *l; 423 struct nlmsg_list *l;
@@ -499,7 +500,7 @@ extern int ipaddr_list_or_flush(int argc, char **argv, int flush)
499 if (filter_dev) { 500 if (filter_dev) {
500 filter.ifindex = ll_name_to_index(filter_dev); 501 filter.ifindex = ll_name_to_index(filter_dev);
501 if (filter.ifindex <= 0) { 502 if (filter.ifindex <= 0) {
502 bb_error_msg("Device \"%s\" does not exist.", filter_dev); 503 bb_error_msg("Device \"%s\" does not exist", filter_dev);
503 return -1; 504 return -1;
504 } 505 }
505 } 506 }
@@ -631,8 +632,11 @@ static int default_scope(inet_prefix *lcl)
631 632
632static int ipaddr_modify(int cmd, int argc, char **argv) 633static int ipaddr_modify(int cmd, int argc, char **argv)
633{ 634{
634 const char *option[] = { "peer", "remote", "broadcast", "brd", 635 static const char *const option[] = {
635 "anycast", "scope", "dev", "label", "local", 0 }; 636 "peer", "remote", "broadcast", "brd",
637 "anycast", "scope", "dev", "label", "local", 0
638 };
639
636 struct rtnl_handle rth; 640 struct rtnl_handle rth;
637 struct { 641 struct {
638 struct nlmsghdr n; 642 struct nlmsghdr n;
@@ -716,7 +720,7 @@ static int ipaddr_modify(int cmd, int argc, char **argv)
716 uint32_t scope = 0; 720 uint32_t scope = 0;
717 NEXT_ARG(); 721 NEXT_ARG();
718 if (rtnl_rtscope_a2n(&scope, *argv)) { 722 if (rtnl_rtscope_a2n(&scope, *argv)) {
719 invarg(*argv, "invalid scope value."); 723 invarg(*argv, "invalid scope value");
720 } 724 }
721 req.ifa.ifa_scope = scope; 725 req.ifa.ifa_scope = scope;
722 scoped = 1; 726 scoped = 1;
@@ -749,11 +753,11 @@ static int ipaddr_modify(int cmd, int argc, char **argv)
749 } 753 }
750 754
751 if (d == NULL) { 755 if (d == NULL) {
752 bb_error_msg("Not enough information: \"dev\" argument is required."); 756 bb_error_msg("Not enough information: \"dev\" argument is required");
753 return -1; 757 return -1;
754 } 758 }
755 if (l && matches(d, l) != 0) { 759 if (l && matches(d, l) != 0) {
756 bb_error_msg_and_die("\"dev\" (%s) must match \"label\" (%s).", d, l); 760 bb_error_msg_and_die("\"dev\" (%s) must match \"label\" (%s)", d, l);
757 } 761 }
758 762
759 if (peer_len == 0 && local_len && cmd != RTM_DELADDR) { 763 if (peer_len == 0 && local_len && cmd != RTM_DELADDR) {
@@ -803,7 +807,10 @@ static int ipaddr_modify(int cmd, int argc, char **argv)
803 807
804extern int do_ipaddr(int argc, char **argv) 808extern int do_ipaddr(int argc, char **argv)
805{ 809{
806 const char *commands[] = { "add", "delete", "list", "show", "lst", "flush", 0 }; 810 static const char *const commands[] = {
811 "add", "delete", "list", "show", "lst", "flush", 0
812 };
813
807 int command_num = 2; 814 int command_num = 2;
808 815
809 if (*argv) { 816 if (*argv) {
diff --git a/networking/udhcp/packet.c b/networking/udhcp/packet.c
index 222dd24e0..fe74b828f 100644
--- a/networking/udhcp/packet.c
+++ b/networking/udhcp/packet.c
@@ -46,12 +46,13 @@ void init_header(struct dhcpMessage *packet, char type)
46/* read a packet from socket fd, return -1 on read error, -2 on packet error */ 46/* read a packet from socket fd, return -1 on read error, -2 on packet error */
47int get_packet(struct dhcpMessage *packet, int fd) 47int get_packet(struct dhcpMessage *packet, int fd)
48{ 48{
49 int bytes; 49 static const char broken_vendors[][8] = {
50 int i;
51 const char broken_vendors[][8] = {
52 "MSFT 98", 50 "MSFT 98",
53 "" 51 ""
54 }; 52 };
53
54 int bytes;
55 int i;
55 char unsigned *vendor; 56 char unsigned *vendor;
56 57
57 memset(packet, 0, sizeof(struct dhcpMessage)); 58 memset(packet, 0, sizeof(struct dhcpMessage));