More linting in src/machine

This commit is contained in:
Jasmine Iwanek
2023-08-21 20:23:21 -04:00
parent fd1334d454
commit d8eab07471
7 changed files with 66 additions and 64 deletions

View File

@@ -40,9 +40,10 @@
#include <86box/fdd.h> #include <86box/fdd.h>
#include <86box/fdc.h> #include <86box/fdc.h>
#include <86box/nvr.h> #include <86box/nvr.h>
#include <86box/plat_unused.h>
static void static void
machine_at_thor_common_init(const machine_t *model, int mr) machine_at_thor_common_init(const machine_t *model, UNUSED(int mr))
{ {
machine_at_common_init_ex(model, 2); machine_at_common_init_ex(model, 2);

View File

@@ -649,7 +649,7 @@ do_format(hdc_t *dev, drive_t *drive, ccb_t *ccb)
fcb = (fcb_t *)dev->data; fcb = (fcb_t *)dev->data;
#endif #endif
dev->state = STATE_FINIT; dev->state = STATE_FINIT;
/*FALLTHROUGH*/ fallthrough;
case STATE_FINIT: case STATE_FINIT:
do_fmt: do_fmt:
@@ -745,7 +745,7 @@ hdc_callback(void *priv)
switch (ccb->cmd) { switch (ccb->cmd) {
case CMD_READ_VERIFY: case CMD_READ_VERIFY:
no_data = 1; no_data = 1;
/*FALLTHROUGH*/ fallthrough;
case CMD_READ_SECTORS: case CMD_READ_SECTORS:
if (!drive->present) { if (!drive->present) {
@@ -772,7 +772,7 @@ hdc_callback(void *priv)
dev->buf_len = (128 << dev->ssb.sect_size); dev->buf_len = (128 << dev->ssb.sect_size);
dev->state = STATE_SEND; dev->state = STATE_SEND;
/*FALLTHROUGH*/ fallthrough;
case STATE_SEND: case STATE_SEND:
/* Activate the status icon. */ /* Activate the status icon. */
@@ -938,7 +938,7 @@ do_send:
case CMD_WRITE_VERIFY: case CMD_WRITE_VERIFY:
no_data = 1; no_data = 1;
/*FALLTHROUGH*/ fallthrough;
case CMD_WRITE_SECTORS: case CMD_WRITE_SECTORS:
if (!drive->present) { if (!drive->present) {
@@ -965,7 +965,7 @@ do_send:
dev->buf_len = (128 << dev->ssb.sect_size); dev->buf_len = (128 << dev->ssb.sect_size);
dev->state = STATE_RECV; dev->state = STATE_RECV;
/*FALLTHROUGH*/ fallthrough;
case STATE_RECV: case STATE_RECV:
/* Activate the status icon. */ /* Activate the status icon. */

View File

@@ -1239,7 +1239,7 @@ static void *
eep_init(const device_t *info) eep_init(const device_t *info)
{ {
t1keep_t *eep; t1keep_t *eep;
FILE *f = NULL; FILE *fp = NULL;
eep = (t1keep_t *) malloc(sizeof(t1keep_t)); eep = (t1keep_t *) malloc(sizeof(t1keep_t));
memset(eep, 0x00, sizeof(t1keep_t)); memset(eep, 0x00, sizeof(t1keep_t));
@@ -1257,11 +1257,11 @@ eep_init(const device_t *info)
break; break;
} }
f = nvr_fopen(eep->path, "rb"); fp = nvr_fopen(eep->path, "rb");
if (f != NULL) { if (fp != NULL) {
if (fread(eep->store, 1, 128, f) != 128) if (fread(eep->store, 1, 128, fp) != 128)
fatal("eep_init(): Error reading Tandy EEPROM\n"); fatal("eep_init(): Error reading Tandy EEPROM\n");
(void) fclose(f); (void) fclose(fp);
} else } else
memset(eep->store, 0x00, 128); memset(eep->store, 0x00, 128);
@@ -1274,12 +1274,12 @@ static void
eep_close(void *priv) eep_close(void *priv)
{ {
t1keep_t *eep = (t1keep_t *) priv; t1keep_t *eep = (t1keep_t *) priv;
FILE *f = NULL; FILE *fp = NULL;
f = nvr_fopen(eep->path, "wb"); fp = nvr_fopen(eep->path, "wb");
if (f != NULL) { if (fp != NULL) {
(void) fwrite(eep->store, 128, 1, f); (void) fwrite(eep->store, 128, 1, fp);
(void) fclose(f); (void) fclose(fp);
} }
free(eep); free(eep);

View File

@@ -91,7 +91,7 @@ philips_write(uint16_t port, uint8_t val, void *priv)
static uint8_t static uint8_t
philips_read(uint16_t port, void *priv) philips_read(uint16_t port, void *priv)
{ {
philips_t *dev = (philips_t *) priv; const philips_t *dev = (philips_t *) priv;
uint8_t ret = 0xff; uint8_t ret = 0xff;
switch (port) { switch (port) {

View File

@@ -833,7 +833,7 @@ t1000_read_roml(uint32_t addr, void *priv)
int int
machine_xt_t1000_init(const machine_t *model) machine_xt_t1000_init(const machine_t *model)
{ {
FILE *f; FILE *fp;
int ret; int ret;
ret = bios_load_linear("roms/machines/t1000/t1000.rom", ret = bios_load_linear("roms/machines/t1000/t1000.rom",
@@ -856,15 +856,15 @@ machine_xt_t1000_init(const machine_t *model)
* If the file is missing, continue to boot; the BIOS will * If the file is missing, continue to boot; the BIOS will
* complain 'No ROM drive' but boot normally from floppy. * complain 'No ROM drive' but boot normally from floppy.
*/ */
f = rom_fopen("roms/machines/t1000/t1000dos.rom", "rb"); fp = rom_fopen("roms/machines/t1000/t1000dos.rom", "rb");
if (f != NULL) { if (fp != NULL) {
t1000.romdrive = malloc(T1000_ROMSIZE); t1000.romdrive = malloc(T1000_ROMSIZE);
if (t1000.romdrive) { if (t1000.romdrive) {
memset(t1000.romdrive, 0xff, T1000_ROMSIZE); memset(t1000.romdrive, 0xff, T1000_ROMSIZE);
if (fread(t1000.romdrive, 1, T1000_ROMSIZE, f) != T1000_ROMSIZE) if (fread(t1000.romdrive, 1, T1000_ROMSIZE, fp) != T1000_ROMSIZE)
fatal("machine_xt_t1000_init(): Error reading DOS ROM data\n"); fatal("machine_xt_t1000_init(): Error reading DOS ROM data\n");
} }
fclose(f); fclose(fp);
} }
mem_mapping_add(&t1000.rom_mapping, 0xa0000, 0x10000, mem_mapping_add(&t1000.rom_mapping, 0xa0000, 0x10000,
t1000_read_rom, t1000_read_romw, t1000_read_roml, t1000_read_rom, t1000_read_romw, t1000_read_roml,
@@ -986,62 +986,62 @@ t1000_syskey(uint8_t andmask, uint8_t ormask, uint8_t xormask)
static void static void
t1000_configsys_load(void) t1000_configsys_load(void)
{ {
FILE *f; FILE *fp;
int size; int size;
memset(t1000.t1000_nvram, 0x1a, sizeof(t1000.t1000_nvram)); memset(t1000.t1000_nvram, 0x1a, sizeof(t1000.t1000_nvram));
f = plat_fopen(nvr_path("t1000_config.nvr"), "rb"); fp = plat_fopen(nvr_path("t1000_config.nvr"), "rb");
if (f != NULL) { if (fp != NULL) {
size = sizeof(t1000.t1000_nvram); size = sizeof(t1000.t1000_nvram);
if (fread(t1000.t1000_nvram, 1, size, f) != size) if (fread(t1000.t1000_nvram, 1, size, fp) != size)
fatal("t1000_configsys_load(): Error reading data\n"); fatal("t1000_configsys_load(): Error reading data\n");
fclose(f); fclose(fp);
} }
} }
static void static void
t1000_configsys_save(void) t1000_configsys_save(void)
{ {
FILE *f; FILE *fp;
int size; int size;
f = plat_fopen(nvr_path("t1000_config.nvr"), "wb"); fp = plat_fopen(nvr_path("t1000_config.nvr"), "wb");
if (f != NULL) { if (fp != NULL) {
size = sizeof(t1000.t1000_nvram); size = sizeof(t1000.t1000_nvram);
if (fwrite(t1000.t1000_nvram, 1, size, f) != size) if (fwrite(t1000.t1000_nvram, 1, size, fp) != size)
fatal("t1000_configsys_save(): Error writing data\n"); fatal("t1000_configsys_save(): Error writing data\n");
fclose(f); fclose(fp);
} }
} }
static void static void
t1200_state_load(void) t1200_state_load(void)
{ {
FILE *f; FILE *fp;
int size; int size;
memset(t1000.t1200_nvram, 0, sizeof(t1000.t1200_nvram)); memset(t1000.t1200_nvram, 0, sizeof(t1000.t1200_nvram));
f = plat_fopen(nvr_path("t1200_state.nvr"), "rb"); fp = plat_fopen(nvr_path("t1200_state.nvr"), "rb");
if (f != NULL) { if (fp != NULL) {
size = sizeof(t1000.t1200_nvram); size = sizeof(t1000.t1200_nvram);
if (fread(t1000.t1200_nvram, 1, size, f) != size) if (fread(t1000.t1200_nvram, 1, size, fp) != size)
fatal("t1200_state_load(): Error reading data\n"); fatal("t1200_state_load(): Error reading data\n");
fclose(f); fclose(fp);
} }
} }
static void static void
t1200_state_save(void) t1200_state_save(void)
{ {
FILE *f; FILE *fp;
int size; int size;
f = plat_fopen(nvr_path("t1200_state.nvr"), "wb"); fp = plat_fopen(nvr_path("t1200_state.nvr"), "wb");
if (f != NULL) { if (fp != NULL) {
size = sizeof(t1000.t1200_nvram); size = sizeof(t1000.t1200_nvram);
if (fwrite(t1000.t1200_nvram, 1, size, f) != size) if (fwrite(t1000.t1200_nvram, 1, size, fp) != size)
fatal("t1200_state_save(): Error writing data\n"); fatal("t1200_state_save(): Error writing data\n");
fclose(f); fclose(fp);
} }
} }
@@ -1049,13 +1049,13 @@ t1200_state_save(void)
static void static void
t1000_emsboard_load(void) t1000_emsboard_load(void)
{ {
FILE *f; FILE *fp;
if (mem_size > 512) { if (mem_size > 512) {
f = plat_fopen(nvr_path("t1000_ems.nvr"), "rb"); fp = plat_fopen(nvr_path("t1000_ems.nvr"), "rb");
if (f != NULL) { if (fp != NULL) {
(void) !fread(&ram[512 * 1024], 1024, (mem_size - 512), f); (void) !fread(&ram[512 * 1024], 1024, (mem_size - 512), fp);
fclose(f); fclose(fp);
} }
} }
} }
@@ -1063,13 +1063,13 @@ t1000_emsboard_load(void)
static void static void
t1000_emsboard_save(void) t1000_emsboard_save(void)
{ {
FILE *f; FILE *fp;
if (mem_size > 512) { if (mem_size > 512) {
f = plat_fopen(nvr_path("t1000_ems.nvr"), "wb"); fp = plat_fopen(nvr_path("t1000_ems.nvr"), "wb");
if (f != NULL) { if (fp != NULL) {
fwrite(&ram[512 * 1024], 1024, (mem_size - 512), f); fwrite(&ram[512 * 1024], 1024, (mem_size - 512), fp);
fclose(f); fclose(fp);
} }
} }
} }

View File

@@ -56,7 +56,8 @@ typedef struct {
static uint8_t static uint8_t
zenith_scratchpad_read(uint32_t addr, void *priv) zenith_scratchpad_read(uint32_t addr, void *priv)
{ {
zenith_t *dev = (zenith_t *) priv; const zenith_t *dev = (zenith_t *) priv;
return dev->scratchpad_ram[addr & 0x3fff]; return dev->scratchpad_ram[addr & 0x3fff];
} }

View File

@@ -12981,16 +12981,16 @@ machine_count(void)
return ((sizeof(machines) / sizeof(machine_t)) - 1); return ((sizeof(machines) / sizeof(machine_t)) - 1);
} }
char * const char *
machine_getname(void) machine_getname(void)
{ {
return ((char *) machines[machine].name); return (machines[machine].name);
} }
char * const char *
machine_getname_ex(int m) machine_getname_ex(int m)
{ {
return ((char *) machines[m].name); return (machines[m].name);
} }
const device_t * const device_t *
@@ -13056,16 +13056,16 @@ machine_get_net_device(int m)
return (NULL); return (NULL);
} }
char * const char *
machine_get_internal_name(void) machine_get_internal_name(void)
{ {
return ((char *) machines[machine].internal_name); return (machines[machine].internal_name);
} }
char * const char *
machine_get_internal_name_ex(int m) machine_get_internal_name_ex(int m)
{ {
return ((char *) machines[m].internal_name); return (machines[m].internal_name);
} }
int int
@@ -13121,12 +13121,12 @@ machine_get_type(int m)
} }
int int
machine_get_machine_from_internal_name(char *s) machine_get_machine_from_internal_name(const char *s)
{ {
int c = 0; int c = 0;
while (machines[c].init != NULL) { while (machines[c].init != NULL) {
if (!strcmp(machines[c].internal_name, (const char *) s)) if (!strcmp(machines[c].internal_name, s))
return c; return c;
c++; c++;
} }