From c7946fbce79022147b5b0c93fde6e5b29c4e4197 Mon Sep 17 00:00:00 2001 From: waltje Date: Sun, 10 Dec 2017 02:53:10 -0500 Subject: [PATCH] Fix logging issues. --- src/86box.h | 9 ++++++--- src/cdrom/cdrom.c | 9 +++++---- src/disk/hdc_ide.c | 9 +++++---- src/disk/hdc_mfm_at.c | 2 +- src/disk/hdd_image.c | 9 +++++---- src/floppy/fdc.c | 5 +++-- src/floppy/floppy_86f.c | 9 +++++---- src/network/net_ne2000.c | 11 +++++------ src/pc.c | 21 ++++++++++++++++----- src/pci.c | 7 ++++--- src/scsi/scsi_aha154x.c | 5 +++-- src/scsi/scsi_bus.c | 9 +++++---- src/scsi/scsi_buslogic.c | 9 +++++---- src/scsi/scsi_disk.c | 9 +++++---- src/scsi/scsi_ncr5380.c | 5 +++-- src/scsi/scsi_x54x.c | 5 +++-- src/sound/snd_audiopci.c | 7 ++++--- src/sound/snd_emu8k.c | 7 ++++--- 18 files changed, 87 insertions(+), 60 deletions(-) diff --git a/src/86box.h b/src/86box.h index 353302bb8..9b3ed2a63 100644 --- a/src/86box.h +++ b/src/86box.h @@ -8,7 +8,7 @@ * * Main include file for the application. * - * Version: @(#)86box.h 1.0.15 2017/12/03 + * Version: @(#)86box.h 1.0.16 2017/12/09 * * Authors: Miran Grca, * Fred N. van Kempen, @@ -122,8 +122,11 @@ extern int config_changed; /* config has changed */ /* Function prototypes. */ -extern void pclog(const char *format, ...); -extern void fatal(const char *format, ...); +#ifdef HAVE_STDARG_H +extern void pclog_ex(const char *fmt, va_list); +#endif +extern void pclog(const char *fmt, ...); +extern void fatal(const char *fmt, ...); extern void set_screen_size(int x, int y); extern void set_screen_size_natural(void); extern void pc_reload(wchar_t *fn); diff --git a/src/cdrom/cdrom.c b/src/cdrom/cdrom.c index b6d5ea951..20dc68d1e 100644 --- a/src/cdrom/cdrom.c +++ b/src/cdrom/cdrom.c @@ -9,7 +9,7 @@ * Implementation of the CD-ROM drive with SCSI(-like) * commands, for both ATAPI and SCSI usage. * - * Version: @(#)cdrom.c 1.0.23 2017/11/24 + * Version: @(#)cdrom.c 1.0.24 2017/12/09 * * Author: Miran Grca, * @@ -21,6 +21,7 @@ #include #include #include +#define HAVE_STDARG_H #include "../86box.h" #include "../config.h" #include "../timer.h" @@ -723,15 +724,15 @@ int cdrom_do_log = ENABLE_CDROM_LOG; static void -cdrom_log(const char *format, ...) +cdrom_log(const char *fmt, ...) { #ifdef ENABLE_CDROM_LOG va_list ap; if (cdrom_do_log) { - va_start(ap, format); - pclog(format, ap); + va_start(ap, fmt); + pclog_ex(fmt, ap); va_end(ap); } #endif diff --git a/src/disk/hdc_ide.c b/src/disk/hdc_ide.c index 01c551b7a..eb2228f9d 100644 --- a/src/disk/hdc_ide.c +++ b/src/disk/hdc_ide.c @@ -9,7 +9,7 @@ * Implementation of the IDE emulation for hard disks and ATAPI * CD-ROM devices. * - * Version: @(#)hdc_ide.c 1.0.20 2017/11/24 + * Version: @(#)hdc_ide.c 1.0.21 2017/12/09 * * Authors: Sarah Walker, * Miran Grca, @@ -26,6 +26,7 @@ #include #include #include +#define HAVE_STDARG_H #include "../86box.h" #include "../cpu/cpu.h" #include "../machine/machine.h" @@ -110,15 +111,15 @@ int ide_do_log = ENABLE_IDE_LOG; #endif -static void ide_log(const char *format, ...) +static void ide_log(const char *fmt, ...) { #ifdef ENABLE_IDE_LOG va_list ap; if (ide_do_log) { - va_start(ap, format); - pclog(format, ap); + va_start(ap, fmt); + pclog_ex(fmt, ap); va_end(ap); } #endif diff --git a/src/disk/hdc_mfm_at.c b/src/disk/hdc_mfm_at.c index 22456ae54..50513dc11 100644 --- a/src/disk/hdc_mfm_at.c +++ b/src/disk/hdc_mfm_at.c @@ -12,7 +12,7 @@ * based design. Most cards were WD1003-WA2 or -WAH, where the * -WA2 cards had a floppy controller as well (to save space.) * - * Version: @(#)hdd_mfm_at.c 1.0.11 2017/11/04 + * Version: @(#)hdc_mfm_at.c 1.0.12 2017/12/09 * * Authors: Sarah Walker, * Fred N. van Kempen, diff --git a/src/disk/hdd_image.c b/src/disk/hdd_image.c index 6d766f4f7..a4f72f7b8 100644 --- a/src/disk/hdd_image.c +++ b/src/disk/hdd_image.c @@ -8,7 +8,7 @@ * * Handling of hard disk image files. * - * Version: @(#)hdd_image.c 1.0.8 2017/11/24 + * Version: @(#)hdd_image.c 1.0.9 2017/12/09 * * Authors: Sarah Walker, * Miran Grca, @@ -28,6 +28,7 @@ #include #include #include +#define HAVE_STDARG_H #include "../86box.h" #include "../plat.h" #include "hdd.h" @@ -55,15 +56,15 @@ int hdd_image_do_log = ENABLE_HDD_LOG; static void -hdd_image_log(const char *format, ...) +hdd_image_log(const char *fmt, ...) { #ifdef ENABLE_HDD_LOG va_list ap; if (hdd_image_do_log) { - va_start(ap, format); - pclog(format, ap); + va_start(ap, fmt); + pclog_ex(fmt, ap); va_end(ap); } #endif diff --git a/src/floppy/fdc.c b/src/floppy/fdc.c index 60746c309..e5e64baa1 100644 --- a/src/floppy/fdc.c +++ b/src/floppy/fdc.c @@ -9,7 +9,7 @@ * Implementation of the NEC uPD-765 and compatible floppy disk * controller. * - * Version: @(#)fdc.c 1.0.10 2017/12/08 + * Version: @(#)fdc.c 1.0.11 2017/12/09 * * Authors: Sarah Walker, * Miran Grca, @@ -22,6 +22,7 @@ #include #include #include +#define HAVE_STDARG_H #include "../86box.h" #include "../cpu/cpu.h" #include "../machine/machine.h" @@ -181,7 +182,7 @@ fdc_log(const char *fmt, ...) if (fdc_do_log) { va_start(ap, fmt); - pclog(fmt, ap); + pclog_ex(fmt, ap); va_end(ap); } #endif diff --git a/src/floppy/floppy_86f.c b/src/floppy/floppy_86f.c index 9cecc3066..de00a1cb1 100644 --- a/src/floppy/floppy_86f.c +++ b/src/floppy/floppy_86f.c @@ -10,7 +10,7 @@ * data in the form of FM/MFM-encoded transitions) which also * forms the core of the emulator's floppy disk emulation. * - * Version: @(#)floppy_86f.c 1.0.12 2017/11/24 + * Version: @(#)floppy_86f.c 1.0.13 2017/12/09 * * Author: Miran Grca, * Copyright 2016,2017 Miran Grca. @@ -23,6 +23,7 @@ #include #include #include "../lzf/lzf.h" +#define HAVE_STDARG_H #include "../86box.h" #include "../config.h" #include "../dma.h" @@ -246,15 +247,15 @@ int d86f_do_log = ENABLE_D86F_LOG; static void -d86f_log(const char *format, ...) +d86f_log(const char *fmt, ...) { #ifdef ENABLE_D86F_LOG va_list ap; if (d86f_do_log) { - va_start(ap, format); - pclog(format, ap); + va_start(ap, fmt); + pclog_ex(fmt, ap); va_end(ap); } #endif diff --git a/src/network/net_ne2000.c b/src/network/net_ne2000.c index a773af1ff..b2c558557 100644 --- a/src/network/net_ne2000.c +++ b/src/network/net_ne2000.c @@ -10,7 +10,7 @@ * * NOTE: The file will also implement an NE1000 for 8-bit ISA systems. * - * Version: @(#)net_ne2000.c 1.0.24 2017/11/24 + * Version: @(#)net_ne2000.c 1.0.25 2017/12/09 * * Authors: Fred N. van Kempen, * Peter Grehan, grehan@iprg.nokia.com> @@ -28,6 +28,7 @@ #include #include #include +#define HAVE_STDARG_H #include "../86box.h" #include "../config.h" #include "../machine/machine.h" @@ -202,7 +203,7 @@ typedef struct { int board; int is_pci; - char name[32]; + const char *name; uint32_t base_address; int base_irq; uint32_t bios_addr, @@ -232,7 +233,7 @@ nelog(int lvl, const char *fmt, ...) if (nic_do_log >= lvl) { va_start(ap, fmt); - pclog(fmt, ap); + pclog_ex(fmt, ap); va_end(ap); } #endif @@ -1896,12 +1897,12 @@ nic_init(device_t *info) dev = malloc(sizeof(nic_t)); memset(dev, 0x00, sizeof(nic_t)); + dev->name = info->name; dev->board = info->local; rom = NULL; switch(dev->board) { #if defined(DEV_BRANCH) && defined(USE_NE1000) case NE2K_NE1000: - strcpy(dev->name, "NE1000"); dev->maclocal[0] = 0x00; /* 00:00:D8 (NE1000 ISA OID) */ dev->maclocal[1] = 0x00; dev->maclocal[2] = 0xD8; @@ -1910,7 +1911,6 @@ nic_init(device_t *info) #endif case NE2K_NE2000: - strcpy(dev->name, "NE2000"); dev->maclocal[0] = 0x00; /* 00:A0:0C (NE2000 compatible OID) */ dev->maclocal[1] = 0xA0; dev->maclocal[2] = 0x0C; @@ -1919,7 +1919,6 @@ nic_init(device_t *info) case NE2K_RTL8029AS: dev->is_pci = (PCI) ? 1 : 0; - strcpy(dev->name, "RTL8029AS"); dev->maclocal[0] = 0x00; /* 00:20:18 (RTL 8029AS PCI OID) */ dev->maclocal[1] = 0x20; dev->maclocal[2] = 0x18; diff --git a/src/pc.c b/src/pc.c index 947d0474d..241a2a4df 100644 --- a/src/pc.c +++ b/src/pc.c @@ -25,6 +25,7 @@ #include #include #include +#define HAVE_STDARG_H #include "86box.h" #include "config.h" #include "cpu/cpu.h" @@ -172,15 +173,12 @@ static int unscaled_size_x = SCREEN_RES_X, /* current unscaled size X */ * being logged, and catch repeating entries. */ void -pclog(const char *fmt, ...) +pclog_ex(const char *fmt, va_list ap) { #ifndef RELEASE_BUILD static char buff[1024]; static int seen = 0; char temp[1024]; - va_list ap; - - va_start(ap, fmt); if (stdlog == NULL) { if (log_path[0] != L'\0') { @@ -204,12 +202,25 @@ pclog(const char *fmt, ...) fprintf(stdlog, temp, ap); } - va_end(ap); fflush(stdlog); #endif } +/* Log something. We only do this in non-release builds. */ +void +pclog(const char *fmt, ...) +{ +#ifndef RELEASE_BUILD + va_list ap; + + va_start(ap, fmt); + pclog_ex(fmt, ap); + va_end(ap); +#endif +} + + /* Log a fatal error, and display a UI message before exiting. */ void fatal(const char *fmt, ...) diff --git a/src/pci.c b/src/pci.c index f4506f748..593d2e4b9 100644 --- a/src/pci.c +++ b/src/pci.c @@ -3,6 +3,7 @@ #include #include #include +#define HAVE_STDARG_H #include "86box.h" #include "machine/machine.h" #include "cpu/cpu.h" @@ -60,15 +61,15 @@ int pci_do_log = ENABLE_PCI_LOG; static void -pcilog(const char *format, ...) +pcilog(const char *fmt, ...) { #ifdef ENABLE_PCI_LOG va_list ap; if (pci_do_log) { - va_start(ap, format); - pclog(format, ap); + va_start(ap, fmt); + pclog_ex(fmt, ap); va_end(ap); } #endif diff --git a/src/scsi/scsi_aha154x.c b/src/scsi/scsi_aha154x.c index 322f65dea..10dcb5f37 100644 --- a/src/scsi/scsi_aha154x.c +++ b/src/scsi/scsi_aha154x.c @@ -10,7 +10,7 @@ * made by Adaptec, Inc. These controllers were designed for * the ISA bus. * - * Version: @(#)scsi_aha154x.c 1.0.35 2017/11/24 + * Version: @(#)scsi_aha154x.c 1.0.36 2017/12/09 * * Authors: Fred N. van Kempen, * Original Buslogic version by SA1988 and Miran Grca. @@ -23,6 +23,7 @@ #include #include #include +#define HAVE_STDARG_H #include "../86box.h" #include "../io.h" #include "../mca.h" @@ -91,7 +92,7 @@ aha_log(const char *fmt, ...) if (aha_do_log) { va_start(ap, fmt); - pclog(fmt, ap); + pclog_ex(fmt, ap); va_end(ap); } #endif diff --git a/src/scsi/scsi_bus.c b/src/scsi/scsi_bus.c index c03211714..d803a0004 100644 --- a/src/scsi/scsi_bus.c +++ b/src/scsi/scsi_bus.c @@ -8,7 +8,7 @@ * * The generic SCSI bus operations handler. * - * Version: @(#)scsi_bus.c 1.0.4 2017/11/24 + * Version: @(#)scsi_bus.c 1.0.5 2017/12/09 * * NOTES: For now ported from PCem with some modifications * but at least it's a start. @@ -21,6 +21,7 @@ #include #include #include +#define HAVE_STDARG_H #include "../86box.h" #include "scsi.h" #include "scsi_device.h" @@ -44,14 +45,14 @@ int scsi_bus_do_log = ENABLE_SCSI_BUS_LOG; static void -scsi_bus_log(const char *format, ...) +scsi_bus_log(const char *fmt, ...) { #ifdef ENABLE_SCSI_BUS_LOG va_list ap; if (scsi_bus_do_log) { - va_start(ap, format); - pclog(format, ap); + va_start(ap, fmt); + pclog_ex(fmt, ap); va_end(ap); } #endif diff --git a/src/scsi/scsi_buslogic.c b/src/scsi/scsi_buslogic.c index 54ac282be..eb25db920 100644 --- a/src/scsi/scsi_buslogic.c +++ b/src/scsi/scsi_buslogic.c @@ -11,7 +11,7 @@ * 1 - BT-545S ISA; * 2 - BT-958D PCI * - * Version: @(#)scsi_buslogic.c 1.0.29 2017/11/24 + * Version: @(#)scsi_buslogic.c 1.0.30 2017/12/09 * * Authors: TheCollector1995, * Miran Grca, @@ -26,6 +26,7 @@ #include #include #include +#define HAVE_STDARG_H #include "../86box.h" #include "../io.h" #include "../mca.h" @@ -243,14 +244,14 @@ int buslogic_do_log = ENABLE_BUSLOGIC_LOG; static void -buslogic_log(const char *format, ...) +buslogic_log(const char *fmt, ...) { #ifdef ENABLE_BUSLOGIC_LOG va_list ap; if (buslogic_do_log) { - va_start(ap, format); - pclog(format, ap); + va_start(ap, fmt); + pclog_ex(fmt, ap); va_end(ap); } #endif diff --git a/src/scsi/scsi_disk.c b/src/scsi/scsi_disk.c index 6f378ae2d..f489851f6 100644 --- a/src/scsi/scsi_disk.c +++ b/src/scsi/scsi_disk.c @@ -6,7 +6,7 @@ * * Emulation of SCSI fixed and removable disks. * - * Version: @(#)scsi_disk.c 1.0.10 2017/11/24 + * Version: @(#)scsi_disk.c 1.0.11 2017/12/09 * * Author: Miran Grca, * @@ -18,6 +18,7 @@ #include #include #include +#define HAVE_STDARG_H #include "../86box.h" #include "../timer.h" #include "../device.h" @@ -457,14 +458,14 @@ int scsi_hd_do_log = ENABLE_SCSI_DISK_LOG; static void -scsi_hd_log(const char *format, ...) +scsi_hd_log(const char *fmt, ...) { #ifdef ENABLE_SCSI_DISK_LOG va_list ap; if (scsi_hd_do_log) { - va_start(ap, format); - pclog(format, ap); + va_start(ap, fmt); + pclog_ex(fmt, ap); va_end(ap); } #endif diff --git a/src/scsi/scsi_ncr5380.c b/src/scsi/scsi_ncr5380.c index 1a4bc4f54..cf92d4008 100644 --- a/src/scsi/scsi_ncr5380.c +++ b/src/scsi/scsi_ncr5380.c @@ -9,7 +9,7 @@ * Implementation of the NCR 5380 series of SCSI Host Adapters * made by NCR. These controllers were designed for the ISA bus. * - * Version: @(#)scsi_ncr5380.c 1.0.7 2017/11/24 + * Version: @(#)scsi_ncr5380.c 1.0.8 2017/12/09 * * Authors: Sarah Walker, * TheCollector1995, @@ -20,6 +20,7 @@ #include #include #include +#define HAVE_STDARG_H #include "../86box.h" #include "../io.h" #include "../dma.h" @@ -156,7 +157,7 @@ ncr_log(const char *fmt, ...) if (ncr5380_do_log) { va_start(ap, fmt); - pclog(fmt, ap); + pclog_ex(fmt, ap); va_end(ap); } #endif diff --git a/src/scsi/scsi_x54x.c b/src/scsi/scsi_x54x.c index a57b58d73..105fa7cbb 100644 --- a/src/scsi/scsi_x54x.c +++ b/src/scsi/scsi_x54x.c @@ -11,7 +11,7 @@ * series of SCSI Host Adapters made by Mylex. * These controllers were designed for various buses. * - * Version: @(#)scsi_x54x.c 1.0.6 2017/11/24 + * Version: @(#)scsi_x54x.c 1.0.7 2017/12/09 * * Authors: TheCollector1995, * Miran Grca, @@ -26,6 +26,7 @@ #include #include #include +#define HAVE_STDARG_H #include "../86box.h" #include "../io.h" #include "../dma.h" @@ -81,7 +82,7 @@ x54x_log(const char *fmt, ...) if (x54x_do_log) { va_start(ap, fmt); - pclog(fmt, ap); + pclog_ex(fmt, ap); va_end(ap); } #endif diff --git a/src/sound/snd_audiopci.c b/src/sound/snd_audiopci.c index 7ae668cf3..979972102 100644 --- a/src/sound/snd_audiopci.c +++ b/src/sound/snd_audiopci.c @@ -3,6 +3,7 @@ #include #include #include +#define HAVE_STDARG_H #include "../86box.h" #include "../device.h" #include "../io.h" @@ -131,14 +132,14 @@ int audiopci_do_log = ENABLE_AUDIOPCI_LOG; static void -audiopci_log(const char *format, ...) +audiopci_log(const char *fmt, ...) { #ifdef ENABLE_AUDIOPCI_LOG va_list ap; if (audiopci_do_log) { - va_start(ap, format); - pclog(format, ap); + va_start(ap, fmt); + pclog_ex(fmt, ap); va_end(ap); } #endif diff --git a/src/sound/snd_emu8k.c b/src/sound/snd_emu8k.c index df108041f..d273e4953 100644 --- a/src/sound/snd_emu8k.c +++ b/src/sound/snd_emu8k.c @@ -6,6 +6,7 @@ #include #include #include +#define HAVE_STDARG_H #include "../86box.h" #include "../device.h" #include "../io.h" @@ -298,14 +299,14 @@ int emu8k_do_log = ENABLE_EMU8K_LOG; static void -emu8k_log(const char *format, ...) +emu8k_log(const char *fmt, ...) { #ifdef ENABLE_EMU8K_LOG va_list ap; if (emu8k_do_log) { - va_start(ap, format); - pclog(format, ap); + va_start(ap, fmt); + pclog_ex(fmt, ap); va_end(ap); } #endif