mirror of
https://github.com/mamedev/mame.git
synced 2024-11-16 07:48:32 +01:00
Clean up several sprintf() deprecation warningss in non-3rdparty code. [R. Belmont]
This commit is contained in:
parent
d28d93b9dd
commit
982d9385b9
13 changed files with 28 additions and 28 deletions
|
@ -330,7 +330,7 @@ void h8_timer16_device::device_start()
|
|||
memset(m_timer_channel, 0, sizeof(m_timer_channel));
|
||||
for(int i=0; i<m_timer_count; i++) {
|
||||
char tm[0x10];
|
||||
sprintf(tm, "%d", i);
|
||||
snprintf(tm, 0x10, "%d", i);
|
||||
m_timer_channel[i] = subdevice<h8_timer16_channel_device>(tm);
|
||||
}
|
||||
|
||||
|
|
|
@ -1914,9 +1914,9 @@ char *i386_disassembler::hexstring(uint32_t value, int digits)
|
|||
static char buffer[20];
|
||||
buffer[0] = '0';
|
||||
if (digits)
|
||||
sprintf(&buffer[1], "%0*Xh", digits, value);
|
||||
snprintf(&buffer[1], 19, "%0*Xh", digits, value);
|
||||
else
|
||||
sprintf(&buffer[1], "%Xh", value);
|
||||
snprintf(&buffer[1], 19, "%Xh", value);
|
||||
return (buffer[1] >= '0' && buffer[1] <= '9') ? &buffer[1] : &buffer[0];
|
||||
}
|
||||
|
||||
|
@ -1925,9 +1925,9 @@ char *i386_disassembler::hexstring64(uint32_t lo, uint32_t hi)
|
|||
static char buffer[40];
|
||||
buffer[0] = '0';
|
||||
if (hi != 0)
|
||||
sprintf(&buffer[1], "%X%08Xh", hi, lo);
|
||||
snprintf(&buffer[1], 39, "%X%08Xh", hi, lo);
|
||||
else
|
||||
sprintf(&buffer[1], "%Xh", lo);
|
||||
snprintf(&buffer[1], 39, "%Xh", lo);
|
||||
return (buffer[1] >= '0' && buffer[1] <= '9') ? &buffer[1] : &buffer[0];
|
||||
}
|
||||
|
||||
|
|
|
@ -118,7 +118,7 @@ inline void m68000_musashi_device::store_pack_float80(u32 ea, int k, floatx80 fp
|
|||
dw1 = dw2 = dw3 = 0;
|
||||
ch = &str[0];
|
||||
|
||||
sprintf(str, "%.16e", fx80_to_double(fpr));
|
||||
snprintf(str, 128, "%.16e", fx80_to_double(fpr));
|
||||
|
||||
if (*ch == '-')
|
||||
{
|
||||
|
|
|
@ -876,15 +876,15 @@ void ppc_device::device_start()
|
|||
for (int regnum = 0; regnum < 32; regnum++)
|
||||
{
|
||||
char buf[10];
|
||||
sprintf(buf, "r%d", regnum);
|
||||
snprintf(buf, 10, "r%d", regnum);
|
||||
m_drcuml->symbol_add(&m_core->r[regnum], sizeof(m_core->r[regnum]), buf);
|
||||
sprintf(buf, "fpr%d", regnum);
|
||||
snprintf(buf, 10, "fpr%d", regnum);
|
||||
m_drcuml->symbol_add(&m_core->f[regnum], sizeof(m_core->f[regnum]), buf);
|
||||
}
|
||||
for (int regnum = 0; regnum < 8; regnum++)
|
||||
{
|
||||
char buf[10];
|
||||
sprintf(buf, "cr%d", regnum);
|
||||
snprintf(buf, 10, "cr%d", regnum);
|
||||
m_drcuml->symbol_add(&m_core->cr[regnum], sizeof(m_core->cr[regnum]), buf);
|
||||
}
|
||||
m_drcuml->symbol_add(&m_core->xerso, sizeof(m_core->xerso), "xerso");
|
||||
|
|
|
@ -1465,7 +1465,7 @@ void ppc_device::static_generate_lsw_entries(int mode)
|
|||
char temp[20];
|
||||
|
||||
/* allocate a handle */
|
||||
sprintf(temp, "lsw%d", regnum);
|
||||
snprintf(temp, 20, "lsw%d", regnum);
|
||||
alloc_handle(m_drcuml.get(), &m_lsw[mode][regnum], temp);
|
||||
UML_HANDLE(block, *m_lsw[mode][regnum]); // handle lsw<regnum>
|
||||
UML_LABEL(block, regnum); // regnum:
|
||||
|
@ -1517,7 +1517,7 @@ void ppc_device::static_generate_stsw_entries(int mode)
|
|||
char temp[20];
|
||||
|
||||
/* allocate a handle */
|
||||
sprintf(temp, "stsw%d", regnum);
|
||||
snprintf(temp, 20, "stsw%d", regnum);
|
||||
alloc_handle(m_drcuml.get(), &m_stsw[mode][regnum], temp);
|
||||
UML_HANDLE(block, *m_stsw[mode][regnum]); // handle stsw<regnum>
|
||||
UML_LABEL(block, regnum); // regnum:
|
||||
|
|
|
@ -108,7 +108,7 @@ void legacy_floppy_image_device::log_readwrite(const char *name, int head, int t
|
|||
char membuf[1024];
|
||||
int i;
|
||||
for (i = 0; i < length; i++)
|
||||
sprintf(membuf + i*2, "%02x", (int) (uint8_t) buf[i]);
|
||||
snprintf(membuf + i*2, 1024 - (i*2), "%02x", (int) (uint8_t) buf[i]);
|
||||
logerror("%s: head=%i track=%i sector=%i buffer='%s'\n", name, head, track, sector, membuf);
|
||||
}
|
||||
|
||||
|
|
|
@ -282,7 +282,7 @@ void corvus_hdc_device::dump_buffer(uint8_t *buffer, uint16_t length) {
|
|||
for(uint16_t offset = 0; offset < length; offset += 16) {
|
||||
int buf_offset = 0;
|
||||
for(uint8_t byte_idx = 0; byte_idx < 16 && (offset + byte_idx) < length; byte_idx++) {
|
||||
sprintf(data_buf + buf_offset, "%02x ", *(buffer + offset));
|
||||
snprintf(data_buf + buf_offset, 128 - buf_offset, "%02x ", *(buffer + offset));
|
||||
ascii_buf[byte_idx] = isprint(*(buffer + offset)) ? *(buffer + offset) : '.';
|
||||
}
|
||||
if((length - offset) < 16) {
|
||||
|
|
|
@ -52,7 +52,7 @@ static inline void ATTR_PRINTF( 3, 4 ) verboselog( device_t *device, int n_level
|
|||
va_list v;
|
||||
char buf[ 32768 ];
|
||||
va_start( v, s_fmt );
|
||||
vsprintf( buf, s_fmt, v );
|
||||
vsnprintf( buf, 32768, s_fmt, v );
|
||||
va_end( v );
|
||||
device->logerror( "%s: I2CMEM %s", device->machine().describe_context(), buf );
|
||||
}
|
||||
|
|
|
@ -932,9 +932,9 @@ void wd_fdc_device_base::write_track_continue()
|
|||
if(format_last_byte_count) {
|
||||
char buf[32];
|
||||
if(format_last_byte_count > 1)
|
||||
sprintf(buf, "%dx%02x", format_last_byte_count, format_last_byte);
|
||||
snprintf(buf, 32, "%dx%02x", format_last_byte_count, format_last_byte);
|
||||
else
|
||||
sprintf(buf, "%02x", format_last_byte);
|
||||
snprintf(buf, 32, "%02x", format_last_byte);
|
||||
format_description_string += buf;
|
||||
}
|
||||
LOGDESC("track description %s\n", format_description_string.c_str());
|
||||
|
@ -2104,9 +2104,9 @@ void wd_fdc_device_base::live_run(attotime limit)
|
|||
if(format_last_byte_count) {
|
||||
char buf[32];
|
||||
if(format_last_byte_count > 1)
|
||||
sprintf(buf, "%dx%02x ", format_last_byte_count, format_last_byte);
|
||||
snprintf(buf, 32, "%dx%02x ", format_last_byte_count, format_last_byte);
|
||||
else
|
||||
sprintf(buf, "%02x ", format_last_byte);
|
||||
snprintf(buf, 32, "%02x ", format_last_byte);
|
||||
format_description_string += buf;
|
||||
}
|
||||
format_last_byte = data;
|
||||
|
|
|
@ -119,11 +119,11 @@ const char *attotime::as_string(int precision) const
|
|||
|
||||
// special case: never
|
||||
if (*this == never)
|
||||
sprintf(buffer, "%-*s", precision, "(never)");
|
||||
snprintf(buffer, 30, "%-*s", precision, "(never)");
|
||||
|
||||
// case 1: we want no precision; seconds only
|
||||
else if (precision == 0)
|
||||
sprintf(buffer, "%d", m_seconds);
|
||||
snprintf(buffer, 30, "%d", m_seconds);
|
||||
|
||||
// case 2: we want 9 or fewer digits of precision
|
||||
else if (precision <= 9)
|
||||
|
@ -135,7 +135,7 @@ const char *attotime::as_string(int precision) const
|
|||
upper /= 10;
|
||||
temp++;
|
||||
}
|
||||
sprintf(buffer, "%d.%0*d", m_seconds, precision, upper);
|
||||
snprintf(buffer, 30, "%d.%0*d", m_seconds, precision, upper);
|
||||
}
|
||||
|
||||
// case 3: more than 9 digits of precision
|
||||
|
@ -149,7 +149,7 @@ const char *attotime::as_string(int precision) const
|
|||
lower /= 10;
|
||||
temp++;
|
||||
}
|
||||
sprintf(buffer, "%d.%09d%0*d", m_seconds, upper, precision - 9, lower);
|
||||
snprintf(buffer, 30, "%d.%09d%0*d", m_seconds, upper, precision - 9, lower);
|
||||
}
|
||||
return buffer;
|
||||
}
|
||||
|
|
|
@ -170,7 +170,7 @@ debugger_commands::debugger_commands(running_machine& machine, debugger_cpu& cpu
|
|||
if ((valcount == 1) && (blockcount == 1) && strstr(name, "/globals/"))
|
||||
{
|
||||
char symname[100];
|
||||
sprintf(symname, ".%s", strrchr(name, '/') + 1);
|
||||
snprintf(symname, 100, ".%s", strrchr(name, '/') + 1);
|
||||
m_global_array[itemnum].base = base;
|
||||
m_global_array[itemnum].size = valsize;
|
||||
symtable.add(
|
||||
|
|
|
@ -94,7 +94,7 @@ debugger_cpu::debugger_cpu(running_machine &machine)
|
|||
for (int regnum = 0; regnum < NUM_TEMP_VARIABLES; regnum++)
|
||||
{
|
||||
char symname[10];
|
||||
sprintf(symname, "temp%d", regnum);
|
||||
snprintf(symname, 10, "temp%d", regnum);
|
||||
m_symtable->add(symname, symbol_table::READ_WRITE, &m_tempvar[regnum]);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -309,7 +309,7 @@ void debug_view_memory::generate_row(debug_view_char *destmin, debug_view_char *
|
|||
|
||||
// generate the address
|
||||
char addrtext[20];
|
||||
sprintf(addrtext, m_addrformat.c_str(), address);
|
||||
snprintf(addrtext, 20, m_addrformat.c_str(), address);
|
||||
debug_view_char *dest = destrow + m_section[0].m_pos + 1;
|
||||
for (int ch = 0; addrtext[ch] != 0 && ch < m_section[0].m_width - 1; ch++, dest++)
|
||||
if (dest >= destmin && dest < destmax)
|
||||
|
@ -359,15 +359,15 @@ void debug_view_memory::generate_row(debug_view_char *destmin, debug_view_char *
|
|||
switch (m_data_format)
|
||||
{
|
||||
case data_format::FLOAT_32BIT:
|
||||
sprintf(valuetext, "%.8g", u32_to_float(u32(chunkdata)));
|
||||
snprintf(valuetext, 64, "%.8g", u32_to_float(u32(chunkdata)));
|
||||
break;
|
||||
case data_format::FLOAT_64BIT:
|
||||
sprintf(valuetext, "%.24g", u64_to_double(chunkdata));
|
||||
snprintf(valuetext, 64, "%.24g", u64_to_double(chunkdata));
|
||||
break;
|
||||
case data_format::FLOAT_80BIT:
|
||||
{
|
||||
float64_t f64 = extF80M_to_f64(&chunkdata80);
|
||||
sprintf(valuetext, "%.24g", u64_to_double(f64.v));
|
||||
snprintf(valuetext, 64, "%.24g", u64_to_double(f64.v));
|
||||
break;
|
||||
}
|
||||
default:
|
||||
|
|
Loading…
Reference in a new issue