fix assorted unused code and wrong format specs found by cppchekc (bug 6716)
authorDenys Vlasenko <vda.linux@googlemail.com>
Fri, 29 Nov 2013 15:43:33 +0000 (16:43 +0100)
committerDenys Vlasenko <vda.linux@googlemail.com>
Fri, 29 Nov 2013 15:43:33 +0000 (16:43 +0100)
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
20 files changed:
archival/libarchive/bz/compress.c
archival/libarchive/decompress_bunzip2.c
archival/libarchive/decompress_gunzip.c
archival/libarchive/lzo1x_9x.c
e2fsprogs/old_e2fsprogs/blkid/blkidP.h
e2fsprogs/old_e2fsprogs/blkid/cache.c
e2fsprogs/old_e2fsprogs/blkid/dev.c
e2fsprogs/old_e2fsprogs/blkid/read.c
e2fsprogs/old_e2fsprogs/blkid/tag.c
e2fsprogs/old_e2fsprogs/e2fsck.c
e2fsprogs/old_e2fsprogs/ext2fs/initialize.c
e2fsprogs/old_e2fsprogs/ext2fs/unix_io.c
e2fsprogs/old_e2fsprogs/fsck.c
e2fsprogs/old_e2fsprogs/mke2fs.c
e2fsprogs/old_e2fsprogs/util.c
libbb/pw_encrypt_md5.c
miscutils/chat.c
networking/tc.c
networking/traceroute.c
util-linux/volume_id/unused_msdos.c

index a7dd72d9eaa598c5e1ab446b492a17e7978b16cb..23de9d3f58cc6819ae4fbb19c79cead882f86662 100644 (file)
@@ -249,7 +249,7 @@ void generateMTFValues(EState* s)
 static NOINLINE
 void sendMTFValues(EState* s)
 {
-       int32_t v, t, i, j, gs, ge, totc, bt, bc, iter;
+       int32_t v, t, i, j, gs, ge, bt, bc, iter;
        int32_t nSelectors, alphaSize, minLen, maxLen, selCtr;
        int32_t nGroups;
 
@@ -345,7 +345,6 @@ void sendMTFValues(EState* s)
                }
 #endif
                nSelectors = 0;
-               totc = 0;
                gs = 0;
                while (1) {
                        /*--- Set group start & end marks. --*/
@@ -411,7 +410,6 @@ void sendMTFValues(EState* s)
                                        bt = t;
                                }
                        }
-                       totc += bc;
                        fave[bt]++;
                        s->selector[nSelectors] = bt;
                        nSelectors++;
index fb1f2921f90517ffe3ab61ddfa7ec8b618a1d096..6396fe40d186a1a67f3df46c4858ac6558a570e4 100644 (file)
@@ -818,7 +818,6 @@ static char *const bunzip_errors[] = {
 /* Dumb little test thing, decompress stdin to stdout */
 int main(int argc, char **argv)
 {
-       int i;
        char c;
 
        int i = unpack_bz2_stream(0, 1);
index 4e6b138c3c288276442c3b312c77da275238d0d1..7c6f38ec300318004501713b967f09951733bb70 100644 (file)
@@ -336,7 +336,7 @@ static int huft_build(const unsigned *b, const unsigned n,
        }
 
        /* Find minimum and maximum length, bound *m by those */
-       for (j = 1; (c[j] == 0) && (j <= BMAX); j++)
+       for (j = 1; (j <= BMAX) && (c[j] == 0); j++)
                continue;
        k = j; /* minimum code length */
        for (i = BMAX; (c[i] == 0) && i; i--)
index 3e331984db044aebabcabcff04f0bd5407411cfa..2b490ae83e5840035a46a7429ec3a45e9f33f8f1 100644 (file)
@@ -466,7 +466,6 @@ static int find_match(lzo1x_999_t *c, lzo_swd_p s,
        }
 
        s->m_len = 1;
-       s->m_len = 1;
 #ifdef SWD_BEST_OFF
        if (s->use_best_off)
                memset(s->best_pos, 0, sizeof(s->best_pos));
index d6b2b42cc56d65d3234337f93b060b6018814666..bbadc8eb5ecded16a2bb61594a6a978e293a0596 100644 (file)
@@ -179,8 +179,4 @@ extern int blkid_set_tag(blkid_dev dev, const char *name,
 extern blkid_dev blkid_new_dev(void);
 extern void blkid_free_dev(blkid_dev dev);
 
-#ifdef __cplusplus
-}
-#endif
-
 #endif
index d1d29146b3505a9e0d92df1eb758077e61baa8cf..251e49900e15533f2c984127b1471fd6809c0f0a 100644 (file)
@@ -115,7 +115,7 @@ int main(int argc, char** argv)
                        argv[0], ret);
                exit(1);
        }
