Fixed a few class memory access warnings.

This commit is contained in:
Vas Crabb 2024-04-14 06:54:27 +10:00
parent c0d5bbe961
commit 7662be246f
10 changed files with 116 additions and 109 deletions

View File

@ -336,7 +336,8 @@ render_texture::render_texture()
m_curseq(0)
{
m_sbounds.set(0, -1, 0, -1);
memset(m_scaled, 0, sizeof(m_scaled));
for (auto &elem : m_scaled)
elem.seqid = 0;
}

View File

@ -76,10 +76,12 @@ void write_escaped(core_file &file, std::string const &str)
struct parse_info
{
parse_info() { memset(&parser, 0, sizeof(parser)); }
XML_Parser parser;
file::ptr rootnode;
data_node * curnode;
uint32_t flags;
data_node * curnode = nullptr;
uint32_t flags = 0;
};
@ -813,7 +815,7 @@ std::string normalize_string(std::string_view string)
static bool expat_setup_parser(parse_info &info, parse_options const *opts)
{
// setup info structure
memset(&info, 0, sizeof(info));
info = parse_info();
if (opts != nullptr)
{
info.flags = opts->flags;

View File

@ -15,6 +15,7 @@
#include "formats/atari_dsk.h"
#include <algorithm>
#include <cctype>
#include <cstdarg>
@ -741,8 +742,8 @@ static const floppy_interface atari_floppy_interface =
DEFINE_DEVICE_TYPE(ATARI_FDC, atari_fdc_device, "atari_fdc", "Atari FDC")
atari_fdc_device::atari_fdc_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock)
: device_t(mconfig, ATARI_FDC, tag, owner, clock),
atari_fdc_device::atari_fdc_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) :
device_t(mconfig, ATARI_FDC, tag, owner, clock),
m_floppy(*this, "floppy%u", 0U),
m_pokey(*this, "^pokey"),
m_pia(*this, "^pia"),
@ -763,9 +764,10 @@ atari_fdc_device::atari_fdc_device(const machine_config &mconfig, const char *ta
void atari_fdc_device::device_start()
{
memset(m_serout_buff, 0, sizeof(m_serout_buff));
memset(m_serin_buff, 0, sizeof(m_serin_buff));
memset(m_drv, 0, sizeof(m_drv));
std::fill(std::begin(m_serout_buff), std::end(m_serout_buff), 0);
std::fill(std::begin(m_serin_buff), std::end(m_serin_buff), 0);
for (auto &drv : m_drv)
drv = atari_drive();
for (auto &floppy : m_floppy)
floppy->floppy_install_load_proc(_atari_load_proc);

View File

@ -37,17 +37,17 @@ private:
struct atari_drive
{
std::unique_ptr<uint8_t[]> image; /* alloc'd image */
int type; /* type of image (XFD, ATR, DSK) */
int mode; /* 0 read only, != 0 read/write */
int density; /* 0 SD, 1 MD, 2 DD */
int header_skip; /* number of bytes in format header */
int tracks; /* number of tracks (35,40,77,80) */
int heads; /* number of heads (1,2) */
int spt; /* sectors per track (18,26) */
int seclen; /* sector length (128,256) */
int bseclen; /* boot sector length (sectors 1..3) */
int sectors; /* total sectors, ie. tracks x heads x spt */
std::unique_ptr<uint8_t[]> image; // alloc'd image
int type = 0; // type of image (XFD, ATR, DSK)
int mode = 0; // 0 read only, != 0 read/write
int density = 0; // 0 SD, 1 MD, 2 DD
int header_skip = 0; // number of bytes in format header
int tracks = 0; // number of tracks (35,40,77,80)
int heads = 0; // number of heads (1,2)
int spt = 0; // sectors per track (18,26)
int seclen = 0; // sector length (128,256)
int bseclen = 0; // boot sector length (sectors 1..3)
int sectors = 0; // total sectors, ie. tracks x heads x spt
};
required_device_array<legacy_floppy_image_device, 4> m_floppy;

View File

@ -1320,7 +1320,7 @@ TIM_BORROWOUT EQU %00000001
void lynx_state::timer_init(int which)
{
memset(&m_timer[which], 0, sizeof(LYNX_TIMER));
m_timer[which] = LYNX_TIMER();
m_timer[which].timer = timer_alloc(FUNC(lynx_state::timer_shot), this);
save_item(NAME(m_timer[which].bakup), which);
@ -1557,7 +1557,7 @@ void lynx_state::update_screen_timing()
void lynx_state::uart_reset()
{
memset(&m_uart, 0, sizeof(m_uart));
m_uart = UART();
}
TIMER_CALLBACK_MEMBER(lynx_state::uart_loopback_timer)
@ -1879,8 +1879,8 @@ void lynx_state::machine_reset()
m_maincpu->set_input_line(INPUT_LINE_HALT, CLEAR_LINE);
m_maincpu->set_input_line(M65SC02_IRQ_LINE, CLEAR_LINE);
memset(&m_suzy, 0, sizeof(m_suzy));
memset(&m_mikey, 0, sizeof(m_mikey));
m_suzy = SUZY();
m_mikey = MIKEY();
m_suzy.data[0x88] = 0x01;
m_suzy.data[0x90] = 0x00;

View File

@ -155,14 +155,14 @@ union ADDR_REG
};
/* Blitter register flag bits */
#define CMD_RUN 0x01
#define CMD_COLST 0x02
#define CMD_PARRD 0x04 /* Never used? */
#define CMD_SRCUP 0x08
#define CMD_DSTUP 0x10
#define CMD_LT0 0x20
#define CMD_LT1 0x40
#define CMD_LINEDRAW 0x80
static constexpr uint8_t CMD_RUN = 0x01;
static constexpr uint8_t CMD_COLST = 0x02;
static constexpr uint8_t CMD_PARRD = 0x04; /* Never used? */
static constexpr uint8_t CMD_SRCUP = 0x08;
static constexpr uint8_t CMD_DSTUP = 0x10;
static constexpr uint8_t CMD_LT0 = 0x20;
static constexpr uint8_t CMD_LT1 = 0x40;
static constexpr uint8_t CMD_LINEDRAW = 0x80;
/* All unconfirmed */
@ -172,20 +172,20 @@ union ADDR_REG
#define SRCDST_A_1 0x80 /* This might be correct for line drawing? */
/* These appear to be correct */
#define MODE_SSIGN 0x80
#define MODE_DSIGN 0x40
#define MODE_YFRAC 0x20
#define MODE_BITTOBYTE 0x04
#define MODE_PALREMAP 0x10
static constexpr uint8_t MODE_SSIGN = 0x80;
static constexpr uint8_t MODE_DSIGN = 0x40;
static constexpr uint8_t MODE_YFRAC = 0x20;
static constexpr uint8_t MODE_BITTOBYTE = 0x04;
static constexpr uint8_t MODE_PALREMAP = 0x10;
#define CMPFUNC_LT 0x01
#define CMPFUNC_EQ 0x02
#define CMPFUNC_GT 0x04
#define CMPFUNC_BEQ 0x08
#define CMPFUNC_LOG0 0x10
#define CMPFUNC_LOG1 0x20
#define CMPFUNC_LOG2 0x40
#define CMPFUNC_LOG3 0x80
static constexpr uint8_t CMPFUNC_LT = 0x01;
static constexpr uint8_t CMPFUNC_EQ = 0x02;
static constexpr uint8_t CMPFUNC_GT = 0x04;
static constexpr uint8_t CMPFUNC_BEQ = 0x08;
static constexpr uint8_t CMPFUNC_LOG0 = 0x10;
static constexpr uint8_t CMPFUNC_LOG1 = 0x20;
static constexpr uint8_t CMPFUNC_LOG2 = 0x40;
static constexpr uint8_t CMPFUNC_LOG3 = 0x80;
/*
Blitter state
@ -194,26 +194,26 @@ struct bf_blitter_t
{
ADDR_REG program;
uint8_t control = 0;
uint8_t status = 0;
uint8_t control = 0;
uint8_t status = 0;
uint8_t command = 0;
uint8_t command = 0;
ADDR_REG source;
ADDR_REG dest;
uint8_t modectl = 0;
uint8_t compfunc = 0;
uint8_t outercnt = 0;
uint8_t modectl = 0;
uint8_t compfunc = 0;
uint8_t outercnt = 0;
uint8_t innercnt = 0;
uint8_t step = 0;
uint8_t pattern = 0;
uint8_t innercnt = 0;
uint8_t step = 0;
uint8_t pattern = 0;
};
#define LOOPTYPE ( ( blitter.command&0x60 ) >> 5 )
struct fdc_t
{
uint8_t MSR = 0;
uint8_t MSR = 0;
int side = 0;
int track = 0;
@ -231,8 +231,8 @@ struct fdc_t
int cmd_cnt = 0;
int res_len = 0;
int res_cnt = 0;
uint8_t cmd[10]{};
uint8_t results[8]{};
uint8_t cmd[10]{};
uint8_t results[8]{};
};
@ -304,7 +304,7 @@ protected:
void reset_fdc();
void exec_w_phase(uint8_t data);
void init_ram();
void command_phase(struct fdc_t &fdc, uint8_t data);
void command_phase(fdc_t &fdc, uint8_t data);
inline uint8_t* blitter_get_addr(uint32_t addr);
inline void z80_bank(int num, int data);
@ -339,7 +339,7 @@ private:
uint8_t m_col7bit[256]{};
uint8_t m_col6bit[256]{};
struct bf_blitter_t m_blitter;
struct fdc_t m_fdc;
fdc_t m_fdc;
required_device<cpu_device> m_maincpu;
required_device<cpu_device> m_audiocpu;
required_device<acia6850_device> m_acia6850_0;
@ -1058,7 +1058,7 @@ enum command
void bfcobra_state::reset_fdc()
{
memset(&m_fdc, 0, sizeof(m_fdc));
m_fdc = fdc_t();
m_fdc.MSR = 0x80;
m_fdc.phase = COMMAND;
@ -1075,71 +1075,70 @@ uint8_t bfcobra_state::fdctrl_r()
uint8_t bfcobra_state::fddata_r()
{
struct fdc_t &fdc = m_fdc;
#define BPS 1024
#define SPT 10
#define BPT 1024*10
constexpr int BPS = 1024;
constexpr int SPT = 10;
constexpr int BPT = BPS * SPT;
uint8_t val = 0;
if (fdc.phase == EXECUTION_R)
if (m_fdc.phase == EXECUTION_R)
{
switch (fdc.cmd[0] & 0x1f)
switch (m_fdc.cmd[0] & 0x1f)
{
/* Specify */
case READ_DATA:
{
if (fdc.setup_read)
if (m_fdc.setup_read)
{
fdc.track = fdc.cmd[2];
fdc.side = fdc.cmd[3];
fdc.sector = fdc.cmd[4];
fdc.number = fdc.cmd[5];
fdc.stop_track = fdc.cmd[6];
//int GPL = fdc.cmd[7];
//int DTL = fdc.cmd[8];
m_fdc.track = m_fdc.cmd[2];
m_fdc.side = m_fdc.cmd[3];
m_fdc.sector = m_fdc.cmd[4];
m_fdc.number = m_fdc.cmd[5];
m_fdc.stop_track = m_fdc.cmd[6];
//int GPL = m_fdc.cmd[7];
//int DTL = m_fdc.cmd[8];
fdc.setup_read = 0;
fdc.byte_pos = 0;
m_fdc.setup_read = 0;
m_fdc.byte_pos = 0;
}
fdc.offset = (BPT * fdc.track*2) + (fdc.side ? BPT : 0) + (BPS * (fdc.sector-1)) + fdc.byte_pos++;
val = *(memregion("user2")->base() + fdc.offset);
m_fdc.offset = (BPT * m_fdc.track*2) + (m_fdc.side ? BPT : 0) + (BPS * (m_fdc.sector-1)) + m_fdc.byte_pos++;
val = *(memregion("user2")->base() + m_fdc.offset);
/* Move on to next sector? */
if (fdc.byte_pos == 1024)
if (m_fdc.byte_pos == 1024)
{
fdc.byte_pos = 0;
m_fdc.byte_pos = 0;
if (fdc.sector == fdc.stop_track || ++fdc.sector == 11)
if (m_fdc.sector == m_fdc.stop_track || ++m_fdc.sector == 11)
{
/* End of read operation */
fdc.MSR = 0xd0;
fdc.phase = RESULTS;
m_fdc.MSR = 0xd0;
m_fdc.phase = RESULTS;
fdc.results[0] = 0;
fdc.results[1] = 0;
fdc.results[2] = 0;
m_fdc.results[0] = 0;
m_fdc.results[1] = 0;
m_fdc.results[2] = 0;
fdc.results[3] = 0;
fdc.results[4] = 0;
fdc.results[5] = 0;
fdc.results[6] = 0;
m_fdc.results[3] = 0;
m_fdc.results[4] = 0;
m_fdc.results[5] = 0;
m_fdc.results[6] = 0;
}
}
break;
}
}
}
else if (fdc.phase == RESULTS)
else if (m_fdc.phase == RESULTS)
{
val = fdc.results[fdc.res_cnt++];
val = m_fdc.results[m_fdc.res_cnt++];
if (fdc.res_cnt == fdc.res_len)
if (m_fdc.res_cnt == m_fdc.res_len)
{
fdc.phase = COMMAND;
fdc.res_cnt = 0;
fdc.MSR &= ~0x40;
m_fdc.phase = COMMAND;
m_fdc.res_cnt = 0;
m_fdc.MSR &= ~0x40;
}
}
@ -1148,12 +1147,11 @@ uint8_t bfcobra_state::fddata_r()
void bfcobra_state::fdctrl_w(uint8_t data)
{
struct fdc_t &fdc = m_fdc;
switch (fdc.phase)
switch (m_fdc.phase)
{
case COMMAND:
{
command_phase(fdc, data);
command_phase(m_fdc, data);
break;
}
case EXECUTION_W:
@ -1168,7 +1166,7 @@ void bfcobra_state::fdctrl_w(uint8_t data)
}
}
void bfcobra_state::command_phase(struct fdc_t &fdc, uint8_t data)
void bfcobra_state::command_phase(fdc_t &fdc, uint8_t data)
{
if (fdc.cmd_cnt == 0)
{

View File

@ -35,6 +35,8 @@
#include "softlist_dev.h"
#include "speaker.h"
#include <algorithm>
/***************************************************************************
T6834 IMPLEMENTATION
@ -1447,10 +1449,12 @@ void x07_state::machine_reset()
memset(m_regs_r, 0, sizeof(m_regs_r));
memset(m_regs_w, 0, sizeof(m_regs_w));
memset(m_alarm, 0, sizeof(m_alarm));
memset(&m_in, 0, sizeof(m_in));
memset(&m_out, 0, sizeof(m_out));
memset(&m_locate, 0, sizeof(m_locate));
memset(&m_cursor, 0, sizeof(m_cursor));
std::fill(std::begin(m_in.data), std::end(m_in.data), 0);
m_in.read = m_in.write = 0;
std::fill(std::begin(m_out.data), std::end(m_out.data), 0);
m_out.read = m_out.write = 0;
m_locate = lcd_position();
m_cursor = lcd_position();
memset(m_prn_buffer, 0, sizeof(m_prn_buffer));
memset(m_lcd_map, 0, sizeof(m_lcd_map));

View File

@ -335,7 +335,8 @@ void esq1_filters::recalc_filter(filter &f)
void esq1_filters::device_start()
{
stream = stream_alloc(8, 2, 44100);
memset(filters, 0, sizeof(filters));
for(auto & elem : filters)
elem = filter();
for(auto & elem : filters)
recalc_filter(elem);
}
@ -389,8 +390,8 @@ namespace {
class esq1_state : public driver_device
{
public:
esq1_state(const machine_config &mconfig, device_type type, const char *tag)
: driver_device(mconfig, type, tag),
esq1_state(const machine_config &mconfig, device_type type, const char *tag) :
driver_device(mconfig, type, tag),
m_maincpu(*this, "maincpu"),
m_duart(*this, "duart"),
m_filters(*this, "filters"),

View File

@ -219,7 +219,7 @@ void pasogo_state::machine_start()
{
system_time systime;
memset(&m_vg230, 0, sizeof(m_vg230));
m_vg230 = decltype(m_vg230)();
m_vg230.pmu.write_protected = true;
machine().base_datetime(systime);

View File

@ -81,7 +81,6 @@ private:
bool automap_nmi_instant_on() const noexcept;
bool automap_nmi_delayed_on() const noexcept;
bool automap() const noexcept;
};
DECLARE_DEVICE_TYPE(SPECNEXT_DIVMMC, specnext_divmmc_device)