diff --git a/src/device.c b/src/device.c index d7c80be7a..fa7378c1a 100644 --- a/src/device.c +++ b/src/device.c @@ -637,16 +637,24 @@ device_get_instance(void) const char * device_get_config_string(const char *str) { - const device_config_t *cfg = device_current.dev->config; + const char *ret = ""; - while (cfg && cfg->type != CONFIG_END) { - if (!strcmp(str, cfg->name)) - return (config_get_string((char *) device_current.name, (char *) str, (char *) cfg->default_string)); + if (device_current.dev != NULL) { + const device_config_t *cfg = device_current.dev->config; - cfg++; + while ((cfg != NULL) && (cfg->type != CONFIG_END)) { + if (!strcmp(str, cfg->name)) { + const char *s = (config_get_string((char *) device_current.name, + (char *) str, (char *) cfg->default_string)); + ret = (s == NULL) ? "" : s; + break; + } + + cfg++; + } } - return (NULL); + return ret; } int @@ -870,24 +878,29 @@ machine_get_config_int(char *str) return 0; } -char * +const char * machine_get_config_string(char *str) { - const device_t *dev = machine_get_device(machine); - const device_config_t *cfg; + const device_t *dev = machine_get_device(machine); + const char *ret = ""; - if (dev == NULL) - return 0; + if (dev != NULL) { + const device_config_t *cfg; - cfg = dev->config; - while (cfg && cfg->type != CONFIG_END) { - if (!strcmp(str, cfg->name)) - return (config_get_string((char *) dev->name, str, (char *) cfg->default_string)); + cfg = dev->config; + while ((cfg != NULL) && (cfg->type != CONFIG_END)) { + if (!strcmp(str, cfg->name)) { + const char *s = config_get_string((char *) dev->name, str, + (char *) cfg->default_string); + ret = (s == NULL) ? "" : s; + break; + } - cfg++; + cfg++; + } } - return NULL; + return ret; } const device_t * diff --git a/src/device/serial_passthrough.c b/src/device/serial_passthrough.c index 3da2e09ff..256f9eaa9 100644 --- a/src/device/serial_passthrough.c +++ b/src/device/serial_passthrough.c @@ -260,7 +260,7 @@ static const device_config_t serial_passthrough_config[] = { .name = "host_serial_path", .description = "Host Serial Device", .type = CONFIG_SERPORT, - .default_string = "", + .default_string = NULL, .default_int = 0, .file_filter = NULL, .spinner = { 0 }, diff --git a/src/include/86box/device.h b/src/include/86box/device.h index 1c2ec5203..b5a4c1925 100644 --- a/src/include/86box/device.h +++ b/src/include/86box/device.h @@ -118,16 +118,6 @@ enum { #define BIOS_INTERLEAVED_INVERT 8 #define BIOS_HIGH_BIT_INVERT 16 -#define device_common_config_t \ - const char *name; \ - const char *description; \ - int type; \ - const char *default_string; \ - int default_int; \ - const char *file_filter; \ - const device_config_spinner_t spinner; \ - const device_config_selection_t selection[32] - typedef struct device_config_selection_t { const char *description; int value; @@ -139,10 +129,6 @@ typedef struct device_config_spinner_t { int16_t step; } device_config_spinner_t; -typedef struct _device_dep_config_ { - device_common_config_t; -} device_dep_config_t; - typedef struct device_config_bios_t { const char *name; const char *internal_name; @@ -153,15 +139,18 @@ typedef struct device_config_bios_t { void *dev1; void *dev2; const char *files[9]; - /* Configuration options that depend on the device variant. - To prevent excessive nesting, there is no CONFIG_BIOS - option a dep_config struct */ - const device_dep_config_t *dep_config; } device_config_bios_t; typedef struct _device_config_ { - device_common_config_t; - const device_config_bios_t bios[32]; + const char *name; + const char *description; + int type; + const char *default_string; + int default_int; + const char *file_filter; + const device_config_spinner_t spinner; + const device_config_selection_t selection[32]; + const device_config_bios_t bios[32]; } device_config_t; typedef struct _device_ { @@ -242,8 +231,8 @@ extern int device_get_instance(void); extern const char *device_get_internal_name(const device_t *dev); -extern int machine_get_config_int(char *str); -extern char *machine_get_config_string(char *str); +extern int machine_get_config_int(char *str); +extern const char *machine_get_config_string(char *str); extern const device_t device_none; extern const device_t device_internal;