Skip to content

Commit 7662be2

Browse files
committed
Fixed a few class memory access warnings.
1 parent c0d5bbe commit 7662be2

File tree

10 files changed

+118
-111
lines changed

10 files changed

+118
-111
lines changed

src/emu/render.cpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -336,7 +336,8 @@ render_texture::render_texture()
336336
m_curseq(0)
337337
{
338338
m_sbounds.set(0, -1, 0, -1);
339-
memset(m_scaled, 0, sizeof(m_scaled));
339+
for (auto &elem : m_scaled)
340+
elem.seqid = 0;
340341
}
341342

342343

src/lib/util/xmlfile.cpp

+5-3
Original file line numberDiff line numberDiff line change
@@ -76,10 +76,12 @@ void write_escaped(core_file &file, std::string const &str)
7676

7777
struct parse_info
7878
{
79+
parse_info() { memset(&parser, 0, sizeof(parser)); }
80+
7981
XML_Parser parser;
8082
file::ptr rootnode;
81-
data_node * curnode;
82-
uint32_t flags;
83+
data_node * curnode = nullptr;
84+
uint32_t flags = 0;
8385
};
8486

8587

@@ -813,7 +815,7 @@ std::string normalize_string(std::string_view string)
813815
static bool expat_setup_parser(parse_info &info, parse_options const *opts)
814816
{
815817
// setup info structure
816-
memset(&info, 0, sizeof(info));
818+
info = parse_info();
817819
if (opts != nullptr)
818820
{
819821
info.flags = opts->flags;

src/mame/atari/atarifdc.cpp

+7-5
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515

1616
#include "formats/atari_dsk.h"
1717

18+
#include <algorithm>
1819
#include <cctype>
1920
#include <cstdarg>
2021

@@ -741,8 +742,8 @@ static const floppy_interface atari_floppy_interface =
741742

742743
DEFINE_DEVICE_TYPE(ATARI_FDC, atari_fdc_device, "atari_fdc", "Atari FDC")
743744

744-
atari_fdc_device::atari_fdc_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock)
745-
: device_t(mconfig, ATARI_FDC, tag, owner, clock),
745+
atari_fdc_device::atari_fdc_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) :
746+
device_t(mconfig, ATARI_FDC, tag, owner, clock),
746747
m_floppy(*this, "floppy%u", 0U),
747748
m_pokey(*this, "^pokey"),
748749
m_pia(*this, "^pia"),
@@ -763,9 +764,10 @@ atari_fdc_device::atari_fdc_device(const machine_config &mconfig, const char *ta
763764

764765
void atari_fdc_device::device_start()
765766
{
766-
memset(m_serout_buff, 0, sizeof(m_serout_buff));
767-
memset(m_serin_buff, 0, sizeof(m_serin_buff));
768-
memset(m_drv, 0, sizeof(m_drv));
767+
std::fill(std::begin(m_serout_buff), std::end(m_serout_buff), 0);
768+
std::fill(std::begin(m_serin_buff), std::end(m_serin_buff), 0);
769+
for (auto &drv : m_drv)
770+
drv = atari_drive();
769771

770772
for (auto &floppy : m_floppy)
771773
floppy->floppy_install_load_proc(_atari_load_proc);

src/mame/atari/atarifdc.h

+11-11
Original file line numberDiff line numberDiff line change
@@ -37,17 +37,17 @@ class atari_fdc_device : public device_t
3737

3838
struct atari_drive
3939
{
40-
std::unique_ptr<uint8_t[]> image; /* alloc'd image */
41-
int type; /* type of image (XFD, ATR, DSK) */
42-
int mode; /* 0 read only, != 0 read/write */
43-
int density; /* 0 SD, 1 MD, 2 DD */
44-
int header_skip; /* number of bytes in format header */
45-
int tracks; /* number of tracks (35,40,77,80) */
46-
int heads; /* number of heads (1,2) */
47-
int spt; /* sectors per track (18,26) */
48-
int seclen; /* sector length (128,256) */
49-
int bseclen; /* boot sector length (sectors 1..3) */
50-
int sectors; /* total sectors, ie. tracks x heads x spt */
40+
std::unique_ptr<uint8_t[]> image; // alloc'd image
41+
int type = 0; // type of image (XFD, ATR, DSK)
42+
int mode = 0; // 0 read only, != 0 read/write
43+
int density = 0; // 0 SD, 1 MD, 2 DD
44+
int header_skip = 0; // number of bytes in format header
45+
int tracks = 0; // number of tracks (35,40,77,80)
46+
int heads = 0; // number of heads (1,2)
47+
int spt = 0; // sectors per track (18,26)
48+
int seclen = 0; // sector length (128,256)
49+
int bseclen = 0; // boot sector length (sectors 1..3)
50+
int sectors = 0; // total sectors, ie. tracks x heads x spt
5151
};
5252

5353
required_device_array<legacy_floppy_image_device, 4> m_floppy;

src/mame/atari/lynx_m.cpp

+4-4
Original file line numberDiff line numberDiff line change
@@ -1320,7 +1320,7 @@ TIM_BORROWOUT EQU %00000001
13201320

13211321
void lynx_state::timer_init(int which)
13221322
{
1323-
memset(&m_timer[which], 0, sizeof(LYNX_TIMER));
1323+
m_timer[which] = LYNX_TIMER();
13241324
m_timer[which].timer = timer_alloc(FUNC(lynx_state::timer_shot), this);
13251325

13261326
save_item(NAME(m_timer[which].bakup), which);
@@ -1557,7 +1557,7 @@ void lynx_state::update_screen_timing()
15571557

15581558
void lynx_state::uart_reset()
15591559
{
1560-
memset(&m_uart, 0, sizeof(m_uart));
1560+
m_uart = UART();
15611561
}
15621562

15631563
TIMER_CALLBACK_MEMBER(lynx_state::uart_loopback_timer)
@@ -1879,8 +1879,8 @@ void lynx_state::machine_reset()
18791879
m_maincpu->set_input_line(INPUT_LINE_HALT, CLEAR_LINE);
18801880
m_maincpu->set_input_line(M65SC02_IRQ_LINE, CLEAR_LINE);
18811881

1882-
memset(&m_suzy, 0, sizeof(m_suzy));
1883-
memset(&m_mikey, 0, sizeof(m_mikey));
1882+
m_suzy = SUZY();
1883+
m_mikey = MIKEY();
18841884

18851885
m_suzy.data[0x88] = 0x01;
18861886
m_suzy.data[0x90] = 0x00;

src/mame/bfm/bfcobra.cpp

+76-78
Original file line numberDiff line numberDiff line change
@@ -155,14 +155,14 @@ union ADDR_REG
155155
};
156156

157157
/* Blitter register flag bits */
158-
#define CMD_RUN 0x01
159-
#define CMD_COLST 0x02
160-
#define CMD_PARRD 0x04 /* Never used? */
161-
#define CMD_SRCUP 0x08
162-
#define CMD_DSTUP 0x10
163-
#define CMD_LT0 0x20
164-
#define CMD_LT1 0x40
165-
#define CMD_LINEDRAW 0x80
158+
static constexpr uint8_t CMD_RUN = 0x01;
159+
static constexpr uint8_t CMD_COLST = 0x02;
160+
static constexpr uint8_t CMD_PARRD = 0x04; /* Never used? */
161+
static constexpr uint8_t CMD_SRCUP = 0x08;
162+
static constexpr uint8_t CMD_DSTUP = 0x10;
163+
static constexpr uint8_t CMD_LT0 = 0x20;
164+
static constexpr uint8_t CMD_LT1 = 0x40;
165+
static constexpr uint8_t CMD_LINEDRAW = 0x80;
166166

167167

168168
/* All unconfirmed */
@@ -172,20 +172,20 @@ union ADDR_REG
172172
#define SRCDST_A_1 0x80 /* This might be correct for line drawing? */
173173

174174
/* These appear to be correct */
175-
#define MODE_SSIGN 0x80
176-
#define MODE_DSIGN 0x40
177-
#define MODE_YFRAC 0x20
178-
#define MODE_BITTOBYTE 0x04
179-
#define MODE_PALREMAP 0x10
180-
181-
#define CMPFUNC_LT 0x01
182-
#define CMPFUNC_EQ 0x02
183-
#define CMPFUNC_GT 0x04
184-
#define CMPFUNC_BEQ 0x08
185-
#define CMPFUNC_LOG0 0x10
186-
#define CMPFUNC_LOG1 0x20
187-
#define CMPFUNC_LOG2 0x40
188-
#define CMPFUNC_LOG3 0x80
175+
static constexpr uint8_t MODE_SSIGN = 0x80;
176+
static constexpr uint8_t MODE_DSIGN = 0x40;
177+
static constexpr uint8_t MODE_YFRAC = 0x20;
178+
static constexpr uint8_t MODE_BITTOBYTE = 0x04;
179+
static constexpr uint8_t MODE_PALREMAP = 0x10;
180+
181+
static constexpr uint8_t CMPFUNC_LT = 0x01;
182+
static constexpr uint8_t CMPFUNC_EQ = 0x02;
183+
static constexpr uint8_t CMPFUNC_GT = 0x04;
184+
static constexpr uint8_t CMPFUNC_BEQ = 0x08;
185+
static constexpr uint8_t CMPFUNC_LOG0 = 0x10;
186+
static constexpr uint8_t CMPFUNC_LOG1 = 0x20;
187+
static constexpr uint8_t CMPFUNC_LOG2 = 0x40;
188+
static constexpr uint8_t CMPFUNC_LOG3 = 0x80;
189189

190190
/*
191191
Blitter state
@@ -194,26 +194,26 @@ struct bf_blitter_t
194194
{
195195
ADDR_REG program;
196196

197-
uint8_t control = 0;
198-
uint8_t status = 0;
197+
uint8_t control = 0;
198+
uint8_t status = 0;
199199

200-
uint8_t command = 0;
200+
uint8_t command = 0;
201201
ADDR_REG source;
202202
ADDR_REG dest;
203-
uint8_t modectl = 0;
204-
uint8_t compfunc = 0;
205-
uint8_t outercnt = 0;
203+
uint8_t modectl = 0;
204+
uint8_t compfunc = 0;
205+
uint8_t outercnt = 0;
206206

207-
uint8_t innercnt = 0;
208-
uint8_t step = 0;
209-
uint8_t pattern = 0;
207+
uint8_t innercnt = 0;
208+
uint8_t step = 0;
209+
uint8_t pattern = 0;
210210
};
211211

212212
#define LOOPTYPE ( ( blitter.command&0x60 ) >> 5 )
213213

214214
struct fdc_t
215215
{
216-
uint8_t MSR = 0;
216+
uint8_t MSR = 0;
217217

218218
int side = 0;
219219
int track = 0;
@@ -231,8 +231,8 @@ struct fdc_t
231231
int cmd_cnt = 0;
232232
int res_len = 0;
233233
int res_cnt = 0;
234-
uint8_t cmd[10]{};
235-
uint8_t results[8]{};
234+
uint8_t cmd[10]{};
235+
uint8_t results[8]{};
236236
};
237237

238238

@@ -304,7 +304,7 @@ class bfcobra_state : public driver_device
304304
void reset_fdc();
305305
void exec_w_phase(uint8_t data);
306306
void init_ram();
307-
void command_phase(struct fdc_t &fdc, uint8_t data);
307+
void command_phase(fdc_t &fdc, uint8_t data);
308308
inline uint8_t* blitter_get_addr(uint32_t addr);
309309
inline void z80_bank(int num, int data);
310310

@@ -339,7 +339,7 @@ class bfcobra_state : public driver_device
339339
uint8_t m_col7bit[256]{};
340340
uint8_t m_col6bit[256]{};
341341
struct bf_blitter_t m_blitter;
342-
struct fdc_t m_fdc;
342+
fdc_t m_fdc;
343343
required_device<cpu_device> m_maincpu;
344344
required_device<cpu_device> m_audiocpu;
345345
required_device<acia6850_device> m_acia6850_0;
@@ -1058,7 +1058,7 @@ enum command
10581058

10591059
void bfcobra_state::reset_fdc()
10601060
{
1061-
memset(&m_fdc, 0, sizeof(m_fdc));
1061+
m_fdc = fdc_t();
10621062

10631063
m_fdc.MSR = 0x80;
10641064
m_fdc.phase = COMMAND;
@@ -1075,71 +1075,70 @@ uint8_t bfcobra_state::fdctrl_r()
10751075

10761076
uint8_t bfcobra_state::fddata_r()
10771077
{
1078-
struct fdc_t &fdc = m_fdc;
1079-
#define BPS 1024
1080-
#define SPT 10
1081-
#define BPT 1024*10
1078+
constexpr int BPS = 1024;
1079+
constexpr int SPT = 10;
1080+
constexpr int BPT = BPS * SPT;
10821081

10831082
uint8_t val = 0;
10841083

1085-
if (fdc.phase == EXECUTION_R)
1084+
if (m_fdc.phase == EXECUTION_R)
10861085
{
1087-
switch (fdc.cmd[0] & 0x1f)
1086+
switch (m_fdc.cmd[0] & 0x1f)
10881087
{
10891088
/* Specify */
10901089
case READ_DATA:
10911090
{
1092-
if (fdc.setup_read)
1091+
if (m_fdc.setup_read)
10931092
{
1094-
fdc.track = fdc.cmd[2];
1095-
fdc.side = fdc.cmd[3];
1096-
fdc.sector = fdc.cmd[4];
1097-
fdc.number = fdc.cmd[5];
1098-
fdc.stop_track = fdc.cmd[6];
1099-
//int GPL = fdc.cmd[7];
1100-
//int DTL = fdc.cmd[8];
1101-
1102-
fdc.setup_read = 0;
1103-
fdc.byte_pos = 0;
1093+
m_fdc.track = m_fdc.cmd[2];
1094+
m_fdc.side = m_fdc.cmd[3];
1095+
m_fdc.sector = m_fdc.cmd[4];
1096+
m_fdc.number = m_fdc.cmd[5];
1097+
m_fdc.stop_track = m_fdc.cmd[6];
1098+
//int GPL = m_fdc.cmd[7];
1099+
//int DTL = m_fdc.cmd[8];
1100+
1101+
m_fdc.setup_read = 0;
1102+
m_fdc.byte_pos = 0;
11041103
}
11051104

1106-
fdc.offset = (BPT * fdc.track*2) + (fdc.side ? BPT : 0) + (BPS * (fdc.sector-1)) + fdc.byte_pos++;
1107-
val = *(memregion("user2")->base() + fdc.offset);
1105+
m_fdc.offset = (BPT * m_fdc.track*2) + (m_fdc.side ? BPT : 0) + (BPS * (m_fdc.sector-1)) + m_fdc.byte_pos++;
1106+
val = *(memregion("user2")->base() + m_fdc.offset);
11081107

11091108
/* Move on to next sector? */
1110-
if (fdc.byte_pos == 1024)
1109+
if (m_fdc.byte_pos == 1024)
11111110
{
1112-
fdc.byte_pos = 0;
1111+
m_fdc.byte_pos = 0;
11131112

1114-
if (fdc.sector == fdc.stop_track || ++fdc.sector == 11)
1113+
if (m_fdc.sector == m_fdc.stop_track || ++m_fdc.sector == 11)
11151114
{
11161115
/* End of read operation */
1117-
fdc.MSR = 0xd0;
1118-
fdc.phase = RESULTS;
1116+
m_fdc.MSR = 0xd0;
1117+
m_fdc.phase = RESULTS;
11191118

1120-
fdc.results[0] = 0;
1121-
fdc.results[1] = 0;
1122-
fdc.results[2] = 0;
1119+
m_fdc.results[0] = 0;
1120+
m_fdc.results[1] = 0;
1121+
m_fdc.results[2] = 0;
11231122

1124-
fdc.results[3] = 0;
1125-
fdc.results[4] = 0;
1126-
fdc.results[5] = 0;
1127-
fdc.results[6] = 0;
1123+
m_fdc.results[3] = 0;
1124+
m_fdc.results[4] = 0;
1125+
m_fdc.results[5] = 0;
1126+
m_fdc.results[6] = 0;
11281127
}
11291128
}
11301129
break;
11311130
}
11321131
}
11331132
}
1134-
else if (fdc.phase == RESULTS)
1133+
else if (m_fdc.phase == RESULTS)
11351134
{
1136-
val = fdc.results[fdc.res_cnt++];
1135+
val = m_fdc.results[m_fdc.res_cnt++];
11371136

1138-
if (fdc.res_cnt == fdc.res_len)
1137+
if (m_fdc.res_cnt == m_fdc.res_len)
11391138
{
1140-
fdc.phase = COMMAND;
1141-
fdc.res_cnt = 0;
1142-
fdc.MSR &= ~0x40;
1139+
m_fdc.phase = COMMAND;
1140+
m_fdc.res_cnt = 0;
1141+
m_fdc.MSR &= ~0x40;
11431142
}
11441143
}
11451144

@@ -1148,12 +1147,11 @@ uint8_t bfcobra_state::fddata_r()
11481147

11491148
void bfcobra_state::fdctrl_w(uint8_t data)
11501149
{
1151-
struct fdc_t &fdc = m_fdc;
1152-
switch (fdc.phase)
1150+
switch (m_fdc.phase)
11531151
{
11541152
case COMMAND:
11551153
{
1156-
command_phase(fdc, data);
1154+
command_phase(m_fdc, data);
11571155
break;
11581156
}
11591157
case EXECUTION_W:
@@ -1168,7 +1166,7 @@ void bfcobra_state::fdctrl_w(uint8_t data)
11681166
}
11691167
}
11701168

1171-
void bfcobra_state::command_phase(struct fdc_t &fdc, uint8_t data)
1169+
void bfcobra_state::command_phase(fdc_t &fdc, uint8_t data)
11721170
{
11731171
if (fdc.cmd_cnt == 0)
11741172
{

0 commit comments

Comments
 (0)