-       if ((ret = blkid_probe_all(cache) < 0))
+       if ((ret = blkid_probe_all(cache)) < 0)
                fprintf(stderr, "error probing devices\n");
 
        blkid_put_cache(cache);
index bb0cc914a06d4fa4ddaffdafb3090cd400bcf57e..260e49c652543fceebb4696707d09a2efe9819f4 100644 (file)
@@ -153,7 +153,7 @@ extern int optind;
 void usage(char *prog)
 {
        fprintf(stderr, "Usage: %s [-f blkid_file] [-m debug_mask]\n", prog);
-       fprintf(stderr, "\tList all devices and exit\n", prog);
+       fprintf(stderr, "\tList all devices and exit\n");
        exit(1);
 }
 
@@ -176,7 +176,7 @@ int main(int argc, char **argv)
                case 'm':
                        blkid_debug_mask = strtoul (optarg, &tmp, 0);
                        if (*tmp) {
-                               fprintf(stderr, "Invalid debug mask: %d\n",
+                               fprintf(stderr, "Invalid debug mask: %s\n",
                                        optarg);
                                exit(1);
                        }
index f795a5d1457d5d4a757b340b06cd174781d0e9f8..feeda518b699d4361f79d76b91674767ee2cdc40 100644 (file)
@@ -385,7 +385,7 @@ void blkid_read_cache(blkid_cache cache)
                        continue;
                end = strlen(buf) - 1;
                /* Continue reading next line if it ends with a backslash */
-               while (buf[end] == '\\' && end < sizeof(buf) - 2 &&
+               while (end < sizeof(buf) - 2 && buf[end] == '\\' &&
                       fgets(buf + end, sizeof(buf) - end, file)) {
                        end = strlen(buf) - 1;
                        lineno++;
index 8337b46b6b30da8fec47a1a05356aebb6901efa6..7424edeb813f09eec5e255624d58a479ef688c1e 100644 (file)
@@ -356,7 +356,7 @@ void usage(char *prog)
        fprintf(stderr, "Usage: %s [-f blkid_file] [-m debug_mask] device "
                "[type value]\n",
                prog);
-       fprintf(stderr, "\tList all tags for a device and exit\n", prog);
+       fprintf(stderr, "\tList all tags for a device and exit\n");
        exit(1);
 }
 
@@ -382,7 +382,7 @@ int main(int argc, char **argv)
                case 'm':
                        blkid_debug_mask = strtoul (optarg, &tmp, 0);
                        if (*tmp) {
-                               fprintf(stderr, "Invalid debug mask: %d\n",
+                               fprintf(stderr, "Invalid debug mask: %s\n",
                                        optarg);
                                exit(1);
                        }
@@ -407,7 +407,7 @@ int main(int argc, char **argv)
 
        dev = blkid_get_dev(cache, devname, flags);
        if (!dev) {
-               fprintf(stderr, "%s: cannot find device in blkid cache\n");
+               fprintf(stderr, "%s: cannot find device in blkid cache\n", devname);
                exit(1);
        }
        if (search_type) {
index 373e8ce916befadd97910e2232d3cec0a527799b..8400a92ce176e0439509bf07c6ae88a409101e5c 100644 (file)
@@ -1050,7 +1050,7 @@ static errcode_t ea_refcount_create(int size, ext2_refcount_t *ret)
        refcount->size = size;
        bytes = (size_t) (size * sizeof(struct ea_refcount_el));
 #ifdef DEBUG
-       printf("Refcount allocated %d entries, %d bytes.\n",
+       printf("Refcount allocated %d entries, %lu bytes.\n",
               refcount->size, bytes);
 #endif
        retval = ext2fs_get_mem(bytes, &refcount->list);
@@ -3424,7 +3424,7 @@ static void e2fsck_pass1(e2fsck_t ctx)
                                continue;
                        }
                        if ((inode->i_links_count || inode->i_blocks ||
-                            inode->i_blocks || inode->i_block[0]) &&
+                            inode->i_block[0]) &&
                            fix_problem(ctx, PR_1_JOURNAL_INODE_NOT_CLEAR,
                                        &pctx)) {
                                memset(inode, 0, inode_size);
@@ -12195,11 +12195,7 @@ static void swap_filesys(e2fsck_t ctx)
 void *e2fsck_allocate_memory(e2fsck_t ctx, unsigned int size,
                             const char *description)
 {
-       void *ret;
-       char buf[256];
-
-       ret = xzalloc(size);
-       return ret;
+       return xzalloc(size);
 }
 
 static char *string_copy(const char *str, int len)
index da2d15137527c00ee1ee1c6718a9fad72bcdd3de..240335b32e7b425077c21f9f79f1e1a42d913bd1 100644 (file)
@@ -83,7 +83,7 @@ static int calc_reserved_gdt_blocks(ext2_filsys fs)
        if (rsv_gdb > EXT2_ADDR_PER_BLOCK(sb))
                rsv_gdb = EXT2_ADDR_PER_BLOCK(sb);
 #ifdef RES_GDT_DEBUG
-       printf("max_blocks %lu, rsv_groups = %lu, rsv_gdb = %lu\n",
+       printf("max_blocks %lu, rsv_groups = %lu, rsv_gdb = %u\n",
               max_blocks, rsv_groups, rsv_gdb);
 #endif
 
index 474f0734026a747f3cc038de89bb06f3ff401e3c..3c95829f09745b5739bdb3341be75f2861988135 100644 (file)
@@ -544,7 +544,7 @@ static errcode_t unix_read_blk(io_channel channel, unsigned long block,
                /* If it's in the cache, use it! */
                if ((cache = find_cached_block(data, block, &reuse[0]))) {
 #ifdef DEBUG
-                       printf("Using cached block %d\n", block);
+                       printf("Using cached block %lu\n", block);
 #endif
                        memcpy(cp, cache->buf, channel->block_size);
                        count--;
@@ -560,7 +560,7 @@ static errcode_t unix_read_blk(io_channel channel, unsigned long block,
                        if (find_cached_block(data, block+i, &reuse[i]))
                                break;
 #ifdef DEBUG
-               printf("Reading %d blocks starting at %d\n", i, block);
+               printf("Reading %d blocks starting at %lu\n", i, block);
 #endif
                if ((retval = raw_read_blk(channel, data, block, i, cp)))
                        return retval;
index 3a0743bb12d738425cbf8c7615da2be466121079..91cce970c340fbfad290a406e7efa0490ec04d24 100644 (file)
@@ -1239,7 +1239,6 @@ static void PRS(int argc, char **argv)
                                                progress_fd = 0;
                                        else {
                                                goto next_arg;
-                                               i++;
                                        }
                                }
                                break;
index 35d717a550256e53ac12fcd03ed5b660462ed180..e44d9865c581868b718c48019258bdcf83e616aa 100644 (file)
@@ -385,7 +385,7 @@ static errcode_t zero_blocks(ext2_filsys fs, blk_t blk, int num,
                             struct progress_struct *progress,
                             blk_t *ret_blk, int *ret_count)
 {
-       int             j, count, next_update, next_update_incr;
+       int             j, count, next_update;
        static char     *buf;
        errcode_t       retval;
 
@@ -403,9 +403,7 @@ static errcode_t zero_blocks(ext2_filsys fs, blk_t blk, int num,
        }
        /* OK, do the write loop */
        next_update = 0;
-       next_update_incr = num / 100;
-       if (next_update_incr < 1)
-               next_update_incr = 1;
+
        for (j=0; j < num; j += STRIDE_LENGTH, blk += STRIDE_LENGTH) {
                count = num - j;
                if (count > STRIDE_LENGTH)
index a61abc2c6634fc293651c428e6fda7d942a135e2..e6758e093a20d1ed1e3f4cb7b981253963f01b16 100644 (file)
@@ -117,7 +117,7 @@ void parse_journal_opts(char **journal_device, int *journal_flags,
                }
                if (strcmp(token, "device") == 0) {
                        *journal_device = blkid_get_devname(NULL, arg, NULL);
-                       if (!journal_device) {
+                       if (!*journal_device) {
                                journal_usage++;
                                continue;
                        }
index 889e09cab0f70d2b31d07593a0df97680f72d554..1e52ecaea84952631ae24582f50b741c449aa09e 100644 (file)
@@ -86,7 +86,7 @@ md5_crypt(char result[MD5_OUT_BUFSIZE], const unsigned char *pw, const unsigned
 
        /* Get the length of the salt including "$1$" */
        sl = 3;
-       while (salt[sl] && salt[sl] != '$' && sl < (3 + 8))
+       while (sl < (3 + 8) && salt[sl] && salt[sl] != '$')
                sl++;
 
        /* Hash. the password first, since that is what is most unknown */
index ce994f870f50b39bd2944939e9de8f1f81e42162..bd2abc24a687f3443b36d06b893f45940b27dd8d 100644 (file)
@@ -296,7 +296,7 @@ int chat_main(int argc UNUSED_PARAM, char **argv)
                                                full_write(record_fd, buf+buf_len, 1);
                                        }
                                        // dump device input if ECHO ON
-                                       if (echo > 0) {
+                                       if (echo) {
 //                                             if (buf[buf_len] < ' ') {
 //                                                     full_write(STDERR_FILENO, "^", 1);
 //                                                     buf[buf_len] += '@';
index b9a4d16ccb4b8f0bd26de7cd64895a7b88eacc2f..533f7c04226e870298ec07312ba22935c8cfed24 100644 (file)
@@ -418,9 +418,6 @@ static int print_class(const struct sockaddr_nl *who UNUSED_PARAM,
 static int print_filter(const struct sockaddr_nl *who UNUSED_PARAM,
                                                struct nlmsghdr *hdr, void *arg UNUSED_PARAM)
 {
-       struct tcmsg *msg = NLMSG_DATA(hdr);
-       int len = hdr->nlmsg_len;
-       struct rtattr * tb[TCA_MAX+1];
        return 0;
 }
 
index 0c18d6c0c305f9df0ca7344188e4a22db33e0257..97a7a19e0b4044419803a7a3f5f720c411db0f7c 100644 (file)
@@ -791,7 +791,9 @@ static int
 common_traceroute_main(int op, char **argv)
 {
        int minpacket;
+#ifdef IP_TOS
        int tos = 0;
+#endif
        int max_ttl = 30;
        int nprobes = 3;
        int first_ttl = 1;
@@ -838,8 +840,10 @@ common_traceroute_main(int op, char **argv)
        if (op & OPT_IP_CHKSUM)
                bb_error_msg("warning: ip checksums disabled");
 #endif
+#ifdef IP_TOS
        if (op & OPT_TOS)
                tos = xatou_range(tos_str, 0, 255);
+#endif
        if (op & OPT_MAX_TTL)
                max_ttl = xatou_range(max_ttl_str, 1, 255);
        if (op & OPT_PORT)
index d2fc66caa02c0976ead6addfce06ace878cd038e..5ebaa3eeff16580835714dedfd096090a414b4c5 100644 (file)
@@ -176,7 +176,7 @@ int FAST_FUNC volume_id_probe_msdos_part_table(struct volume_id *id, uint64_t of
                                if (id->partition_count < 4)
                                        id->partition_count = 4;
 
-                               p = &id->partitions[id->partition_count];
+//                             p = &id->partitions[id->partition_count];
 
 //                             if (is_raid(part[i].sys_ind))
 //                                     volume_id_set_usage_part(p, VOLUME_ID_RAID);