From 4c4bb3181b343f7a7e238ce6cea8fae30bada908 Mon Sep 17 00:00:00 2001 From: Vas Crabb Date: Sun, 14 Apr 2024 08:14:34 +1000 Subject: Fixed a few more class memory access warnings. --- src/devices/machine/ie15.cpp | 2 +- src/mame/midway/midyunit_v.cpp | 19 ++++++++------- src/mame/misc/3do_m.cpp | 4 ++-- src/mame/nintendo/n64_m.cpp | 5 +++- src/mame/nintendo/n64_v.h | 10 ++++---- src/mame/nintendo/n64types.h | 52 +++++++++++++++++++++--------------------- src/mame/nintendo/pokemini.cpp | 26 ++++++++++----------- src/mame/phoenix/phoenix_a.cpp | 6 ++--- src/mame/phoenix/phoenix_a.h | 8 +++---- src/tools/regrep.cpp | 17 +++++++++----- 10 files changed, 79 insertions(+), 70 deletions(-) diff --git a/src/devices/machine/ie15.cpp b/src/devices/machine/ie15.cpp index ee0278801e3..bf8c9294878 100644 --- a/src/devices/machine/ie15.cpp +++ b/src/devices/machine/ie15.cpp @@ -494,7 +494,7 @@ void ie15_device::device_reset() { update_serial(0); - memset(&m_video, 0, sizeof(m_video)); + m_video = decltype(m_video)(); m_kb_ruslat = m_long_beep = m_kb_control = m_kb_data = m_kb_flag0 = 0; m_kb_flag = IE_TRUE; m_kbd_sdv = false; diff --git a/src/mame/midway/midyunit_v.cpp b/src/mame/midway/midyunit_v.cpp index 2e0e979d079..6bcd2d0739a 100644 --- a/src/mame/midway/midyunit_v.cpp +++ b/src/mame/midway/midyunit_v.cpp @@ -58,7 +58,7 @@ VIDEO_START_MEMBER(midyunit_state,common) /* reset DMA state */ memset(m_dma_register, 0, sizeof(m_dma_register)); - memset(&m_dma_state, 0, sizeof(m_dma_state)); + m_dma_state = dma_state_t(); /* register for state saving */ save_item(NAME(m_autoerase_enable)); @@ -272,14 +272,13 @@ void midyunit_state::midyunit_paletteram_w(offs_t offset, uint16_t data, uint16_ void midyunit_state::dma_draw(uint16_t command) { - struct dma_state_t &dma_state = m_dma_state; int dx = (command & 0x10) ? -1 : 1; - int height = dma_state.height; - int width = dma_state.width; + int height = m_dma_state.height; + int width = m_dma_state.width; uint8_t *base = m_gfx_rom; - uint32_t offset = dma_state.offset >> 3; - uint16_t pal = dma_state.palette; - uint16_t color = pal | dma_state.color; + uint32_t offset = m_dma_state.offset >> 3; + uint16_t pal = m_dma_state.palette; + uint16_t color = pal | m_dma_state.color; int x, y; /* we only need the low 4 bits of the command */ @@ -288,14 +287,14 @@ void midyunit_state::dma_draw(uint16_t command) /* loop over the height */ for (y = 0; y < height; y++) { - int tx = dma_state.xpos; - int ty = dma_state.ypos; + int tx = m_dma_state.xpos; + int ty = m_dma_state.ypos; uint32_t o = offset; uint16_t *dest; /* determine Y position */ ty = (ty + y) & 0x1ff; - offset += dma_state.rowbytes; + offset += m_dma_state.rowbytes; /* determine destination pointer */ dest = &m_local_videoram[ty * 512]; diff --git a/src/mame/misc/3do_m.cpp b/src/mame/misc/3do_m.cpp index 8a09ad65e63..1a3d63a80a3 100644 --- a/src/mame/misc/3do_m.cpp +++ b/src/mame/misc/3do_m.cpp @@ -1099,7 +1099,7 @@ uint32_t _3do_state::screen_update(screen_device &screen, bitmap_rgb32 &bitmap, void _3do_state::m_madam_init( void ) { - memset( &m_madam, 0, sizeof(MADAM) ); + m_madam = MADAM(); m_madam.revision = 0x01020000; m_madam.msysbits = 0x51; } @@ -1112,7 +1112,7 @@ void _3do_state::m_slow2_init( void ) void _3do_state::m_clio_init() { - memset( &m_clio, 0, sizeof(CLIO) ); + m_clio = CLIO(); m_clio.screen = m_screen; m_clio.revision = 0x02022000 /* 0x04000000 */; m_clio.unclerev = 0x03800000; diff --git a/src/mame/nintendo/n64_m.cpp b/src/mame/nintendo/n64_m.cpp index 068f64a2ae4..5e012e1d959 100644 --- a/src/mame/nintendo/n64_m.cpp +++ b/src/mame/nintendo/n64_m.cpp @@ -13,6 +13,9 @@ #include "debugger.h" #include "screen.h" +#include + + // device type definition DEFINE_DEVICE_TYPE(N64PERIPH, n64_periphs, "n64_periphs", "N64 Peripheral Chips") @@ -167,7 +170,7 @@ void n64_periphs::device_reset() field = 0; ai_timer->adjust(attotime::never); - memset(ai_fifo, 0, sizeof(ai_fifo)); + std::fill(std::begin(ai_fifo), std::end(ai_fifo), AUDIO_DMA()); ai_fifo_wpos = 0; ai_fifo_rpos = 0; ai_fifo_num = 0; diff --git a/src/mame/nintendo/n64_v.h b/src/mame/nintendo/n64_v.h index 2b9f87bfeae..a05c1e598d3 100644 --- a/src/mame/nintendo/n64_v.h +++ b/src/mame/nintendo/n64_v.h @@ -1,11 +1,13 @@ // license:BSD-3-Clause // copyright-holders:Ryan Holtz -#ifndef _VIDEO_N64_H_ -#define _VIDEO_N64_H_ +#ifndef MAME_NINTENDO_N64_V_H +#define MAME_NINTENDO_N64_V_H #include "video/poly.h" #include "pin64.h" +#include + /*****************************************************************************/ #define PIXEL_SIZE_4BIT 0 @@ -150,7 +152,7 @@ public: m_norm_slope_rom[i] = (normslope[(i << 1) + 1] << 8) | normslope[i << 1]; } - memset(m_tiles, 0, 8 * sizeof(n64_tile_t)); + std::fill(std::begin(m_tiles), std::end(m_tiles), n64_tile_t()); memset(m_cmd_data, 0, sizeof(m_cmd_data)); for (int32_t i = 0; i < 8; i++) @@ -396,4 +398,4 @@ public: bool dolog; }; -#endif // _VIDEO_N64_H_ +#endif // MAME_NINTENDO_N64_V_H diff --git a/src/mame/nintendo/n64types.h b/src/mame/nintendo/n64types.h index 6c99aec4e68..d2a800a163e 100644 --- a/src/mame/nintendo/n64types.h +++ b/src/mame/nintendo/n64types.h @@ -113,27 +113,27 @@ enum struct n64_tile_t { - int32_t format; // Image data format: RGBA, YUV, CI, IA, I - int32_t size; // Size of texel element: 4b, 8b, 16b, 32b - int32_t line; // Size of tile line in bytes - int32_t tmem; // Starting tmem address for this tile in bytes - int32_t palette; // Palette number for 4b CI texels - int32_t ct, mt, cs, ms; // Clamp / mirror enable bits for S / T direction - int32_t mask_t, shift_t, mask_s, shift_s; // Mask values / LOD shifts - int32_t lshift_s, rshift_s, lshift_t, rshift_t; - int32_t wrapped_mask_s, wrapped_mask_t; - bool clamp_s, clamp_t; - rgbaint_t mm, invmm; - rgbaint_t wrapped_mask; - rgbaint_t mask; - rgbaint_t invmask; - rgbaint_t lshift; - rgbaint_t rshift; - rgbaint_t sth; - rgbaint_t stl; - rgbaint_t clamp_st; - uint16_t sl, tl, sh, th; // 10.2 fixed-point, starting and ending texel row / column - int32_t num; + int32_t format = 0; // Image data format: RGBA, YUV, CI, IA, I + int32_t size = 0; // Size of texel element: 4b, 8b, 16b, 32b + int32_t line = 0; // Size of tile line in bytes + int32_t tmem = 0; // Starting tmem address for this tile in bytes + int32_t palette = 0; // Palette number for 4b CI texels + int32_t ct = 0, mt = 0, cs = 0, ms = 0; // Clamp / mirror enable bits for S / T direction + int32_t mask_t = 0, shift_t = 0, mask_s = 0, shift_s = 0; // Mask values / LOD shifts + int32_t lshift_s = 0, rshift_s = 0, lshift_t = 0, rshift_t = 0; + int32_t wrapped_mask_s = 0, wrapped_mask_t = 0; + bool clamp_s = false, clamp_t = false; + rgbaint_t mm = { 0, 0, 0, 0 }, invmm = { 0, 0, 0, 0 }; + rgbaint_t wrapped_mask = { 0, 0, 0, 0 }; + rgbaint_t mask = { 0, 0, 0, 0 }; + rgbaint_t invmask = { 0, 0, 0, 0 }; + rgbaint_t lshift = { 0, 0, 0, 0 }; + rgbaint_t rshift = { 0, 0, 0, 0 }; + rgbaint_t sth = { 0, 0, 0, 0 }; + rgbaint_t stl = { 0, 0, 0, 0 }; + rgbaint_t clamp_st = { 0, 0, 0, 0 }; + uint16_t sl = 0, tl = 0, sh = 0, th = 0; // 10.2 fixed-point, starting and ending texel row / column + int32_t num = 0; }; struct span_base_t @@ -255,10 +255,10 @@ struct rdp_poly_state other_modes_t m_other_modes; /* miscellaneous rasterizer bits (2) */ span_base_t m_span_base; /* span initial values for triangle rasterization */ rectangle_t m_scissor; /* screen-space scissor bounds */ - uint32_t m_fill_color; /* poly fill color */ + uint32_t m_fill_color; /* poly fill color */ n64_tile_t m_tiles[8]; /* texture tile state */ - uint8_t m_tmem[0x1000]; /* texture cache */ - int32_t tilenum; /* texture tile index */ + uint8_t m_tmem[0x1000]; /* texture cache */ + int32_t tilenum; /* texture tile index */ bool flip; /* left-major / right-major flip */ bool rect; /* primitive is rectangle (vs. triangle) */ }; @@ -268,8 +268,8 @@ struct rdp_poly_state // This is enormous and horrible struct rdp_span_aux { - uint32_t m_unscissored_rx; - uint16_t m_cvg[RDP_CVG_SPAN_MAX]; + uint32_t m_unscissored_rx; + uint16_t m_cvg[RDP_CVG_SPAN_MAX]; color_t m_memory_color; color_t m_pixel_color; color_t m_inv_pixel_color; diff --git a/src/mame/nintendo/pokemini.cpp b/src/mame/nintendo/pokemini.cpp index 2581451d814..5b44119606a 100644 --- a/src/mame/nintendo/pokemini.cpp +++ b/src/mame/nintendo/pokemini.cpp @@ -46,17 +46,17 @@ protected: private: struct PRC { - uint8_t colors_inverted = 0; - uint8_t background_enabled = 0; - uint8_t sprites_enabled = 0; - uint8_t copy_enabled = 0; - uint8_t map_size = 0; - uint8_t map_size_x = 0; - uint8_t frame_count = 0; - uint8_t max_frame_count = 0; - uint32_t bg_tiles = 0; - uint32_t spr_tiles = 0; - uint8_t count = 0; + uint8_t colors_inverted = 0; + uint8_t background_enabled = 0; + uint8_t sprites_enabled = 0; + uint8_t copy_enabled = 0; + uint8_t map_size = 0; + uint8_t map_size_x = 0; + uint8_t frame_count = 0; + uint8_t max_frame_count = 0; + uint32_t bg_tiles = 0; + uint32_t spr_tiles = 0; + uint8_t count = 0; emu_timer *count_timer = nullptr; }; @@ -1651,8 +1651,8 @@ TIMER_CALLBACK_MEMBER(pokemini_state::prc_counter_callback) void pokemini_state::machine_start() { /* Clear internal structures */ - memset( &m_prc, 0, sizeof(m_prc) ); - memset( &m_timers, 0, sizeof(m_timers) ); + m_prc = PRC(); + m_timers = TIMERS(); memset( m_pm_reg, 0, sizeof(m_pm_reg) ); /* Set up timers */ diff --git a/src/mame/phoenix/phoenix_a.cpp b/src/mame/phoenix/phoenix_a.cpp index 1008a61539c..0f24cd62de4 100644 --- a/src/mame/phoenix/phoenix_a.cpp +++ b/src/mame/phoenix/phoenix_a.cpp @@ -68,9 +68,9 @@ void phoenix_sound_device::device_start() uint32_t shiftreg; m_sound_latch_a = 0; - memset(&m_c24_state, 0, sizeof(m_c24_state)); - memset(&m_c25_state, 0, sizeof(m_c25_state)); - memset(&m_noise_state, 0, sizeof(m_noise_state)); + m_c24_state = c_state(); + m_c25_state = c_state(); + m_noise_state = n_state(); m_poly18 = std::make_unique(1ul << (18-5)); diff --git a/src/mame/phoenix/phoenix_a.h b/src/mame/phoenix/phoenix_a.h index 3738de54b8f..389ec20ca71 100644 --- a/src/mame/phoenix/phoenix_a.h +++ b/src/mame/phoenix/phoenix_a.h @@ -41,10 +41,10 @@ private: }; // internal state - struct c_state m_c24_state; - struct c_state m_c25_state; - struct n_state m_noise_state; - uint8_t m_sound_latch_a = 0; + c_state m_c24_state; + c_state m_c25_state; + n_state m_noise_state; + uint8_t m_sound_latch_a = 0; sound_stream * m_channel = nullptr; std::unique_ptr m_poly18; required_device m_discrete; diff --git a/src/tools/regrep.cpp b/src/tools/regrep.cpp index 21254acfe3c..316ef805f5a 100644 --- a/src/tools/regrep.cpp +++ b/src/tools/regrep.cpp @@ -14,6 +14,7 @@ #include "osdcomm.h" +#include #include #include #include @@ -67,8 +68,8 @@ struct summary_file summary_file * next; char name[20]; char source[100]; - uint8_t status[MAX_COMPARES]; - uint8_t matchbitmap[MAX_COMPARES]; + uint8_t status[MAX_COMPARES]; + uint8_t matchbitmap[MAX_COMPARES]; std::string text[MAX_COMPARES]; }; @@ -290,7 +291,7 @@ int main(int argc, char *argv[]) static summary_file *get_file(const char *filename) { - summary_file *file; + summary_file *file = nullptr; /* use the first two characters as a lookup */ for (file = filehash[filename[0] & 0x7f][filename[1] & 0x7f]; file != nullptr; file = file->next) @@ -298,10 +299,14 @@ static summary_file *get_file(const char *filename) return file; /* didn't find one -- allocate */ - file = (summary_file *)malloc(sizeof(*file)); + file = new (std::nothrow) summary_file; if (file == nullptr) return nullptr; - memset(file, 0, sizeof(*file)); + file->next = nullptr; + std::fill(std::begin(file->name), std::end(file->name), '\0'); + std::fill(std::begin(file->source), std::end(file->source), '\0'); + std::fill(std::begin(file->status), std::end(file->status), 0); + std::fill(std::begin(file->matchbitmap), std::end(file->matchbitmap), 0); /* set the name so we find it in the future */ strcpy(file->name, filename); @@ -510,7 +515,7 @@ static int CLIB_DECL compare_file(const void *file0ptr, const void *file1ptr) into a single, sorted list -------------------------------------------------*/ -static summary_file *sort_file_list(void) +static summary_file *sort_file_list() { summary_file *listhead, **tailptr, *curfile, **filearray; int numfiles, filenum; -- cgit v1.2.3