Skip to content

Commit 9b2a9f0

Browse files
author
Denys Vlasenko
committed
fix assorted unused code and wrong format specs found by cppchekc (bug 6716)
Signed-off-by: Denys Vlasenko <[email protected]>
1 parent 1a7256a commit 9b2a9f0

File tree

20 files changed

+25
-39
lines changed

20 files changed

+25
-39
lines changed

archival/libarchive/bz/compress.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,7 @@ void generateMTFValues(EState* s)
249249
static NOINLINE
250250
void sendMTFValues(EState* s)
251251
{
252-
int32_t v, t, i, j, gs, ge, totc, bt, bc, iter;
252+
int32_t v, t, i, j, gs, ge, bt, bc, iter;
253253
int32_t nSelectors, alphaSize, minLen, maxLen, selCtr;
254254
int32_t nGroups;
255255

@@ -345,7 +345,6 @@ void sendMTFValues(EState* s)
345345
}
346346
#endif
347347
nSelectors = 0;
348-
totc = 0;
349348
gs = 0;
350349
while (1) {
351350
/*--- Set group start & end marks. --*/
@@ -411,7 +410,6 @@ void sendMTFValues(EState* s)
411410
bt = t;
412411
}
413412
}
414-
totc += bc;
415413
fave[bt]++;
416414
s->selector[nSelectors] = bt;
417415
nSelectors++;

archival/libarchive/decompress_bunzip2.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -818,7 +818,6 @@ static char *const bunzip_errors[] = {
818818
/* Dumb little test thing, decompress stdin to stdout */
819819
int main(int argc, char **argv)
820820
{
821-
int i;
822821
char c;
823822

824823
int i = unpack_bz2_stream(0, 1);

archival/libarchive/decompress_gunzip.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -336,7 +336,7 @@ static int huft_build(const unsigned *b, const unsigned n,
336336
}
337337

338338
/* Find minimum and maximum length, bound *m by those */
339-
for (j = 1; (c[j] == 0) && (j <= BMAX); j++)
339+
for (j = 1; (j <= BMAX) && (c[j] == 0); j++)
340340
continue;
341341
k = j; /* minimum code length */
342342
for (i = BMAX; (c[i] == 0) && i; i--)

archival/libarchive/lzo1x_9x.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -466,7 +466,6 @@ static int find_match(lzo1x_999_t *c, lzo_swd_p s,
466466
}
467467

468468
s->m_len = 1;
469-
s->m_len = 1;
470469
#ifdef SWD_BEST_OFF
471470
if (s->use_best_off)
472471
memset(s->best_pos, 0, sizeof(s->best_pos));

e2fsprogs/old_e2fsprogs/blkid/blkidP.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -179,8 +179,4 @@ extern int blkid_set_tag(blkid_dev dev, const char *name,
179179
extern blkid_dev blkid_new_dev(void);
180180
extern void blkid_free_dev(blkid_dev dev);
181181

182-
#ifdef __cplusplus
183-
}
184-
#endif
185-
186182
#endif

e2fsprogs/old_e2fsprogs/blkid/cache.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ int main(int argc, char** argv)
115115
argv[0], ret);
116116
exit(1);
117117
}
118-
if ((ret = blkid_probe_all(cache) < 0))
118+
if ((ret = blkid_probe_all(cache)) < 0)
119119
fprintf(stderr, "error probing devices\n");
120120

121121
blkid_put_cache(cache);

e2fsprogs/old_e2fsprogs/blkid/dev.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ extern int optind;
153153
void usage(char *prog)
154154
{
155155
fprintf(stderr, "Usage: %s [-f blkid_file] [-m debug_mask]\n", prog);
156-
fprintf(stderr, "\tList all devices and exit\n", prog);
156+
fprintf(stderr, "\tList all devices and exit\n");
157157
exit(1);
158158
}
159159

@@ -176,7 +176,7 @@ int main(int argc, char **argv)
176176
case 'm':
177177
blkid_debug_mask = strtoul (optarg, &tmp, 0);
178178
if (*tmp) {
179-
fprintf(stderr, "Invalid debug mask: %d\n",
179+
fprintf(stderr, "Invalid debug mask: %s\n",
180180
optarg);
181181
exit(1);
182182
}

e2fsprogs/old_e2fsprogs/blkid/read.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -385,7 +385,7 @@ void blkid_read_cache(blkid_cache cache)
385385
continue;
386386
end = strlen(buf) - 1;
387387
/* Continue reading next line if it ends with a backslash */
388-
while (buf[end] == '\\' && end < sizeof(buf) - 2 &&
388+
while (end < sizeof(buf) - 2 && buf[end] == '\\' &&
389389
fgets(buf + end, sizeof(buf) - end, file)) {
390390
end = strlen(buf) - 1;
391391
lineno++;

e2fsprogs/old_e2fsprogs/blkid/tag.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -356,7 +356,7 @@ void usage(char *prog)
356356
fprintf(stderr, "Usage: %s [-f blkid_file] [-m debug_mask] device "
357357
"[type value]\n",
358358
prog);
359-
fprintf(stderr, "\tList all tags for a device and exit\n", prog);
359+
fprintf(stderr, "\tList all tags for a device and exit\n");
360360
exit(1);
361361
}
362362

@@ -382,7 +382,7 @@ int main(int argc, char **argv)
382382
case 'm':
383383
blkid_debug_mask = strtoul (optarg, &tmp, 0);
384384
if (*tmp) {
385-
fprintf(stderr, "Invalid debug mask: %d\n",
385+
fprintf(stderr, "Invalid debug mask: %s\n",
386386
optarg);
387387
exit(1);
388388
}
@@ -407,7 +407,7 @@ int main(int argc, char **argv)
407407

408408
dev = blkid_get_dev(cache, devname, flags);
409409
if (!dev) {
410-
fprintf(stderr, "%s: cannot find device in blkid cache\n");
410+
fprintf(stderr, "%s: cannot find device in blkid cache\n", devname);
411411
exit(1);
412412
}
413413
if (search_type) {

e2fsprogs/old_e2fsprogs/e2fsck.c

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1050,7 +1050,7 @@ static errcode_t ea_refcount_create(int size, ext2_refcount_t *ret)
10501050
refcount->size = size;
10511051
bytes = (size_t) (size * sizeof(struct ea_refcount_el));
10521052
#ifdef DEBUG
1053-
printf("Refcount allocated %d entries, %d bytes.\n",
1053+
printf("Refcount allocated %d entries, %lu bytes.\n",
10541054
refcount->size, bytes);
10551055
#endif
10561056
retval = ext2fs_get_mem(bytes, &refcount->list);
@@ -3424,7 +3424,7 @@ static void e2fsck_pass1(e2fsck_t ctx)
34243424
continue;
34253425
}
34263426
if ((inode->i_links_count || inode->i_blocks ||
3427-
inode->i_blocks || inode->i_block[0]) &&
3427+
inode->i_block[0]) &&
34283428
fix_problem(ctx, PR_1_JOURNAL_INODE_NOT_CLEAR,
34293429
&pctx)) {
34303430
memset(inode, 0, inode_size);
@@ -12195,11 +12195,7 @@ static void swap_filesys(e2fsck_t ctx)
1219512195
void *e2fsck_allocate_memory(e2fsck_t ctx, unsigned int size,
1219612196
const char *description)
1219712197
{
12198-
void *ret;
12199-
char buf[256];
12200-
12201-
ret = xzalloc(size);
12202-
return ret;
12198+
return xzalloc(size);
1220312199
}
1220412200

1220512201
static char *string_copy(const char *str, int len)

0 commit comments

Comments
 (0)