Use unsigned printf/scanf conversion where more appropriate
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
This commit is contained in:
parent
9b2a9f0210
commit
327f550669
@ -165,7 +165,7 @@ int cal_main(int argc UNUSED_PARAM, char **argv)
|
|||||||
char lineout[30];
|
char lineout[30];
|
||||||
|
|
||||||
day_array(month, year, dp);
|
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",
|
printf("%*s%s\n%s\n",
|
||||||
((7*julian + WEEK_LEN) - len) / 2, "",
|
((7*julian + WEEK_LEN) - len) / 2, "",
|
||||||
lineout, day_headings);
|
lineout, day_headings);
|
||||||
|
@ -70,9 +70,9 @@ static unsigned sum_file(const char *file, unsigned type)
|
|||||||
if (type >= SUM_SYSV) {
|
if (type >= SUM_SYSV) {
|
||||||
r = (s & 0xffff) + ((s & 0xffffffff) >> 16);
|
r = (s & 0xffff) + ((s & 0xffffffff) >> 16);
|
||||||
s = (r & 0xffff) + (r >> 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
|
} 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;
|
return 1;
|
||||||
#undef buf
|
#undef buf
|
||||||
}
|
}
|
||||||
|
@ -239,7 +239,7 @@ static void test_disk(ext2_filsys fs, badblocks_list *bb_list)
|
|||||||
errcode_t retval;
|
errcode_t retval;
|
||||||
char buf[1024];
|
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 " : "",
|
quiet ? "" : "-s ", (cflag > 1) ? "-w " : "",
|
||||||
fs->device_name, fs->super->s_blocks_count);
|
fs->device_name, fs->super->s_blocks_count);
|
||||||
mke2fs_verbose("Running command: %s\n", buf);
|
mke2fs_verbose("Running command: %s\n", buf);
|
||||||
|
@ -607,7 +607,7 @@ int tune2fs_main(int argc, char **argv)
|
|||||||
if (e_flag) {
|
if (e_flag) {
|
||||||
sb->s_errors = errors;
|
sb->s_errors = errors;
|
||||||
ext2fs_mark_super_dirty(fs);
|
ext2fs_mark_super_dirty(fs);
|
||||||
printf("Setting error behavior to %d\n", errors);
|
printf("Setting error behavior to %u\n", errors);
|
||||||
}
|
}
|
||||||
if (g_flag) {
|
if (g_flag) {
|
||||||
sb->s_def_resgid = resgid;
|
sb->s_def_resgid = resgid;
|
||||||
|
@ -239,7 +239,7 @@ void make_journal_blocks(ext2_filsys fs, int journal_size, int journal_flags, in
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!quiet)
|
if (!quiet)
|
||||||
printf("Creating journal (%ld blocks): ", journal_blocks);
|
printf("Creating journal (%lu blocks): ", journal_blocks);
|
||||||
fflush(stdout);
|
fflush(stdout);
|
||||||
retval = ext2fs_add_journal_inode(fs, journal_blocks,
|
retval = ext2fs_add_journal_inode(fs, journal_blocks,
|
||||||
journal_flags);
|
journal_flags);
|
||||||
|
@ -188,8 +188,8 @@ int patch_main(int argc UNUSED_PARAM, char **argv)
|
|||||||
unsigned src_last_line = 1;
|
unsigned src_last_line = 1;
|
||||||
unsigned dst_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)
|
if ((sscanf(patch_line, "@@ -%u,%u +%u,%u", &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)
|
&& (sscanf(patch_line, "@@ -%u +%u,%u", &src_beg_line, &dst_beg_line, &dst_last_line) < 2)
|
||||||
) {
|
) {
|
||||||
/* No more hunks for this file */
|
/* No more hunks for this file */
|
||||||
break;
|
break;
|
||||||
|
@ -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)
|
static void print_flag_on_off(int get_arg, const char *s, unsigned long arg)
|
||||||
{
|
{
|
||||||
if (get_arg) {
|
if (get_arg) {
|
||||||
printf(" setting %s to %ld", s, arg);
|
printf(" setting %s to %lu", s, arg);
|
||||||
on_off(arg);
|
on_off(arg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void print_value_on_off(const char *str, unsigned long argp)
|
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);
|
on_off(argp != 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1509,7 +1509,7 @@ static void bus_state_value(unsigned value)
|
|||||||
else if (value == BUSSTATE_TRISTATE)
|
else if (value == BUSSTATE_TRISTATE)
|
||||||
printf(" (tristate)\n");
|
printf(" (tristate)\n");
|
||||||
else
|
else
|
||||||
printf(" (unknown: %d)\n", value);
|
printf(" (unknown: %u)\n", value);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -1589,7 +1589,7 @@ static void interpret_xfermode(unsigned xfermode)
|
|||||||
static void print_flag(int flag, const char *s, unsigned long value)
|
static void print_flag(int flag, const char *s, unsigned long value)
|
||||||
{
|
{
|
||||||
if (flag)
|
if (flag)
|
||||||
printf(" setting %s to %ld\n", s, value);
|
printf(" setting %s to %lu\n", s, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void process_dev(char *devname)
|
static void process_dev(char *devname)
|
||||||
|
@ -459,12 +459,12 @@ static int arp_show(char *name)
|
|||||||
arp_disp(hostname, ip, type, flags, hwa, mask, dev);
|
arp_disp(hostname, ip, type, flags, hwa, mask, dev);
|
||||||
}
|
}
|
||||||
if (option_mask32 & ARP_OPT_v)
|
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);
|
entries, entries - shown, shown);
|
||||||
|
|
||||||
if (!shown) {
|
if (!shown) {
|
||||||
if (hw_set || host || device[0])
|
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) {
|
if (ENABLE_FEATURE_CLEAN_UP) {
|
||||||
free((char*)host);
|
free((char*)host);
|
||||||
|
@ -125,10 +125,10 @@ typedef enum {
|
|||||||
*/
|
*/
|
||||||
#define ADDR_WIDE 51 /* INET6_ADDRSTRLEN + 5 for the port number */
|
#define ADDR_WIDE 51 /* INET6_ADDRSTRLEN + 5 for the port number */
|
||||||
#if ENABLE_FEATURE_NETSTAT_WIDE
|
#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"
|
# define FMT_NET_CONN_HEADER "\nProto Recv-Q Send-Q %-*s %-*s State %s\n"
|
||||||
#else
|
#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"
|
# define FMT_NET_CONN_HEADER "\nProto Recv-Q Send-Q %-23s %-23s State %s\n"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -403,7 +403,7 @@ static int scan_inet_proc_line(struct inet_params *param, char *line)
|
|||||||
"%*d: %32[0-9A-Fa-f]:%X "
|
"%*d: %32[0-9A-Fa-f]:%X "
|
||||||
"%32[0-9A-Fa-f]:%X %X "
|
"%32[0-9A-Fa-f]:%X %X "
|
||||||
"%lX:%lX %*X:%*X "
|
"%lX:%lX %*X:%*X "
|
||||||
"%*X %d %*d %ld ",
|
"%*X %d %*d %lu ",
|
||||||
local_addr, ¶m->local_port,
|
local_addr, ¶m->local_port,
|
||||||
rem_addr, ¶m->rem_port, ¶m->state,
|
rem_addr, ¶m->rem_port, ¶m->state,
|
||||||
¶m->txq, ¶m->rxq,
|
¶m->txq, ¶m->rxq,
|
||||||
@ -611,7 +611,7 @@ static int FAST_FUNC unix_do_one(char *line)
|
|||||||
strcat(ss_flags, "N ");
|
strcat(ss_flags, "N ");
|
||||||
strcat(ss_flags, "]");
|
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
|
ss_proto, refcnt, ss_flags, ss_type, ss_state, inode
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -157,7 +157,7 @@ int pscan_main(int argc UNUSED_PARAM, char **argv)
|
|||||||
}
|
}
|
||||||
if (ENABLE_FEATURE_CLEAN_UP) free(lsap);
|
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,
|
closed_ports,
|
||||||
open_ports,
|
open_ports,
|
||||||
nports - (closed_ports + open_ports));
|
nports - (closed_ports + open_ports));
|
||||||
|
@ -65,9 +65,9 @@ static void act(unsigned pid, char *cmd, int signo)
|
|||||||
{
|
{
|
||||||
if (pgrep) {
|
if (pgrep) {
|
||||||
if (option_mask32 & (1 << OPTBIT_L)) /* OPT_LIST */
|
if (option_mask32 & (1 << OPTBIT_L)) /* OPT_LIST */
|
||||||
printf("%d %s\n", pid, cmd);
|
printf("%u %s\n", pid, cmd);
|
||||||
else
|
else
|
||||||
printf("%d\n", pid);
|
printf("%u\n", pid);
|
||||||
} else
|
} else
|
||||||
kill(pid, signo);
|
kill(pid, signo);
|
||||||
}
|
}
|
||||||
|
@ -677,7 +677,7 @@ static NOINLINE void display_process_list(int lines_rem, int scr_width)
|
|||||||
if (s->vsz >= 100000)
|
if (s->vsz >= 100000)
|
||||||
sprintf(vsz_str_buf, "%6ldm", s->vsz/1024);
|
sprintf(vsz_str_buf, "%6ldm", s->vsz/1024);
|
||||||
else
|
else
|
||||||
sprintf(vsz_str_buf, "%7ld", s->vsz);
|
sprintf(vsz_str_buf, "%7lu", s->vsz);
|
||||||
/* PID PPID USER STAT VSZ %VSZ [%CPU] COMMAND */
|
/* PID PPID USER STAT VSZ %VSZ [%CPU] COMMAND */
|
||||||
col = snprintf(line_buf, scr_width,
|
col = snprintf(line_buf, scr_width,
|
||||||
"\n" "%5u%6u %-8.8s %s%s" FMT
|
"\n" "%5u%6u %-8.8s %s%s" FMT
|
||||||
|
@ -126,7 +126,7 @@ int logread_main(int argc UNUSED_PARAM, char **argv)
|
|||||||
shbuf_data = shbuf->data; /* pointer! */
|
shbuf_data = shbuf->data; /* pointer! */
|
||||||
|
|
||||||
if (DEBUG)
|
if (DEBUG)
|
||||||
printf("cur:%d tail:%i size:%i\n",
|
printf("cur:%u tail:%u size:%u\n",
|
||||||
cur, shbuf_tail, shbuf_size);
|
cur, shbuf_tail, shbuf_size);
|
||||||
|
|
||||||
if (!follow) {
|
if (!follow) {
|
||||||
|
@ -72,7 +72,7 @@ int fdformat_main(int argc UNUSED_PARAM, char **argv)
|
|||||||
/* original message was: "Could not determine current format type" */
|
/* original message was: "Could not determine current format type" */
|
||||||
xioctl(fd, FDGETPRM, ¶m);
|
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.head == 2) ? "Double" : "Single",
|
||||||
param.track, param.sect, param.size >> 1);
|
param.track, param.sect, param.size >> 1);
|
||||||
|
|
||||||
|
@ -686,7 +686,7 @@ static void get_inode_common(unsigned nr, uint16_t i_mode)
|
|||||||
total++;
|
total++;
|
||||||
if (!inode_count[nr]) {
|
if (!inode_count[nr]) {
|
||||||
if (!inode_in_use(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);
|
"for file '%s'\n", nr, current_name);
|
||||||
if (OPT_repair) {
|
if (OPT_repair) {
|
||||||
if (ask("Mark as 'in use'", 1))
|
if (ask("Mark as 'in use'", 1))
|
||||||
|
@ -166,10 +166,10 @@ static NOINLINE void do_shm(void)
|
|||||||
case STATUS:
|
case STATUS:
|
||||||
printf("------ Shared Memory %s --------\n", "Status");
|
printf("------ Shared Memory %s --------\n", "Status");
|
||||||
printf("segments allocated %d\n"
|
printf("segments allocated %d\n"
|
||||||
"pages allocated %ld\n"
|
"pages allocated %lu\n"
|
||||||
"pages resident %ld\n"
|
"pages resident %lu\n"
|
||||||
"pages swapped %ld\n"
|
"pages swapped %lu\n"
|
||||||
"Swap performance: %ld attempts\t%ld successes\n",
|
"Swap performance: %lu attempts\t%lu successes\n",
|
||||||
shm_info.used_ids,
|
shm_info.used_ids,
|
||||||
shm_info.shm_tot,
|
shm_info.shm_tot,
|
||||||
shm_info.shm_rss,
|
shm_info.shm_rss,
|
||||||
@ -569,7 +569,7 @@ static void print_sem(int semid)
|
|||||||
if (val < 0 || ncnt < 0 || zcnt < 0 || pid < 0) {
|
if (val < 0 || ncnt < 0 || zcnt < 0 || pid < 0) {
|
||||||
bb_perror_msg_and_die("semctl");
|
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');
|
bb_putchar('\n');
|
||||||
}
|
}
|
||||||
|
@ -505,7 +505,7 @@ static void get_list_blocks(char *filename)
|
|||||||
|
|
||||||
listfile = xfopen_for_read(filename);
|
listfile = xfopen_for_read(filename);
|
||||||
while (!feof(listfile)) {
|
while (!feof(listfile)) {
|
||||||
fscanf(listfile, "%ld\n", &blockno);
|
fscanf(listfile, "%lu\n", &blockno);
|
||||||
mark_zone(blockno);
|
mark_zone(blockno);
|
||||||
G.badblocks++;
|
G.badblocks++;
|
||||||
}
|
}
|
||||||
|
@ -152,7 +152,7 @@ int readprofile_main(int argc UNUSED_PARAM, char **argv)
|
|||||||
|
|
||||||
step = buf[0];
|
step = buf[0];
|
||||||
if (optInfo) {
|
if (optInfo) {
|
||||||
printf("Sampling_step: %i\n", step);
|
printf("Sampling_step: %u\n", step);
|
||||||
return EXIT_SUCCESS;
|
return EXIT_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -219,10 +219,10 @@ int readprofile_main(int argc UNUSED_PARAM, char **argv)
|
|||||||
&& (fn_len = next_add-fn_add) != 0
|
&& (fn_len = next_add-fn_add) != 0
|
||||||
) {
|
) {
|
||||||
if (optVerbose)
|
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);
|
fn_name, this, this/(double)fn_len);
|
||||||
else
|
else
|
||||||
printf("%6i %-40s %8.4f\n",
|
printf("%6u %-40s %8.4f\n",
|
||||||
this, fn_name, this/(double)fn_len);
|
this, fn_name, this/(double)fn_len);
|
||||||
if (optSub) {
|
if (optSub) {
|
||||||
unsigned long long scan;
|
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 */
|
/* 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 */
|
/* trailer */
|
||||||
if (optVerbose)
|
if (optVerbose)
|
||||||
printf("%016x %-40s %6i %8.4f\n",
|
printf("%016x %-40s %6u %8.4f\n",
|
||||||
0, "total", total, total/(double)(fn_add-add0));
|
0, "total", total, total/(double)(fn_add-add0));
|
||||||
else
|
else
|
||||||
printf("%6i %-40s %8.4f\n",
|
printf("%6u %-40s %8.4f\n",
|
||||||
total, "total", total/(double)(fn_add-add0));
|
total, "total", total/(double)(fn_add-add0));
|
||||||
|
|
||||||
fclose(map);
|
fclose(map);
|
||||||
|
Loading…
Reference in New Issue
Block a user