fixed %d->%u format found by cppcheck (patch by Maxim Derbasov)

This commit is contained in:
Stanislav Shwartsman 2015-01-25 21:24:13 +00:00
parent ea390d58dc
commit b5a603c8c7
21 changed files with 43 additions and 40 deletions

View File

@ -373,7 +373,7 @@ void bx_get_command(void)
char prompt[256];
if (bx_infile_stack_index == 0) {
sprintf(prompt, "<bochs:%d> ", bx_infile_stack[bx_infile_stack_index].lineno);
sprintf(prompt, "<bochs:%u> ", bx_infile_stack[bx_infile_stack_index].lineno);
}
if (SIM->has_debug_gui() && bx_infile_stack_index == 0) {
// wait for gui debugger to send another debugger command
@ -878,9 +878,9 @@ void bx_dbg_print_avx_state(unsigned vlen)
for(unsigned i=0;i<num_regs;i++) {
dbg_printf("VMM[%02u]: ", i);
for (int j=vlen-1;j >= 0; j--) {
sprintf(param_name, "SSE.xmm%02d_%d", i, j*2+1);
sprintf(param_name, "SSE.xmm%02u_%d", i, j*2+1);
Bit64u hi = SIM->get_param_num(param_name, dbg_cpu_list)->get64();
sprintf(param_name, "SSE.xmm%02d_%d", i, j*2);
sprintf(param_name, "SSE.xmm%02u_%d", i, j*2);
Bit64u lo = SIM->get_param_num(param_name, dbg_cpu_list)->get64();
dbg_printf("%08x_%08x_%08x_%08x", GET32H(hi), GET32L(hi), GET32H(lo), GET32L(lo));
if (j!=0) dbg_printf("_");
@ -897,7 +897,7 @@ void bx_dbg_print_avx_state(unsigned vlen)
#if BX_SUPPORT_EVEX
if (BX_CPU(dbg_cpu)->is_cpu_extension_supported(BX_ISA_AVX512)) {
for(unsigned i=0;i<8;i++) {
sprintf(param_name, "OPMASK.k%d", i);
sprintf(param_name, "OPMASK.k%u", i);
Bit64u opmask = SIM->get_param_num(param_name, dbg_cpu_list)->get64();
dbg_printf("K%d: %08x_%08x\n", i, GET32H(opmask), GET32L(opmask));
}

View File

@ -1382,7 +1382,7 @@ void bx_local_apic_c::register_state(bx_param_c *parent)
bx_list_c *LVT = new bx_list_c(lapic, "lvt");
for (i=0; i<APIC_LVT_ENTRIES; i++) {
sprintf(name, "%d", i);
sprintf(name, "%u", i);
new bx_shadow_num_c(LVT, name, &lvt[i], BASE_HEX);
}

View File

@ -181,7 +181,7 @@ void BX_CPU_C::register_state(void)
bx_list_c *cpu = new bx_list_c(SIM->get_bochs_root(), name, name);
for (n=0;n<BX_ISA_EXTENSIONS_ARRAY_SIZE;n++) {
sprintf(name, "ia_extensions_bitmask_%d", n);
sprintf(name, "ia_extensions_bitmask_%u", n);
new bx_shadow_num_c(cpu, name, &ia_extensions_bitmask[n], BASE_HEX);
}
@ -470,7 +470,7 @@ void BX_CPU_C::register_state(void)
BXRS_PARAM_BOOL(tlb, split_large, TLB.split_large);
#endif
for (n=0; n<BX_TLB_SIZE; n++) {
sprintf(name, "entry%d", n);
sprintf(name, "entry%u", n);
bx_list_c *tlb_entry = new bx_list_c(tlb, name);
BXRS_HEX_PARAM_FIELD(tlb_entry, lpf, TLB.entry[n].lpf);
BXRS_HEX_PARAM_FIELD(tlb_entry, lpf_mask, TLB.entry[n].lpf_mask);

View File

@ -857,15 +857,15 @@ void MyFrame::simStatusChanged(StatusChange change, bx_bool popupNotify) {
// only enabled ATA channels with a cdrom connected are available at runtime
for (unsigned i=0; i<BX_MAX_ATA_CHANNEL; i++) {
sprintf(ata_name, "ata.%d.resources", i);
sprintf(ata_name, "ata.%u.resources", i);
base = (bx_list_c*) SIM->get_param(ata_name);
if (!SIM->get_param_bool("enabled", base)->get()) {
menuEdit->Enable(ID_Edit_ATA0+i, canConfigure);
} else {
sprintf(ata_name, "ata.%d.master", i);
sprintf(ata_name, "ata.%u.master", i);
base = (bx_list_c*) SIM->get_param(ata_name);
if (SIM->get_param_enum("type", base)->get() != BX_ATA_DEVICE_CDROM) {
sprintf(ata_name, "ata.%d.slave", i);
sprintf(ata_name, "ata.%u.slave", i);
base = (bx_list_c*) SIM->get_param(ata_name);
if (SIM->get_param_enum("type", base)->get() != BX_ATA_DEVICE_CDROM) {
menuEdit->Enable(ID_Edit_ATA0+i, canConfigure);

View File

@ -69,7 +69,7 @@ void bx_instr_initialize(unsigned cpu)
if (instruction == NULL)
instruction = new struct instruction_t[BX_SMP_PROCESSORS];
fprintf(stderr, "Initialize cpu %d\n", cpu);
fprintf(stderr, "Initialize cpu %u\n", cpu);
}
void bx_instr_reset(unsigned cpu, unsigned type)
@ -88,8 +88,8 @@ void bx_print_instruction(unsigned cpu, const instruction_t *i)
if(length != 0)
{
fprintf(stderr, "----------------------------------------------------------\n");
fprintf(stderr, "CPU %d: %s\n", cpu, disasm_tbuf);
fprintf(stderr, "LEN %d\tBYTES: ", length);
fprintf(stderr, "CPU %u: %s\n", cpu, disasm_tbuf);
fprintf(stderr, "LEN %u\tBYTES: ", length);
for(n=0;n < length;n++) fprintf(stderr, "%02x", i->opcode[n]);
if(i->is_branch)
{

View File

@ -41,7 +41,7 @@ void bx_instr_initialize(unsigned cpu)
icpu[cpu].set_cpu_id(cpu);
fprintf(stderr, "Initialize cpu %d\n", cpu);
fprintf(stderr, "Initialize cpu %u\n", cpu);
}
void bxInstrumentation::bx_instr_reset(unsigned type)

View File

@ -47,7 +47,7 @@ void bx_instr_initialize(unsigned cpu)
ia_stats[cpu].active = 0;
fprintf(stderr, "Initialize cpu %d instrumentation module\n", cpu);
fprintf(stderr, "Initialize cpu %u instrumentation module\n", cpu);
}
void bx_instr_reset(unsigned cpu, unsigned type)
@ -85,7 +85,7 @@ void bx_instr_before_execution(unsigned cpu, bxInstruction_c *i)
ia_stats[cpu].total_cnt++;
if (ia_stats[cpu].total_cnt > IA_CNT_DUMP_THRESHOLD) {
printf("Dump IA stats for CPU %d\n", cpu);
printf("Dump IA stats for CPU %u\n", cpu);
printf("----------------------------------------------------------\n");
printf("Interrupts: %d, Exceptions: %d\n", ia_stats[cpu].interrupts, ia_stats[cpu].exceptions);
while(1) {

View File

@ -201,14 +201,14 @@ void bx_dma_c::register_state(void)
char name[6];
bx_list_c *list = new bx_list_c(SIM->get_bochs_root(), "dma", "DMA State");
for (i=0; i<2; i++) {
sprintf(name, "%d", i);
sprintf(name, "%u", i);
bx_list_c *ctrl = new bx_list_c(list, name);
BXRS_PARAM_BOOL(ctrl, flip_flop, BX_DMA_THIS s[i].flip_flop);
BXRS_HEX_PARAM_FIELD(ctrl, status_reg, BX_DMA_THIS s[i].status_reg);
BXRS_HEX_PARAM_FIELD(ctrl, command_reg, BX_DMA_THIS s[i].command_reg);
BXRS_PARAM_BOOL(ctrl, ctrl_disabled, BX_DMA_THIS s[i].ctrl_disabled);
for (c=0; c<4; c++) {
sprintf(name, "%d", c);
sprintf(name, "%u", c);
bx_list_c *chan = new bx_list_c(ctrl, name);
BXRS_PARAM_BOOL(chan, DRQ, BX_DMA_THIS s[i].DRQ[c]);
BXRS_PARAM_BOOL(chan, DACK, BX_DMA_THIS s[i].DACK[c]);

View File

@ -343,7 +343,7 @@ void bx_floppy_ctrl_c::register_state(void)
new bx_shadow_num_c(list, "data_rate", &BX_FD_THIS s.data_rate);
bx_list_c *command = new bx_list_c(list, "command");
for (i=0; i<10; i++) {
sprintf(name, "%d", i);
sprintf(name, "%u", i);
new bx_shadow_num_c(command, name, &BX_FD_THIS s.command[i], BASE_HEX);
}
new bx_shadow_num_c(list, "command_index", &BX_FD_THIS s.command_index);
@ -357,7 +357,7 @@ void bx_floppy_ctrl_c::register_state(void)
new bx_shadow_num_c(list, "format_fillbyte", &BX_FD_THIS s.format_fillbyte, BASE_HEX);
bx_list_c *result = new bx_list_c(list, "result");
for (i=0; i<10; i++) {
sprintf(name, "%d", i);
sprintf(name, "%u", i);
new bx_shadow_num_c(result, name, &BX_FD_THIS s.result[i], BASE_HEX);
}
new bx_shadow_num_c(list, "result_index", &BX_FD_THIS s.result_index);
@ -380,7 +380,7 @@ void bx_floppy_ctrl_c::register_state(void)
new bx_shadow_num_c(list, "perp_mode", &BX_FD_THIS s.perp_mode);
new bx_shadow_data_c(list, "buffer", BX_FD_THIS s.floppy_buffer, 512);
for (i=0; i<4; i++) {
sprintf(name, "drive%d", i);
sprintf(name, "drive%u", i);
drive = new bx_list_c(list, name);
new bx_shadow_num_c(drive, "cylinder", &BX_FD_THIS s.cylinder[i]);
new bx_shadow_num_c(drive, "head", &BX_FD_THIS s.head[i]);
@ -417,7 +417,7 @@ void bx_floppy_ctrl_c::runtime_config(void)
for (drive=0; drive<2; drive++) {
if (BX_FD_THIS s.media[drive].status_changed) {
sprintf(pname, "floppy.%d.status", drive);
sprintf(pname, "floppy.%u.status", drive);
status = (SIM->get_param_enum(pname)->get() == BX_INSERTED);
if (BX_FD_THIS s.media_present[drive]) {
BX_FD_THIS set_media_status(drive, 0);

View File

@ -578,11 +578,11 @@ void bx_hard_drive_c::register_state(void)
bx_list_c *list = new bx_list_c(SIM->get_bochs_root(), "hard_drive", "Hard Drive State");
for (i=0; i<BX_MAX_ATA_CHANNEL; i++) {
sprintf(cname, "%d", i);
sprintf(cname, "%u", i);
chan = new bx_list_c(list, cname);
for (j=0; j<2; j++) {
if (BX_DRIVE_IS_PRESENT(i, j)) {
sprintf(dname, "drive%d", j);
sprintf(dname, "drive%u", j);
drive = new bx_list_c(chan, dname);
if (channels[i].drives[j].hdimage != NULL) {
channels[i].drives[j].hdimage->register_state(drive);

View File

@ -401,7 +401,10 @@ bx_bool hdimage_copy_file(const char *src, const char *dst)
| O_BINARY
#endif
, S_IWUSR | S_IRUSR | S_IRGRP | S_IWGRP);
if (fd2 < 0) return 0;
if (fd2 < 0) {
::close(fd1);
return 0;
}
offset = 0;
size = 0x20000;
buf = (char*)malloc(size);

View File

@ -199,7 +199,7 @@ void bx_iodebug_c::mem_write(BX_CPU_C *cpu, bx_phy_address addr, unsigned len, v
}
bx_guard.interrupt_requested=1;
#else
fprintf(stderr, "IODEBUG write to monitored memory area: %2i\t", area);
fprintf(stderr, "IODEBUG write to monitored memory area: %2u\t", area);
if (cpu != NULL)
fprintf(stderr, "by EIP:\t\t" FMT_ADDRX "\n\t", cpu->get_instruction_pointer());
@ -262,7 +262,7 @@ void bx_iodebug_c::mem_read(BX_CPU_C *cpu, bx_phy_address addr, unsigned len, vo
}
bx_guard.interrupt_requested=1;
#else
fprintf(stderr, "IODEBUG read at monitored memory area: %2i\t", area);
fprintf(stderr, "IODEBUG read at monitored memory area: %2u\t", area);
if (cpu != NULL)
fprintf(stderr, "by EIP:\t\t" FMT_ADDRX "\n\t", cpu->get_instruction_pointer());

View File

@ -838,12 +838,12 @@ int tftp_send_optack(Bit8u *buffer, tftp_session_t *s)
}
if (s->options & TFTP_OPTION_BLKSIZE) {
*p++='b'; *p++='l'; *p++='k'; *p++='s'; *p++='i'; *p++='z'; *p++='e'; *p++='\0';
sprintf((char *)p, "%d", s->blksize_val);
sprintf((char *)p, "%u", s->blksize_val);
p += strlen((const char *)p) + 1;
}
if (s->options & TFTP_OPTION_TIMEOUT) {
*p++='t'; *p++='i'; *p++='m'; *p++='e'; *p++='o'; *p++='u'; *p++='t'; *p++='\0';
sprintf((char *)p, "%d", s->timeout_val);
sprintf((char *)p, "%u", s->timeout_val);
p += strlen((const char *)p) + 1;
}
tftp_update_timestamp(s);

View File

@ -211,10 +211,10 @@ void bx_parallel_c::register_state(void)
bx_list_c *list = new bx_list_c(SIM->get_bochs_root(), "parallel", "Parallel Port State");
for (i=0; i<BX_N_PARALLEL_PORTS; i++) {
sprintf(pname, "ports.parallel.%d", i+1);
sprintf(pname, "ports.parallel.%u", i+1);
base = (bx_list_c*) SIM->get_param(pname);
if (SIM->get_param_bool("enabled", base)->get()) {
sprintf(name, "%d", i);
sprintf(name, "%u", i);
port = new bx_list_c(list, name);
new bx_shadow_num_c(port, "data", &BX_PAR_THIS s[i].data, BASE_HEX);
new bx_shadow_bool_c(port, "slct", &BX_PAR_THIS s[i].STATUS.slct);

View File

@ -168,12 +168,12 @@ void bx_piix3_c::register_state(void)
bx_list_c *irqr = new bx_list_c(list, "irq_registry");
for (i=0; i<16; i++) {
sprintf(name, "%d", i);
sprintf(name, "%u", i);
new bx_shadow_num_c(irqr, name, &BX_P2I_THIS s.irq_registry[i]);
}
bx_list_c *irql = new bx_list_c(list, "irq_level");
for (i=0; i<16; i++) {
sprintf(name, "%d", i);
sprintf(name, "%u", i);
new bx_shadow_num_c(irql, name, &BX_P2I_THIS s.irq_level[i]);
}
}

View File

@ -144,7 +144,7 @@ void bx_pci_ide_c::register_state(void)
new bx_shadow_data_c(list, "buffer1", BX_PIDE_THIS s.bmdma[1].buffer, 0x20000);
for (unsigned i=0; i<2; i++) {
sprintf(name, "%d", i);
sprintf(name, "%u", i);
bx_list_c *ctrl = new bx_list_c(list, name);
BXRS_PARAM_BOOL(ctrl, cmd_ssbm, BX_PIDE_THIS s.bmdma[i].cmd_ssbm);
BXRS_PARAM_BOOL(ctrl, cmd_rwcon, BX_PIDE_THIS s.bmdma[i].cmd_rwcon);

View File

@ -211,7 +211,7 @@ void pit_82C54::register_state(bx_param_c *parent)
char name[4];
for (unsigned i=0; i<3; i++) {
sprintf(name, "%d", i);
sprintf(name, "%u", i);
bx_list_c *tim = new bx_list_c(parent, name);
new bx_shadow_bool_c(tim, "GATE", &counter[i].GATE);
new bx_shadow_bool_c(tim, "OUTpin", &counter[i].OUTpin);

View File

@ -583,7 +583,7 @@ void bx_serial_c::register_state(void)
bx_list_c *list = new bx_list_c(SIM->get_bochs_root(), "serial", "Serial Port State");
for (i=0; i<BX_N_SERIAL_PORTS; i++) {
sprintf(name, "%d", i);
sprintf(name, "%u", i);
port = new bx_list_c(list, name);
new bx_shadow_bool_c(port, "ls_interrupt", &BX_SER_THIS s[i].ls_interrupt);
new bx_shadow_bool_c(port, "ms_interrupt", &BX_SER_THIS s[i].ms_interrupt);

View File

@ -390,7 +390,7 @@ void bx_virt_timer_c::register_state(void)
bx_list_c *list = new bx_list_c(SIM->get_bochs_root(), "virt_timer", "Virtual Timer State");
bx_list_c *vtimers = new bx_list_c(list, "timer");
for (i = 0; i < numTimers; i++) {
sprintf(name, "%d", i);
sprintf(name, "%u", i);
bx_list_c *bxtimer = new bx_list_c(vtimers, name);
BXRS_PARAM_BOOL(bxtimer, inUse, timer[i].inUse);
BXRS_DEC_PARAM_FIELD(bxtimer, period, timer[i].period);
@ -401,7 +401,7 @@ void bx_virt_timer_c::register_state(void)
}
bx_list_c *sys = new bx_list_c(list, "s");
for (i = 0; i < 2; i++) {
sprintf(name, "%d", i);
sprintf(name, "%u", i);
bx_list_c *snum = new bx_list_c(sys, name);
BXRS_DEC_PARAM_FIELD(snum, current_timers_time, s[i].current_timers_time);
BXRS_DEC_PARAM_FIELD(snum, timers_next_event_time, s[i].timers_next_event_time);

View File

@ -1222,7 +1222,7 @@ int CDECL main(int argc, char *argv[])
image_overwrite_check(bx_filename_1);
if (bx_hdimage == 0) {
sprintf(bochsrc_line, "floppya: image=\"%s\", status=inserted", bx_filename_1);
printf("\nCreating floppy image '%s' with %d sectors\n", bx_filename_1, fdsize_sectors[bx_fdsize_idx]);
printf("\nCreating floppy image '%s' with %u sectors\n", bx_filename_1, fdsize_sectors[bx_fdsize_idx]);
create_flat_image(bx_filename_1, fdsize_sectors[bx_fdsize_idx] * 512);
} else {
int heads = 16, spt = 63;

View File

@ -234,7 +234,7 @@ void bx_pc_system_c::register_state(void)
bx_list_c *timers = new bx_list_c(list, "timer");
for (unsigned i = 0; i < numTimers; i++) {
char name[4];
sprintf(name, "%d", i);
sprintf(name, "%u", i);
bx_list_c *bxtimer = new bx_list_c(timers, name);
BXRS_PARAM_BOOL(bxtimer, inUse, timer[i].inUse);
BXRS_DEC_PARAM_FIELD(bxtimer, period, timer[i].period);