Skip to content

Commit 327f550

Browse files
author
Denys Vlasenko
committed
Use unsigned printf/scanf conversion where more appropriate
Signed-off-by: Denys Vlasenko <[email protected]>
1 parent 9b2a9f0 commit 327f550

File tree

18 files changed

+37
-37
lines changed

18 files changed

+37
-37
lines changed

coreutils/cal.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ int cal_main(int argc UNUSED_PARAM, char **argv)
165165
char lineout[30];
166166

167167
day_array(month, year, dp);
168-
len = sprintf(lineout, "%s %d", month_names[month - 1], year);
168+
len = sprintf(lineout, "%s %u", month_names[month - 1], year);
169169
printf("%*s%s\n%s\n",
170170
((7*julian + WEEK_LEN) - len) / 2, "",
171171
lineout, day_headings);

coreutils/sum.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,9 +70,9 @@ static unsigned sum_file(const char *file, unsigned type)
7070
if (type >= SUM_SYSV) {
7171
r = (s & 0xffff) + ((s & 0xffffffff) >> 16);
7272
s = (r & 0xffff) + (r >> 16);
73-
printf("%d %llu %s\n", s, (total_bytes + 511) / 512, file);
73+
printf("%u %llu %s\n", s, (total_bytes + 511) / 512, file);
7474
} else
75-
printf("%05d %5llu %s\n", s, (total_bytes + 1023) / 1024, file);
75+
printf("%05u %5llu %s\n", s, (total_bytes + 1023) / 1024, file);
7676
return 1;
7777
#undef buf
7878
}

e2fsprogs/old_e2fsprogs/mke2fs.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,7 @@ static void test_disk(ext2_filsys fs, badblocks_list *bb_list)
239239
errcode_t retval;
240240
char buf[1024];
241241

