Patch from Denis Vlasenko to constify things and fix a few typos.
authorRob Landley <rob@landley.net>
Wed, 22 Feb 2006 17:01:00 +0000 (17:01 -0000)
committerRob Landley <rob@landley.net>
Wed, 22 Feb 2006 17:01:00 +0000 (17:01 -0000)
archival/dpkg.c
archival/unzip.c
coreutils/env.c
coreutils/stat.c
init/halt.c
miscutils/devfsd.c
miscutils/hdparm.c
networking/libiproute/ipaddress.c
networking/udhcp/packet.c

index 7ed17d711268dec22d90cd800dea89fd54b9d6a6..70eaefb9404b3781f20865cbca637e3d7f4cd4e4 100644 (file)
@@ -552,9 +552,12 @@ static void free_package(common_node_t *node)
 
 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;
index f602db12d2983115e5752fb41d00eda8c68a30f9..ff2b1a26637ee95b9181adaf5bef1bece25375f4 100644 (file)
@@ -220,7 +220,7 @@ extern int unzip_main(int argc, char **argv)
                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]);
index d59e738f127b0e6c52e004b9f3251c734a9fb361..156f4e77d757ec88105a450ba33451bd96578c91 100644 (file)
@@ -59,8 +59,9 @@ static const struct option env_long_options[] = {
 
 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;
index 44289fbaa070c2fd40b72cc1334da1ac5cb6597f..c845a2aa7e7ac953c2e4cace4e27a7d0776466d9 100644 (file)
@@ -120,12 +120,11 @@ static char const *human_fstype(long f_type)
                { 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;
 }
 
index 34479742e507edcde4e5ec356412970ee74ad9ce..38ca38222570aba64bd5dd440571b3b492ddd99f 100644 (file)
 
 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++);
index fd5f54763e7bfe55d746aebb32cb978b6a7c2e93..f99a9462892b7f8188d4c269d295d4b36bf2c116 100644 (file)
@@ -606,17 +606,18 @@ static void process_config_line (const char *line, unsigned long *event_mask)
        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 };
-
-       int i;
+       static const char *const options[] = {
+               "CLEAR_CONFIG", "INCLUDE", "OPTIONAL_INCLUDE",
+               "RESTORE", "PERMISSIONS", "MODLOAD", "EXECUTE",
+               "COPY", "IGNORE", "MKOLDCOMPAT", "MKNEWCOMPAT",
+               "RMOLDCOMPAT", "RMNEWCOMPAT", 0
+       };
 
        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 @@ static void process_config_line (const char *line, unsigned long *event_mask)
                        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 @@ static void action_compat (const struct devfsd_notify_struct *info, unsigned int
        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 *get_old_name (const char *devname, unsigned int namelen,
        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__);
 
index 750cb499bd3ae29f2dad256e70d22d713fae8a0a..e733c91723e04fdfcffc0fffe4f6070049f417af 100644 (file)
@@ -1305,10 +1305,12 @@ static const char * const BuffType[]    = {"unknown", "1Sect", "DualPort", "DualPor
 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++)
index 9db79eacb83be5c484a1ef49ad103112c3eb0821..d7a0c517797cc609ac8266045e9aabff1aac2415 100644 (file)
@@ -416,7 +416,8 @@ static void ipaddr_reset_filter(int _oneline)
 
 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 @@ extern int ipaddr_list_or_flush(int argc, char **argv, int flush)
        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 default_scope(inet_prefix *lcl)
 
 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 @@ static int ipaddr_modify(int cmd, int argc, char **argv)
                                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 @@ static int ipaddr_modify(int cmd, int argc, char **argv)
        }
 
        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 @@ static int ipaddr_modify(int cmd, int argc, char **argv)
 
 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) {
index 222dd24e02a53263aa8f1c11c89dec4696c083ea..fe74b828f30c5d635830599642f84b99aa60da0d 100644 (file)
@@ -46,12 +46,13 @@ void init_header(struct dhcpMessage *packet, char type)
 /* 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));