From 7bdd411be06ddac07ead3cacc71eb6ce912ebbb7 Mon Sep 17 00:00:00 2001 From: Vas Crabb Date: Thu, 29 Nov 2018 17:00:05 +1100 Subject: use the magic macros in mips.cpp, change signature of stuff in floppy.h to hint that it needs an array, not just a pointer, although it doesn't actually warn if you just give a pointer anyway (nw) --- src/devices/imagedev/floppy.cpp | 8 ++------ src/devices/imagedev/floppy.h | 6 +++--- src/mame/drivers/mips.cpp | 12 ++++++++++-- 3 files changed, 15 insertions(+), 11 deletions(-) diff --git a/src/devices/imagedev/floppy.cpp b/src/devices/imagedev/floppy.cpp index c69e55b7a19..70362e876fb 100644 --- a/src/devices/imagedev/floppy.cpp +++ b/src/devices/imagedev/floppy.cpp @@ -145,7 +145,7 @@ floppy_connector::~floppy_connector() { } -void floppy_connector::set_formats(const floppy_format_type *_formats) +void floppy_connector::set_formats(const floppy_format_type _formats[]) { formats = _formats; } @@ -252,11 +252,7 @@ void floppy_image_device::set_formats(const floppy_format_type *formats) { extension_list[0] = '\0'; fif_list = nullptr; - // FIXME: this code previously treated formats as an array, but none of the actual formats in src/lib/formats provide an array - they all just supply a single function pointer - // This happens to work by chance if the next poitner-sized piece of BSS data happens to be zero, which it is most of the time. - // However, for some reason on a Linux clang 6 build it sometimes isn't, causing a lovely crash here. - // If this is supposed to be a nullptr-terminated array of function pointers, the code needs to be changed to better enforce it. - for(int cnt=0; /*formats[cnt]*/ !cnt; cnt++) + for(int cnt=0; formats[cnt]; cnt++) { // allocate a new format floppy_image_format_t *fif = formats[cnt](); diff --git a/src/devices/imagedev/floppy.h b/src/devices/imagedev/floppy.h index 02879b6af17..51b588bfd3a 100644 --- a/src/devices/imagedev/floppy.h +++ b/src/devices/imagedev/floppy.h @@ -317,7 +317,7 @@ class floppy_connector: public device_t, { public: template - floppy_connector(const machine_config &mconfig, const char *tag, device_t *owner, T &&opts, const char *dflt, const floppy_format_type *formats, bool fixed = false) + floppy_connector(const machine_config &mconfig, const char *tag, device_t *owner, T &&opts, const char *dflt, const floppy_format_type formats[], bool fixed = false) : floppy_connector(mconfig, tag, owner, 0) { option_reset(); @@ -326,7 +326,7 @@ public: set_fixed(fixed); set_formats(formats); } - floppy_connector(const machine_config &mconfig, const char *tag, device_t *owner, const char *option, const device_type &devtype, bool is_default, const floppy_format_type *formats) + floppy_connector(const machine_config &mconfig, const char *tag, device_t *owner, const char *option, const device_type &devtype, bool is_default, const floppy_format_type formats[]) : floppy_connector(mconfig, tag, owner, 0) { option_reset(); @@ -339,7 +339,7 @@ public: floppy_connector(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock = 0); virtual ~floppy_connector(); - void set_formats(const floppy_format_type *formats); + void set_formats(const floppy_format_type formats[]); floppy_image_device *get_device(); void enable_sound(bool doit) { m_enable_sound = doit; } diff --git a/src/mame/drivers/mips.cpp b/src/mame/drivers/mips.cpp index 3ec2c0bf800..d3032b7f1c5 100644 --- a/src/mame/drivers/mips.cpp +++ b/src/mame/drivers/mips.cpp @@ -143,6 +143,14 @@ #define VERBOSE 0 #include "logmacro.h" +namespace { + +FLOPPY_FORMATS_MEMBER(mips_floppy_formats) + FLOPPY_PC_FORMAT +FLOPPY_FORMATS_END + +} // anonymous namespace + void rx2030_state::machine_start() { save_item(NAME(m_mmu)); @@ -479,7 +487,7 @@ void rx2030_state::rx2030(machine_config &config) WD37C65C(config, m_fdc, 16_MHz_XTAL); m_fdc->intrq_wr_callback().set_inputline(m_iop, INPUT_LINE_IRQ6); //m_fdc->drq_wr_callback().set(); - FLOPPY_CONNECTOR(config, "fdc:0", "35hd", FLOPPY_35_HD, true, &FLOPPY_PC_FORMAT).enable_sound(false); + FLOPPY_CONNECTOR(config, "fdc:0", "35hd", FLOPPY_35_HD, true, mips_floppy_formats).enable_sound(false); // scsi bus and devices NSCSI_BUS(config, m_scsibus, 0); @@ -703,7 +711,7 @@ void rx3230_state::rx3230(machine_config &config) I82072(config, m_fdc, 16_MHz_XTAL); m_fdc->intrq_wr_callback().set_inputline(m_cpu, INPUT_LINE_IRQ4); //m_fdc->drq_wr_callback().set(); - FLOPPY_CONNECTOR(config, "fdc:0", "35hd", FLOPPY_35_HD, true, &FLOPPY_PC_FORMAT).enable_sound(false); + FLOPPY_CONNECTOR(config, "fdc:0", "35hd", FLOPPY_35_HD, true, mips_floppy_formats).enable_sound(false); // keyboard pc_kbdc_device &kbdc(PC_KBDC(config, "pc_kbdc", 0)); -- cgit v1.2.3