242-
sprintf(buf, "badblocks -b %d %s%s%s %d", fs->blocksize,
242+
sprintf(buf, "badblocks -b %u %s%s%s %d", fs->blocksize,
243243
quiet ? "" : "-s ", (cflag > 1) ? "-w " : "",
244244
fs->device_name, fs->super->s_blocks_count);
245245
mke2fs_verbose("Running command: %s\n", buf);

e2fsprogs/old_e2fsprogs/tune2fs.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -607,7 +607,7 @@ int tune2fs_main(int argc, char **argv)
607607
if (e_flag) {
608608
sb->s_errors = errors;
609609
ext2fs_mark_super_dirty(fs);
610-
printf("Setting error behavior to %d\n", errors);
610+
printf("Setting error behavior to %u\n", errors);
611611
}
612612
if (g_flag) {
613613
sb->s_def_resgid = resgid;

e2fsprogs/old_e2fsprogs/util.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,7 @@ void make_journal_blocks(ext2_filsys fs, int journal_size, int journal_flags, in
239239
return;
240240
}
241241
if (!quiet)
242-
printf("Creating journal (%ld blocks): ", journal_blocks);
242+
printf("Creating journal (%lu blocks): ", journal_blocks);
243243
fflush(stdout);
244244
retval = ext2fs_add_journal_inode(fs, journal_blocks,
245245
journal_flags);

editors/patch_bbox.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -188,8 +188,8 @@ int patch_main(int argc UNUSED_PARAM, char **argv)
188188
unsigned src_last_line = 1;
189189
unsigned dst_last_line = 1;
190190

191-
if ((sscanf(patch_line, "@@ -%d,%d +%d,%d", &src_beg_line, &src_last_line, &dst_beg_line, &dst_last_line) < 3)
192-
&& (sscanf(patch_line, "@@ -%d +%d,%d", &src_beg_line, &dst_beg_line, &dst_last_line) < 2)
191+
if ((sscanf(patch_line, "@@ -%u,%u +%u,%u", &src_beg_line, &src_last_line, &dst_beg_line, &dst_last_line) < 3)
192+
&& (sscanf(patch_line, "@@ -%u +%u,%u", &src_beg_line, &dst_beg_line, &dst_last_line) < 2)
193193
) {
194194
/* No more hunks for this file */
195195
break;

miscutils/hdparm.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -465,14 +465,14 @@ static void on_off(int value)
465465
static void print_flag_on_off(int get_arg, const char *s, unsigned long arg)
466466
{
467467
if (get_arg) {
468-
printf(" setting %s to %ld", s, arg);
468+
printf(" setting %s to %lu", s, arg);
469469
on_off(arg);
470470
}
471471
}
472472

473473
static void print_value_on_off(const char *str, unsigned long argp)
474474
{
475-
printf(" %s\t= %2ld", str, argp);
475+
printf(" %s\t= %2lu", str, argp);
476476
on_off(argp != 0);
477477
}
478478

@@ -1509,7 +1509,7 @@ static void bus_state_value(unsigned value)
15091509
else if (value == BUSSTATE_TRISTATE)
15101510
printf(" (tristate)\n");
15111511
else
1512-
printf(" (unknown: %d)\n", value);
1512+
printf(" (unknown: %u)\n", value);
15131513
}
15141514
#endif
15151515

@@ -1589,7 +1589,7 @@ static void interpret_xfermode(unsigned xfermode)
15891589
static void print_flag(int flag, const char *s, unsigned long value)
15901590
{
15911591
if (flag)
1592-
printf(" setting %s to %ld\n", s, value);
1592+
printf(" setting %s to %lu\n", s, value);
15931593
}
15941594

15951595
static void process_dev(char *devname)

networking/arp.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -459,12 +459,12 @@ static int arp_show(char *name)
459459
arp_disp(hostname, ip, type, flags, hwa, mask, dev);
460460
}
461461
if (option_mask32 & ARP_OPT_v)
462-
printf("Entries: %d\tSkipped: %d\tFound: %d\n",
462+
printf("Entries: %u\tSkipped: %u\tFound: %u\n",
463463
entries, entries - shown, shown);
464464

465465
if (!shown) {
466466
if (hw_set || host || device[0])
467-
printf("No match found in %d entries\n", entries);
467+
printf("No match found in %u entries\n", entries);
468468
}
469469
if (ENABLE_FEATURE_CLEAN_UP) {
470470
free((char*)host);

networking/netstat.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -125,10 +125,10 @@ typedef enum {
125125
*/
126126
#define ADDR_WIDE 51 /* INET6_ADDRSTRLEN + 5 for the port number */
127127
#if ENABLE_FEATURE_NETSTAT_WIDE
128-
# define FMT_NET_CONN_DATA "%s %6ld %6ld %-*s %-*s %-12s"
128+
# define FMT_NET_CONN_DATA "%s %6lu %6lu %-*s %-*s %-12s"
129129
# define FMT_NET_CONN_HEADER "\nProto Recv-Q Send-Q %-*s %-*s State %s\n"
130130
#else
131-
# define FMT_NET_CONN_DATA "%s %6ld %6ld %-23s %-23s %-12s"
131+
# define FMT_NET_CONN_DATA "%s %6lu %6lu %-23s %-23s %-12s"
132132
# define FMT_NET_CONN_HEADER "\nProto Recv-Q Send-Q %-23s %-23s State %s\n"
133133
#endif
134134

@@ -403,7 +403,7 @@ static int scan_inet_proc_line(struct inet_params *param, char *line)
403403
"%*d: %32[0-9A-Fa-f]:%X "
404404
"%32[0-9A-Fa-f]:%X %X "
405405
"%lX:%lX %*X:%*X "
406-
"%*X %d %*d %ld ",
406+
"%*X %d %*d %lu ",
407407
local_addr, &param->local_port,
408408
rem_addr, &param->rem_port, &param->state,
409409
&param->txq, &param->rxq,
@@ -611,7 +611,7 @@ static int FAST_FUNC unix_do_one(char *line)
611611
strcat(ss_flags, "N ");
612612
strcat(ss_flags, "]");
613613

614-
printf("%-5s %-6ld %-11s %-10s %-13s %6lu ",
614+
printf("%-5s %-6lu %-11s %-10s %-13s %6lu ",
615615
ss_proto, refcnt, ss_flags, ss_type, ss_state, inode
616616
);
617617

networking/pscan.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ int pscan_main(int argc UNUSED_PARAM, char **argv)
157157
}
158158
if (ENABLE_FEATURE_CLEAN_UP) free(lsap);
159159

160-
printf("%d closed, %d open, %d timed out (or blocked) ports\n",
160+
printf("%u closed, %u open, %u timed out (or blocked) ports\n",
161161
closed_ports,
162162
open_ports,
163163
nports - (closed_ports + open_ports));

0 commit comments

Comments
 (0)