mirror of
https://github.com/holub/mame
synced 2025-07-04 17:38:08 +03:00
Fixed a few issues identified by Coverity:
* cpu/m6805: Removed unnecessary comparison that can't be true from 'HC05 timer handler. * machine/z80scc.cpp: Fixed flag test in logging. * emu/devdelegate.h: Fixed use-after-move in functoid constructor. * util/unzip.cpp: Fixed integer promotion issue in ZIP16 member header handling. * util/xmlfile.cpp: Got rid of custom allocator functions that have alignment issues and no longer provide value. * capcom/alien.cpp: Use machine().rand() for determinism. * ensoniq/esqpanel.cpp: I/O stream eof() returns whether a read stopped short due to EOF, not whether the file pointer is at EOF. * sega/sms.cpp: Fixed a few use-after-move errors. * osd/modules/monitor: Fixed an apparent bug in what appears to be a setter member function.
This commit is contained in:
parent
185f734a6c
commit
0fab97a476
@ -646,7 +646,7 @@ void m68hc05_device::burn_cycles(unsigned count)
|
||||
unsigned const ps_mask((1 << ps_opt) - 1);
|
||||
unsigned const increments((count + (m_prescaler & ps_mask)) >> ps_opt);
|
||||
u32 const new_counter(u32(m_counter) + increments);
|
||||
bool const timer_rollover((0x010000 > m_counter) && (0x010000 <= new_counter));
|
||||
bool const timer_rollover(0x010000 <= new_counter);
|
||||
bool const output_compare_match((m_ocr > m_counter) && (m_ocr <= new_counter));
|
||||
m_prescaler = (count + m_prescaler) & ps_mask;
|
||||
m_counter = u16(new_counter);
|
||||
|
@ -1918,7 +1918,7 @@ void z80scc_channel::do_sccreg_wr1(uint8_t data)
|
||||
LOG("- Receiver Interrupt on Special Conditions only\n");
|
||||
break;
|
||||
}
|
||||
if ((data & WR1_RX_INT_MODE_MASK) == WR1_PARITY_IS_SPEC_COND)
|
||||
if (data & WR1_PARITY_IS_SPEC_COND)
|
||||
LOG("- Parity error is a Special Condition\n");
|
||||
m_uart->check_interrupts();
|
||||
}
|
||||
|
@ -211,7 +211,7 @@ public:
|
||||
device_delegate(device_t &owner, T &&funcptr, std::enable_if_t<suitable_functoid<T>::value, char const *> name)
|
||||
: basetype(std::forward<T>(funcptr), name)
|
||||
, detail::device_delegate_helper(owner)
|
||||
{ basetype::operator=(basetype(std::forward<T>(funcptr), name)); }
|
||||
{ }
|
||||
|
||||
// setters that implicitly bind to the current device
|
||||
template <class D> void set(ReturnType (D::*funcptr)(Params...), char const *name)
|
||||
|
@ -593,17 +593,17 @@ public:
|
||||
, m_compressed_size(header.compressed_size())
|
||||
, m_header_offset(header.header_offset())
|
||||
, m_start_disk(header.start_disk())
|
||||
, m_offs_compressed_size(~m_uncompressed_size ? 0 : 8)
|
||||
, m_offs_header_offset(m_offs_compressed_size + (~m_compressed_size ? 0 : 8))
|
||||
, m_offs_start_disk(m_offs_header_offset + (~m_header_offset ? 0 : 8))
|
||||
, m_offs_end(m_offs_start_disk + (~m_start_disk ? 0 : 4))
|
||||
, m_offs_compressed_size((0xffff'ffffU != m_uncompressed_size) ? 0 : 8)
|
||||
, m_offs_header_offset(m_offs_compressed_size + ((0xffff'ffffU != m_compressed_size) ? 0 : 8))
|
||||
, m_offs_start_disk(m_offs_header_offset + ((0xffff'ffffU != m_header_offset) ? 0 : 8))
|
||||
, m_offs_end(m_offs_start_disk + ((0xffffU != m_start_disk) ? 0 : 4))
|
||||
{
|
||||
}
|
||||
|
||||
std::uint64_t uncompressed_size() const noexcept { return ~m_uncompressed_size ? m_uncompressed_size : read_qword(0x00); }
|
||||
std::uint64_t compressed_size() const noexcept { return ~m_compressed_size ? m_compressed_size : read_qword(m_offs_compressed_size); }
|
||||
std::uint64_t header_offset() const noexcept { return ~m_header_offset ? m_header_offset : read_qword(m_offs_header_offset); }
|
||||
std::uint32_t start_disk() const noexcept { return ~m_start_disk ? m_start_disk : read_dword(m_offs_start_disk); }
|
||||
std::uint64_t uncompressed_size() const noexcept { return (0xffff'ffffU != m_uncompressed_size) ? m_uncompressed_size : read_qword(0x00); }
|
||||
std::uint64_t compressed_size() const noexcept { return (0xffff'ffffU != m_compressed_size) ? m_compressed_size : read_qword(m_offs_compressed_size); }
|
||||
std::uint64_t header_offset() const noexcept { return (0xffff'ffffU != m_header_offset) ? m_header_offset : read_qword(m_offs_header_offset); }
|
||||
std::uint32_t start_disk() const noexcept { return (0xffffU != m_start_disk) ? m_start_disk : read_dword(m_offs_start_disk); }
|
||||
|
||||
std::size_t total_length() const noexcept { return minimum_length() + m_offs_end; }
|
||||
static constexpr std::size_t minimum_length() { return 0x00; }
|
||||
|
@ -807,49 +807,12 @@ const char *normalize_string(const char *string)
|
||||
// EXPAT INTERFACES
|
||||
//**************************************************************************
|
||||
|
||||
//-------------------------------------------------
|
||||
// expat_malloc/expat_realloc/expat_free -
|
||||
// wrappers for memory allocation functions so
|
||||
// that they pass through out memory tracking
|
||||
// systems
|
||||
//-------------------------------------------------
|
||||
|
||||
static void *expat_malloc(size_t size)
|
||||
{
|
||||
auto *result = (uint32_t *)malloc(size + 4 * sizeof(uint32_t));
|
||||
*result = size;
|
||||
return &result[4];
|
||||
}
|
||||
|
||||
static void expat_free(void *ptr)
|
||||
{
|
||||
if (ptr != nullptr)
|
||||
free(&((uint32_t *)ptr)[-4]);
|
||||
}
|
||||
|
||||
static void *expat_realloc(void *ptr, size_t size)
|
||||
{
|
||||
void *newptr = expat_malloc(size);
|
||||
if (newptr == nullptr)
|
||||
return nullptr;
|
||||
if (ptr != nullptr)
|
||||
{
|
||||
uint32_t oldsize = ((uint32_t *)ptr)[-4];
|
||||
memcpy(newptr, ptr, oldsize);
|
||||
expat_free(ptr);
|
||||
}
|
||||
return newptr;
|
||||
}
|
||||
|
||||
|
||||
//-------------------------------------------------
|
||||
// expat_setup_parser - set up expat for parsing
|
||||
//-------------------------------------------------
|
||||
|
||||
static bool expat_setup_parser(parse_info &info, parse_options const *opts)
|
||||
{
|
||||
XML_Memory_Handling_Suite memcallbacks;
|
||||
|
||||
// setup info structure
|
||||
memset(&info, 0, sizeof(info));
|
||||
if (opts != nullptr)
|
||||
@ -870,11 +833,8 @@ static bool expat_setup_parser(parse_info &info, parse_options const *opts)
|
||||
info.curnode = info.rootnode.get();
|
||||
|
||||
// create the XML parser
|
||||
memcallbacks.malloc_fcn = expat_malloc;
|
||||
memcallbacks.realloc_fcn = expat_realloc;
|
||||
memcallbacks.free_fcn = expat_free;
|
||||
info.parser = XML_ParserCreate_MM(nullptr, &memcallbacks, nullptr);
|
||||
if (info.parser == nullptr)
|
||||
info.parser = XML_ParserCreate(nullptr);
|
||||
if (!info.parser)
|
||||
{
|
||||
info.rootnode.reset();
|
||||
return false;
|
||||
|
@ -111,7 +111,7 @@ u32 alien_state::screen_update(screen_device &screen, bitmap_rgb32 &bitmap, cons
|
||||
u8 alien_state::fpga_r()
|
||||
{
|
||||
u8 fpga_type = 1; // 2 bit value
|
||||
return (fpga_type << 5) | 0x10 | (rand() & 7); // status bits TODO
|
||||
return (fpga_type << 5) | 0x10 | (machine().rand() & 7); // status bits TODO
|
||||
}
|
||||
|
||||
void alien_state::alien_map(address_map &map)
|
||||
|
@ -71,13 +71,13 @@ namespace esqpanel {
|
||||
return 0;
|
||||
}
|
||||
|
||||
int c;
|
||||
while ((c = is.get()) != EOF)
|
||||
{
|
||||
int message_type = external_panel::get_message_type(char(uint8_t(unsigned(c))));
|
||||
int n;
|
||||
while (!is.eof()) {
|
||||
char c = is.get();
|
||||
int message_type = external_panel::get_message_type(c);
|
||||
is >> n;
|
||||
int send = (n != 0);
|
||||
if (send)
|
||||
if (n != 0)
|
||||
{
|
||||
m_send_message_types |= message_type;
|
||||
}
|
||||
|
@ -540,7 +540,7 @@ void sms_state::sms_ntsc_base(machine_config &config)
|
||||
template <typename X>
|
||||
void sms_state::screen_sms_pal_raw_params(screen_device &screen, X &&pixelclock)
|
||||
{
|
||||
screen.set_raw(std::forward<X>(pixelclock),
|
||||
screen.set_raw(pixelclock,
|
||||
sega315_5124_device::WIDTH,
|
||||
sega315_5124_device::LBORDER_START + sega315_5124_device::LBORDER_WIDTH - 2,
|
||||
sega315_5124_device::LBORDER_START + sega315_5124_device::LBORDER_WIDTH + 256 + 10,
|
||||
@ -553,7 +553,7 @@ void sms_state::screen_sms_pal_raw_params(screen_device &screen, X &&pixelclock)
|
||||
template <typename X>
|
||||
void sms_state::screen_sms_ntsc_raw_params(screen_device &screen, X &&pixelclock)
|
||||
{
|
||||
screen.set_raw(std::forward<X>(pixelclock),
|
||||
screen.set_raw(pixelclock,
|
||||
sega315_5124_device::WIDTH,
|
||||
sega315_5124_device::LBORDER_START + sega315_5124_device::LBORDER_WIDTH - 2,
|
||||
sega315_5124_device::LBORDER_START + sega315_5124_device::LBORDER_WIDTH + 256 + 10,
|
||||
@ -566,7 +566,7 @@ void sms_state::screen_sms_ntsc_raw_params(screen_device &screen, X &&pixelclock
|
||||
template <typename X>
|
||||
void gamegear_state::screen_gg_raw_params(screen_device &screen, X &&pixelclock)
|
||||
{
|
||||
screen.set_raw(std::forward<X>(pixelclock),
|
||||
screen.set_raw(pixelclock,
|
||||
sega315_5124_device::WIDTH,
|
||||
sega315_5124_device::LBORDER_START + sega315_5124_device::LBORDER_WIDTH + 6*8,
|
||||
sega315_5124_device::LBORDER_START + sega315_5124_device::LBORDER_WIDTH + 26*8,
|
||||
|
@ -53,7 +53,7 @@ public:
|
||||
float aspect() const { return m_aspect; }
|
||||
float pixel_aspect() const { return m_aspect / (float(m_pos_size.width()) / float(m_pos_size.height())); }
|
||||
|
||||
void update_resolution(const int new_width, const int new_height) const { m_pos_size.resize(new_width, new_height); }
|
||||
void update_resolution(const int new_width, const int new_height) { m_pos_size = m_pos_size.resize(new_width, new_height); }
|
||||
void set_aspect(const float a) { m_aspect = a; }
|
||||
bool is_primary() const { return m_is_primary; }
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user