diff options
author | Denys Vlasenko <vda.linux@googlemail.com> | 2013-11-29 16:45:45 +0100 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2013-11-29 16:45:45 +0100 |
commit | 327f550669a80d72f36bc9e4de619c163aa46eff (patch) | |
tree | d304092aeb06539085be1385ab9298876c414b44 | |
parent | 9b2a9f0210f13f1c59c0b954c4aa0eeb0a66efd1 (diff) | |
download | busybox-327f550669a80d72f36bc9e4de619c163aa46eff.tar.gz |
Use unsigned printf/scanf conversion where more appropriate
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r-- | coreutils/cal.c | 2 | ||||
-rw-r--r-- | coreutils/sum.c | 4 | ||||
-rw-r--r-- | e2fsprogs/old_e2fsprogs/mke2fs.c | 2 | ||||
-rw-r--r-- | e2fsprogs/old_e2fsprogs/tune2fs.c | 2 | ||||
-rw-r--r-- | e2fsprogs/old_e2fsprogs/util.c | 2 | ||||
-rw-r--r-- | editors/patch_bbox.c | 4 | ||||
-rw-r--r-- | miscutils/hdparm.c | 8 | ||||
-rw-r--r-- | networking/arp.c | 4 | ||||
-rw-r--r-- | networking/netstat.c | 8 | ||||
-rw-r--r-- | networking/pscan.c | 2 | ||||
-rw-r--r-- | procps/pgrep.c | 4 | ||||
-rw-r--r-- | procps/top.c | 2 | ||||
-rw-r--r-- | sysklogd/logread.c | 2 | ||||
-rw-r--r-- | util-linux/fdformat.c | 2 | ||||
-rw-r--r-- | util-linux/fsck_minix.c | 2 | ||||
-rw-r--r-- | util-linux/ipcs.c | 10 | ||||
-rw-r--r-- | util-linux/mkfs_minix.c | 2 | ||||
-rw-r--r-- | util-linux/readprofile.c | 12 |
18 files changed, 37 insertions, 37 deletions
diff --git a/coreutils/cal.c b/coreutils/cal.c index 0d388aa1c..12c46b14f 100644 --- a/coreutils/cal.c +++ b/coreutils/cal.c @@ -165,7 +165,7 @@ int cal_main(int argc UNUSED_PARAM, char **argv) char lineout[30]; day_array(month, year, dp); - len = sprintf(lineout, "%s %d", month_names[month - 1], year); + len = sprintf(lineout, "%s %u", month_names[month - 1], year); printf("%*s%s\n%s\n", ((7*julian + WEEK_LEN) - len) / 2, "", lineout, day_headings); diff --git a/coreutils/sum.c b/coreutils/sum.c index 75f6ef60a..deb068e10 100644 --- a/coreutils/sum.c +++ b/coreutils/sum.c @@ -70,9 +70,9 @@ static unsigned sum_file(const char *file, unsigned type) if (type >= SUM_SYSV) { r = (s & 0xffff) + ((s & 0xffffffff) >> 16); s = (r & 0xffff) + (r >> 16); - printf("%d %llu %s\n", s, (total_bytes + 511) / 512, file); + printf("%u %llu %s\n", s, (total_bytes + 511) / 512, file); } else - printf("%05d %5llu %s\n", s, (total_bytes + 1023) / 1024, file); + printf("%05u %5llu %s\n", s, (total_bytes + 1023) / 1024, file); return 1; #undef buf } diff --git a/e2fsprogs/old_e2fsprogs/mke2fs.c b/e2fsprogs/old_e2fsprogs/mke2fs.c index e44d9865c..ebcb46cf2 100644 --- a/e2fsprogs/old_e2fsprogs/mke2fs.c +++ b/e2fsprogs/old_e2fsprogs/mke2fs.c @@ -239,7 +239,7 @@ static void test_disk(ext2_filsys fs, badblocks_list *bb_list) errcode_t retval; char buf[1024]; - sprintf(buf, "badblocks -b %d %s%s%s %d", fs->blocksize, + sprintf(buf, "badblocks -b %u %s%s%s %d", fs->blocksize, quiet ? "" : "-s ", (cflag > 1) ? "-w " : "", fs->device_name, fs->super->s_blocks_count); mke2fs_verbose("Running command: %s\n", buf); diff --git a/e2fsprogs/old_e2fsprogs/tune2fs.c b/e2fsprogs/old_e2fsprogs/tune2fs.c index 3c3f4afa5..bbe30e5a0 100644 --- a/e2fsprogs/old_e2fsprogs/tune2fs.c +++ b/e2fsprogs/old_e2fsprogs/tune2fs.c @@ -607,7 +607,7 @@ int tune2fs_main(int argc, char **argv) if (e_flag) { sb->s_errors = errors; ext2fs_mark_super_dirty(fs); - printf("Setting error behavior to %d\n", errors); + printf("Setting error behavior to %u\n", errors); } if (g_flag) { sb->s_def_resgid = resgid; diff --git a/e2fsprogs/old_e2fsprogs/util.c b/e2fsprogs/old_e2fsprogs/util.c index e6758e093..3e7ee8e75 100644 --- a/e2fsprogs/old_e2fsprogs/util.c +++ b/e2fsprogs/old_e2fsprogs/util.c @@ -239,7 +239,7 @@ void make_journal_blocks(ext2_filsys fs, int journal_size, int journal_flags, in return; } if (!quiet) - printf("Creating journal (%ld blocks): ", journal_blocks); + printf("Creating journal (%lu blocks): ", journal_blocks); fflush(stdout); retval = ext2fs_add_journal_inode(fs, journal_blocks, journal_flags); diff --git a/editors/patch_bbox.c b/editors/patch_bbox.c index 78aa5fde8..aae7b7987 100644 --- a/editors/patch_bbox.c +++ b/editors/patch_bbox.c @@ -188,8 +188,8 @@ int patch_main(int argc UNUSED_PARAM, char **argv) unsigned src_last_line = 1; unsigned dst_last_line = 1; - if ((sscanf(patch_line, "@@ -%d,%d +%d,%d", &src_beg_line, &src_last_line, &dst_beg_line, &dst_last_line) < 3) - && (sscanf(patch_line, "@@ -%d +%d,%d", &src_beg_line, &dst_beg_line, &dst_last_line) < 2) + if ((sscanf(patch_line, "@@ -%u,%u +%u,%u", &src_beg_line, &src_last_line, &dst_beg_line, &dst_last_line) < 3) + && (sscanf(patch_line, "@@ -%u +%u,%u", &src_beg_line, &dst_beg_line, &dst_last_line) < 2) ) { /* No more hunks for this file */ break; diff --git a/miscutils/hdparm.c b/miscutils/hdparm.c index 69726ae72..f0e9c9d75 100644 --- a/miscutils/hdparm.c +++ b/miscutils/hdparm.c @@ -465,14 +465,14 @@ static void on_off(int value) static void print_flag_on_off(int get_arg, const char *s, unsigned long arg) { if (get_arg) { - printf(" setting %s to %ld", s, arg); + printf(" setting %s to %lu", s, arg); on_off(arg); } } static void print_value_on_off(const char *str, unsigned long argp) { - printf(" %s\t= %2ld", str, argp); + printf(" %s\t= %2lu", str, argp); on_off(argp != 0); } @@ -1509,7 +1509,7 @@ static void bus_state_value(unsigned value) else if (value == BUSSTATE_TRISTATE) printf(" (tristate)\n"); else - printf(" (unknown: %d)\n", value); + printf(" (unknown: %u)\n", value); } #endif @@ -1589,7 +1589,7 @@ static void interpret_xfermode(unsigned xfermode) static void print_flag(int flag, const char *s, unsigned long value) { if (flag) - printf(" setting %s to %ld\n", s, value); + printf(" setting %s to %lu\n", s, value); } static void process_dev(char *devname) diff --git a/networking/arp.c b/networking/arp.c index 40d244116..e79b1b6a1 100644 --- a/networking/arp.c +++ b/networking/arp.c @@ -459,12 +459,12 @@ static int arp_show(char *name) arp_disp(hostname, ip, type, flags, hwa, mask, dev); } if (option_mask32 & ARP_OPT_v) - printf("Entries: %d\tSkipped: %d\tFound: %d\n", + printf("Entries: %u\tSkipped: %u\tFound: %u\n", entries, entries - shown, shown); if (!shown) { if (hw_set || host || device[0]) - printf("No match found in %d entries\n", entries); + printf("No match found in %u entries\n", entries); } if (ENABLE_FEATURE_CLEAN_UP) { free((char*)host); diff --git a/networking/netstat.c b/networking/netstat.c index c0c6ba501..f80b845bc 100644 --- a/networking/netstat.c +++ b/networking/netstat.c @@ -125,10 +125,10 @@ typedef enum { */ #define ADDR_WIDE 51 /* INET6_ADDRSTRLEN + 5 for the port number */ #if ENABLE_FEATURE_NETSTAT_WIDE -# define FMT_NET_CONN_DATA "%s %6ld %6ld %-*s %-*s %-12s" +# define FMT_NET_CONN_DATA "%s %6lu %6lu %-*s %-*s %-12s" # define FMT_NET_CONN_HEADER "\nProto Recv-Q Send-Q %-*s %-*s State %s\n" #else -# define FMT_NET_CONN_DATA "%s %6ld %6ld %-23s %-23s %-12s" +# define FMT_NET_CONN_DATA "%s %6lu %6lu %-23s %-23s %-12s" # define FMT_NET_CONN_HEADER "\nProto Recv-Q Send-Q %-23s %-23s State %s\n" #endif @@ -403,7 +403,7 @@ static int scan_inet_proc_line(struct inet_params *param, char *line) "%*d: %32[0-9A-Fa-f]:%X " "%32[0-9A-Fa-f]:%X %X " "%lX:%lX %*X:%*X " - "%*X %d %*d %ld ", + "%*X %d %*d %lu ", local_addr, ¶m->local_port, rem_addr, ¶m->rem_port, ¶m->state, ¶m->txq, ¶m->rxq, @@ -611,7 +611,7 @@ static int FAST_FUNC unix_do_one(char *line) strcat(ss_flags, "N "); strcat(ss_flags, "]"); - printf("%-5s %-6ld %-11s %-10s %-13s %6lu ", + printf("%-5s %-6lu %-11s %-10s %-13s %6lu ", ss_proto, refcnt, ss_flags, ss_type, ss_state, inode ); diff --git a/networking/pscan.c b/networking/pscan.c index 28005ad57..72ed8cdb5 100644 --- a/networking/pscan.c +++ b/networking/pscan.c @@ -157,7 +157,7 @@ int pscan_main(int argc UNUSED_PARAM, char **argv) } if (ENABLE_FEATURE_CLEAN_UP) free(lsap); - printf("%d closed, %d open, %d timed out (or blocked) ports\n", + printf("%u closed, %u open, %u timed out (or blocked) ports\n", closed_ports, open_ports, nports - (closed_ports + open_ports)); diff --git a/procps/pgrep.c b/procps/pgrep.c index 8daf5b28a..1c7c7c48b 100644 --- a/procps/pgrep.c +++ b/procps/pgrep.c @@ -65,9 +65,9 @@ static void act(unsigned pid, char *cmd, int signo) { if (pgrep) { if (option_mask32 & (1 << OPTBIT_L)) /* OPT_LIST */ - printf("%d %s\n", pid, cmd); + printf("%u %s\n", pid, cmd); else - printf("%d\n", pid); + printf("%u\n", pid); } else kill(pid, signo); } diff --git a/procps/top.c b/procps/top.c index 31f2a5113..51f1c1aed 100644 --- a/procps/top.c +++ b/procps/top.c @@ -677,7 +677,7 @@ static NOINLINE void display_process_list(int lines_rem, int scr_width) if (s->vsz >= 100000) sprintf(vsz_str_buf, "%6ldm", s->vsz/1024); else - sprintf(vsz_str_buf, "%7ld", s->vsz); + sprintf(vsz_str_buf, "%7lu", s->vsz); /* PID PPID USER STAT VSZ %VSZ [%CPU] COMMAND */ col = snprintf(line_buf, scr_width, "\n" "%5u%6u %-8.8s %s%s" FMT diff --git a/sysklogd/logread.c b/sysklogd/logread.c index 92a562919..bea73d932 100644 --- a/sysklogd/logread.c +++ b/sysklogd/logread.c @@ -126,7 +126,7 @@ int logread_main(int argc UNUSED_PARAM, char **argv) shbuf_data = shbuf->data; /* pointer! */ if (DEBUG) - printf("cur:%d tail:%i size:%i\n", + printf("cur:%u tail:%u size:%u\n", cur, shbuf_tail, shbuf_size); if (!follow) { diff --git a/util-linux/fdformat.c b/util-linux/fdformat.c index b3e918fb0..6f49cec8f 100644 --- a/util-linux/fdformat.c +++ b/util-linux/fdformat.c @@ -72,7 +72,7 @@ int fdformat_main(int argc UNUSED_PARAM, char **argv) /* original message was: "Could not determine current format type" */ xioctl(fd, FDGETPRM, ¶m); - printf("%s-sided, %d tracks, %d sec/track. Total capacity %d kB\n", + printf("%s-sided, %u tracks, %u sec/track. Total capacity %d kB\n", (param.head == 2) ? "Double" : "Single", param.track, param.sect, param.size >> 1); diff --git a/util-linux/fsck_minix.c b/util-linux/fsck_minix.c index c1d1b2cc3..33767a1af 100644 --- a/util-linux/fsck_minix.c +++ b/util-linux/fsck_minix.c @@ -686,7 +686,7 @@ static void get_inode_common(unsigned nr, uint16_t i_mode) total++; if (!inode_count[nr]) { if (!inode_in_use(nr)) { - printf("Inode %d is marked as 'unused', but it is used " + printf("Inode %u is marked as 'unused', but it is used " "for file '%s'\n", nr, current_name); if (OPT_repair) { if (ask("Mark as 'in use'", 1)) diff --git a/util-linux/ipcs.c b/util-linux/ipcs.c index 2668cafd4..67a25a8ef 100644 --- a/util-linux/ipcs.c +++ b/util-linux/ipcs.c @@ -166,10 +166,10 @@ static NOINLINE void do_shm(void) case STATUS: printf("------ Shared Memory %s --------\n", "Status"); printf("segments allocated %d\n" - "pages allocated %ld\n" - "pages resident %ld\n" - "pages swapped %ld\n" - "Swap performance: %ld attempts\t%ld successes\n", + "pages allocated %lu\n" + "pages resident %lu\n" + "pages swapped %lu\n" + "Swap performance: %lu attempts\t%lu successes\n", shm_info.used_ids, shm_info.shm_tot, shm_info.shm_rss, @@ -569,7 +569,7 @@ static void print_sem(int semid) if (val < 0 || ncnt < 0 || zcnt < 0 || pid < 0) { bb_perror_msg_and_die("semctl"); } - printf("%-10d %-10d %-10d %-10d %-10d\n", i, val, ncnt, zcnt, pid); + printf("%-10u %-10d %-10d %-10d %-10d\n", i, val, ncnt, zcnt, pid); } bb_putchar('\n'); } diff --git a/util-linux/mkfs_minix.c b/util-linux/mkfs_minix.c index 49afd1176..d65a5161c 100644 --- a/util-linux/mkfs_minix.c +++ b/util-linux/mkfs_minix.c @@ -505,7 +505,7 @@ static void get_list_blocks(char *filename) listfile = xfopen_for_read(filename); while (!feof(listfile)) { - fscanf(listfile, "%ld\n", &blockno); + fscanf(listfile, "%lu\n", &blockno); mark_zone(blockno); G.badblocks++; } diff --git a/util-linux/readprofile.c b/util-linux/readprofile.c index 974fe89c4..a64540464 100644 --- a/util-linux/readprofile.c +++ b/util-linux/readprofile.c @@ -152,7 +152,7 @@ int readprofile_main(int argc UNUSED_PARAM, char **argv) step = buf[0]; if (optInfo) { - printf("Sampling_step: %i\n", step); + printf("Sampling_step: %u\n", step); return EXIT_SUCCESS; } @@ -219,10 +219,10 @@ int readprofile_main(int argc UNUSED_PARAM, char **argv) && (fn_len = next_add-fn_add) != 0 ) { if (optVerbose) - printf("%016llx %-40s %6i %8.4f\n", fn_add, + printf("%016llx %-40s %6u %8.4f\n", fn_add, fn_name, this, this/(double)fn_len); else - printf("%6i %-40s %8.4f\n", + printf("%6u %-40s %8.4f\n", this, fn_name, this/(double)fn_len); if (optSub) { unsigned long long scan; @@ -246,14 +246,14 @@ int readprofile_main(int argc UNUSED_PARAM, char **argv) } /* clock ticks, out of kernel text - probably modules */ - printf("%6i %s\n", buf[len/sizeof(*buf)-1], "*unknown*"); + printf("%6u %s\n", buf[len/sizeof(*buf)-1], "*unknown*"); /* trailer */ if (optVerbose) - printf("%016x %-40s %6i %8.4f\n", + printf("%016x %-40s %6u %8.4f\n", 0, "total", total, total/(double)(fn_add-add0)); else - printf("%6i %-40s %8.4f\n", + printf("%6u %-40s %8.4f\n", total, "total", total/(double)(fn_add-add0)); fclose(map); |