Yet more sonarlint fixes

This commit is contained in:
Jasmine Iwanek
2023-05-29 01:30:51 -04:00
parent 2e6634da89
commit ed1b369abd
125 changed files with 2557 additions and 2279 deletions

View File

@@ -174,12 +174,12 @@ hdc_has_config(int hdc)
const device_t *dev = hdc_get_device(hdc);
if (dev == NULL)
return (0);
return 0;
if (!device_has_config(dev))
return (0);
return 0;
return (1);
return 1;
}
int

View File

@@ -172,16 +172,19 @@ get_sector(esdi_t *esdi, off64_t *addr)
drive_t *drive = &esdi->drives[esdi->drive_sel];
int heads = drive->cfg_hpc;
int sectors = drive->cfg_spt;
int c, h, s, sector;
int c;
int h;
int s;
int sector;
if (esdi->head > heads) {
esdi_at_log("esdi_get_sector: past end of configured heads\n");
return (1);
return 1;
}
if (esdi->sector >= sectors + 1) {
esdi_at_log("esdi_get_sector: past end of configured sectors\n");
return (1);
return 1;
}
sector = esdi->sector ? esdi->sector : 1;
@@ -203,7 +206,7 @@ get_sector(esdi_t *esdi, off64_t *addr)
*addr = ((((off64_t) c * drive->real_hpc) + h) * drive->real_spt) + s;
}
return (0);
return 0;
}
/* Move to the next sector using CHS addressing. */
@@ -253,7 +256,8 @@ static void
esdi_write(uint16_t port, uint8_t val, void *priv)
{
esdi_t *esdi = (esdi_t *) priv;
double seek_time, xfer_time;
double seek_time;
double xfer_time;
off64_t addr;
esdi_at_log("WD1007 write(%04x, %02x)\n", port, val);
@@ -452,7 +456,7 @@ esdi_readw(uint16_t port, void *priv)
}
}
return (temp);
return temp;
}
static uint8_t
@@ -498,7 +502,7 @@ esdi_read(uint16_t port, void *priv)
esdi_at_log("WD1007 read(%04x) = %02x\n", port, temp);
return (temp);
return temp;
}
static void
@@ -820,13 +824,13 @@ esdi_rom_write(uint32_t addr, uint8_t val, void *p)
static void *
wd1007vse1_init(const device_t *info)
{
int c, d;
int c;
esdi_t *esdi = malloc(sizeof(esdi_t));
memset(esdi, 0x00, sizeof(esdi_t));
c = 0;
for (d = 0; d < HDD_NUM; d++) {
for (uint8_t d = 0; d < HDD_NUM; d++) {
if ((hdd[d].bus == HDD_BUS_ESDI) && (hdd[d].esdi_channel < ESDI_NUM)) {
loadhd(esdi, hdd[d].esdi_channel, d, hdd[d].fn);
@@ -858,7 +862,7 @@ wd1007vse1_init(const device_t *info)
ui_sb_update_icon(SB_HDD | HDD_BUS_ESDI, 0);
return (esdi);
return esdi;
}
static void
@@ -866,9 +870,8 @@ wd1007vse1_close(void *priv)
{
esdi_t *esdi = (esdi_t *) priv;
drive_t *drive;
int d;
for (d = 0; d < 2; d++) {
for (uint8_t d = 0; d < 2; d++) {
drive = &esdi->drives[d];
hdd_image_close(drive->hdd_num);

View File

@@ -868,7 +868,7 @@ esdi_read(uint16_t port, void *priv)
break;
}
return (ret);
return ret;
}
static void
@@ -987,7 +987,7 @@ esdi_readw(uint16_t port, void *priv)
switch (port & 7) {
case 0: /*Status Interface Register*/
if (dev->status_pos >= dev->status_len)
return (0);
return 0;
ret = dev->status_data[dev->status_pos++];
if (dev->status_pos >= dev->status_len) {
dev->status &= ~STATUS_STATUS_OUT_FULL;
@@ -999,7 +999,7 @@ esdi_readw(uint16_t port, void *priv)
fatal("esdi_readw port=%04x\n", port);
}
return (ret);
return ret;
}
static void
@@ -1117,7 +1117,8 @@ esdi_init(const device_t *info)
{
drive_t *drive;
esdi_t *dev;
int c, i;
uint8_t c;
uint8_t i;
dev = malloc(sizeof(esdi_t));
if (dev == NULL)
@@ -1178,7 +1179,7 @@ esdi_init(const device_t *info)
/* Set the reply timer. */
timer_add(&dev->timer, esdi_callback, dev, 0);
return (dev);
return dev;
}
static void
@@ -1186,11 +1187,10 @@ esdi_close(void *priv)
{
esdi_t *dev = (esdi_t *) priv;
drive_t *drive;
int d;
dev->drives[0].present = dev->drives[1].present = 0;
for (d = 0; d < 2; d++) {
for (uint8_t d = 0; d < 2; d++) {
drive = &dev->drives[d];
hdd_image_close(drive->hdd_num);

View File

@@ -176,7 +176,8 @@ static uint8_t ide_qua_pnp_rom[] = {
};
ide_t *ide_drives[IDE_NUM];
int ide_ter_enabled = 0, ide_qua_enabled = 0;
int ide_ter_enabled = 0;
int ide_qua_enabled = 0;
static void ide_atapi_callback(ide_t *ide);
static void ide_callback(void *priv);
@@ -389,9 +390,9 @@ ide_irq_update(ide_t *ide)
void
ide_padstr(char *str, const char *src, int len)
{
int i, v;
int v;
for (i = 0; i < len; i++) {
for (int i = 0; i < len; i++) {
if (*src != '\0')
v = *src++;
else
@@ -412,9 +413,7 @@ ide_padstr(char *str, const char *src, int len)
void
ide_padstr8(uint8_t *buf, int buf_size, const char *src)
{
int i;
for (i = 0; i < buf_size; i++) {
for (int i = 0; i < buf_size; i++) {
if (*src != '\0')
buf[i] = *src++;
else
@@ -488,7 +487,9 @@ ide_hd_identify(ide_t *ide)
{
char device_identify[9] = { '8', '6', 'B', '_', 'H', 'D', '0', '0', 0 };
uint32_t d_hpc, d_spt, d_tracks;
uint32_t d_hpc;
uint32_t d_spt;
uint32_t d_tracks;
uint64_t full_size = (((uint64_t) hdd[ide->hdd_num].tracks) * hdd[ide->hdd_num].hpc * hdd[ide->hdd_num].spt);
device_identify[6] = (ide->hdd_num / 10) + 0x30;
@@ -577,7 +578,12 @@ ide_hd_identify(ide_t *ide)
static void
ide_identify(ide_t *ide)
{
int d, i, max_pio, max_sdma, max_mdma, max_udma;
int d;
int i;
int max_pio;
int max_sdma;
int max_mdma;
int max_udma;
ide_t *ide_other = ide_drives[ide->channel ^ 1];
ide_log("IDE IDENTIFY or IDENTIFY PACKET DEVICE on board %i (channel %i)\n", ide->board, ide->channel);
@@ -674,7 +680,8 @@ ide_identify(ide_t *ide)
static off64_t
ide_get_sector(ide_t *ide)
{
uint32_t heads, sectors;
uint32_t heads;
uint32_t sectors;
if (ide->lba)
return (off64_t) ide->lba_addr;
@@ -749,8 +756,11 @@ ide_set_signature(ide_t *ide)
static int
ide_set_features(ide_t *ide)
{
uint8_t features, features_data;
int mode, submode, max;
uint8_t features;
uint8_t features_data;
int mode;
int submode;
int max;
features = ide->cylprecomp;
features_data = ide->secount;
@@ -836,7 +846,8 @@ ide_set_features(ide_t *ide)
void
ide_set_sector(ide_t *ide, int64_t sector_num)
{
unsigned int cyl, r;
unsigned int cyl;
unsigned int r;
if (ide->lba) {
ide->head = (sector_num >> 24);
ide->cylinder = (sector_num >> 8);
@@ -942,7 +953,8 @@ ide_atapi_command_bus(ide_t *ide)
static void
ide_atapi_callback(ide_t *ide)
{
int out, ret = 0;
int out;
int ret = 0;
switch (ide->sc->packet_status) {
case PHASE_IDLE:
@@ -1326,7 +1338,8 @@ ide_write_devctl(uint16_t addr, uint8_t val, void *priv)
{
ide_board_t *dev = (ide_board_t *) priv;
ide_t *ide, *ide_other;
ide_t *ide;
ide_t *ide_other;
int ch;
uint8_t old;
@@ -1428,7 +1441,8 @@ ide_writeb(uint16_t addr, uint8_t val, void *priv)
{
ide_board_t *dev = (ide_board_t *) priv;
ide_t *ide, *ide_other;
ide_t *ide;
ide_t *ide_other;
int ch;
ch = dev->cur_dev;
@@ -1913,7 +1927,8 @@ ide_readb(uint16_t addr, void *priv)
{
ide_board_t *dev = (ide_board_t *) priv;
int ch, absent = 0;
int ch;
int absent = 0;
ide_t *ide;
ch = dev->cur_dev;
@@ -2170,7 +2185,8 @@ atapi_error_no_ready(ide_t *ide)
static void
ide_callback(void *priv)
{
int snum, ret = 0;
int snum;
int ret = 0;
ide_t *ide = (ide_t *) priv;
@@ -2580,8 +2596,10 @@ id_not_found:
uint8_t
ide_read_ali_75(void)
{
ide_t *ide0, *ide1;
int ch0, ch1;
ide_t *ide0;
ide_t *ide1;
int ch0;
int ch1;
uint8_t ret = 0x00;
ch0 = ide_boards[0]->cur_dev;
@@ -2604,8 +2622,10 @@ ide_read_ali_75(void)
uint8_t
ide_read_ali_76(void)
{
ide_t *ide0, *ide1;
int ch0, ch1;
ide_t *ide0;
ide_t *ide1;
int ch0;
int ch1;
uint8_t ret = 0x00;
ch0 = ide_boards[0]->cur_dev;
@@ -2743,7 +2763,7 @@ static void
ide_board_close(int board)
{
ide_t *dev;
int c, d;
int c;
ide_log("ide_board_close(%i)\n", board);
@@ -2757,7 +2777,7 @@ ide_board_close(int board)
ide_clear_bus_master(board);
/* Close hard disk image files (if previously open) */
for (d = 0; d < 2; d++) {
for (uint8_t d = 0; d < 2; d++) {
c = (board << 1) + d;
ide_boards[board]->ide[d] = NULL;
@@ -2797,9 +2817,13 @@ static void
ide_board_setup(int board)
{
ide_t *dev;
int c, d;
int ch, is_ide, valid_ch;
int min_ch, max_ch;
int c;
int d;
int ch;
int is_ide;
int valid_ch;
int min_ch;
int max_ch;
min_ch = (board << 1);
max_ch = min_ch + 1;
@@ -3015,7 +3039,7 @@ ide_init(const device_t *info)
break;
}
return (ide_drives);
return ide_drives;
}
static void
@@ -3047,7 +3071,8 @@ ide_drive_reset(int d)
static void
ide_board_reset(int board)
{
int d, min, max;
int min;
int max;
ide_log("Resetting IDE board %i...\n", board);
@@ -3056,7 +3081,7 @@ ide_board_reset(int board)
min = (board << 1);
max = min + 2;
for (d = min; d < max; d++)
for (int d = min; d < max; d++)
ide_drive_reset(d);
}

View File

@@ -102,7 +102,8 @@ cmd640_set_irq(int channel, void *priv)
static void
cmd640_ide_handlers(cmd640_t *dev)
{
uint16_t main, side;
uint16_t main;
uint16_t side;
ide_pri_disable();

View File

@@ -96,7 +96,8 @@ cmd646_bus_master_dma(int channel, uint8_t *data, int transfer_length, int out,
static void
cmd646_ide_handlers(cmd646_t *dev)
{
uint16_t main, side;
uint16_t main;
uint16_t side;
int irq_mode[2] = { 0, 0 };
ide_pri_disable();

View File

@@ -302,7 +302,8 @@ sff_bus_master_dma(int channel, uint8_t *data, int transfer_length, int out, voi
char *sop;
#endif
int force_end = 0, buffer_pos = 0;
int force_end = 0;
int buffer_pos = 0;
#ifdef ENABLE_SFF_LOG
sop = out ? "Read" : "Writ";

View File

@@ -177,35 +177,35 @@ get_sector(mfm_t *mfm, off64_t *addr)
diagnostics v2.07 will error with: ERROR 152 - SYSTEM BOARD. */
if (drive->curcyl != mfm->cylinder) {
st506_at_log("WD1003(%d) sector: wrong cylinder\n");
return (1);
return 1;
}
if (mfm->head > drive->cfg_hpc) {
st506_at_log("WD1003(%d) get_sector: past end of configured heads\n",
mfm->drvsel);
return (1);
return 1;
}
if (mfm->sector >= drive->cfg_spt + 1) {
st506_at_log("WD1003(%d) get_sector: past end of configured sectors\n",
mfm->drvsel);
return (1);
return 1;
}
/* We should check this in the SET_DRIVE_PARAMETERS command! --FvK */
if (mfm->head > drive->hpc) {
st506_at_log("WD1003(%d) get_sector: past end of heads\n", mfm->drvsel);
return (1);
return 1;
}
if (mfm->sector >= drive->spt + 1) {
st506_at_log("WD1003(%d) get_sector: past end of sectors\n", mfm->drvsel);
return (1);
return 1;
}
*addr = ((((off64_t) mfm->cylinder * drive->cfg_hpc) + mfm->head) * drive->cfg_spt) + (mfm->sector - 1);
return (0);
return 0;
}
/* Move to the next sector using CHS addressing. */
@@ -468,7 +468,7 @@ mfm_readw(uint16_t port, void *priv)
}
}
return (ret);
return ret;
}
static uint8_t
@@ -517,7 +517,7 @@ mfm_read(uint16_t port, void *priv)
st506_at_log("WD1003 read(%04x) = %02x\n", port, ret);
return (ret);
return ret;
}
static void
@@ -689,14 +689,14 @@ static void *
mfm_init(const device_t *info)
{
mfm_t *mfm;
int c, d;
int c;
st506_at_log("WD1003: ISA MFM/RLL Fixed Disk Adapter initializing ...\n");
mfm = malloc(sizeof(mfm_t));
memset(mfm, 0x00, sizeof(mfm_t));
c = 0;
for (d = 0; d < HDD_NUM; d++) {
for (uint8_t d = 0; d < HDD_NUM; d++) {
if ((hdd[d].bus == HDD_BUS_MFM) && (hdd[d].mfm_channel < MFM_NUM)) {
loadhd(mfm, hdd[d].mfm_channel, d, hdd[d].fn);
@@ -722,16 +722,15 @@ mfm_init(const device_t *info)
ui_sb_update_icon(SB_HDD | HDD_BUS_MFM, 0);
return (mfm);
return mfm;
}
static void
mfm_close(void *priv)
{
mfm_t *mfm = (mfm_t *) priv;
int d;
for (d = 0; d < 2; d++) {
for (uint8_t d = 0; d < 2; d++) {
drive_t *drive = &mfm->drives[d];
hdd_image_close(drive->hdd_num);

View File

@@ -369,7 +369,7 @@ get_sector(hdc_t *dev, drive_t *drive, off64_t *addr)
if (!drive->present) {
/* No need to log this. */
dev->error = dev->nr_err;
return (0);
return 0;
}
#if 0
@@ -387,19 +387,19 @@ get_sector(hdc_t *dev, drive_t *drive, off64_t *addr)
st506_xt_log("ST506: get_sector: past end of configured heads\n");
#endif
dev->error = ERR_ILLEGAL_ADDR;
return (0);
return 0;
}
if (dev->sector >= drive->cfg_spt) {
#ifdef ENABLE_ST506_XT_LOG
st506_xt_log("ST506: get_sector: past end of configured sectors\n");
#endif
dev->error = ERR_ILLEGAL_ADDR;
return (0);
return 0;
}
*addr = ((((off64_t) dev->cylinder * drive->cfg_hpc) + dev->head) * drive->cfg_spt) + dev->sector;
return (1);
return 1;
}
static void
@@ -446,12 +446,12 @@ get_chs(hdc_t *dev, drive_t *drive)
* result in an ERR_ILLEGAL_ADDR. --FvK
*/
drive->cylinder = drive->cfg_cyl - 1;
return (0);
return 0;
}
drive->cylinder = dev->cylinder;
return (1);
return 1;
}
static void
@@ -1217,7 +1217,7 @@ st506_read(uint16_t port, void *priv)
}
st506_xt_log("ST506: read(%04x) = %02x\n", port, ret);
return (ret);
return ret;
}
/* Write to one of the registers. */
@@ -1287,7 +1287,8 @@ static void
mem_write(uint32_t addr, uint8_t val, void *priv)
{
hdc_t *dev = (hdc_t *) priv;
uint32_t ptr, mask = 0;
uint32_t ptr;
uint32_t mask = 0;
/* Ignore accesses to anything below the configured address,
needed because of the emulator's 4k mapping granularity. */
@@ -1317,7 +1318,8 @@ static uint8_t
mem_read(uint32_t addr, void *priv)
{
hdc_t *dev = (hdc_t *) priv;
uint32_t ptr, mask = 0;
uint32_t ptr;
uint32_t mask = 0;
uint8_t ret = 0xff;
/* Ignore accesses to anything below the configured address,
@@ -1373,7 +1375,7 @@ mem_read(uint32_t addr, void *priv)
else
ret = dev->bios_rom.rom[addr];
return (ret);
return ret;
}
/*
@@ -1467,12 +1469,11 @@ static void
set_switches(hdc_t *dev, hd_type_t *hdt, int num)
{
drive_t *drive;
int c, d;
int e;
dev->switches = 0x00;
for (d = 0; d < MFM_NUM; d++) {
for (uint8_t d = 0; d < MFM_NUM; d++) {
drive = &dev->drives[d];
if (!drive->present) {
@@ -1481,7 +1482,7 @@ set_switches(hdc_t *dev, hd_type_t *hdt, int num)
continue;
}
for (c = 0; c < num; c++) {
for (int c = 0; c < num; c++) {
/* Does the Xebec also support more than 4 types? */
if ((drive->spt == hdt[c].spt) && (drive->hpc == hdt[c].hpc) && (drive->tracks == hdt[c].tracks)) {
/* Olivetti M24/M240: Move the upper 2 bites up by 2 bits, as the
@@ -1511,7 +1512,8 @@ st506_init(const device_t *info)
{
char *fn = NULL;
hdc_t *dev;
int i, c;
int i;
int c;
dev = (hdc_t *) malloc(sizeof(hdc_t));
memset(dev, 0x00, sizeof(hdc_t));
@@ -1703,7 +1705,7 @@ st506_init(const device_t *info)
dev->drives[c].cfg_spt = dev->drives[c].spt;
}
return (dev);
return dev;
}
static void
@@ -1711,9 +1713,8 @@ st506_close(void *priv)
{
hdc_t *dev = (hdc_t *) priv;
drive_t *drive;
int d;
for (d = 0; d < MFM_NUM; d++) {
for (uint8_t d = 0; d < MFM_NUM; d++) {
drive = &dev->drives[d];
hdd_image_close(drive->hdd_num);

View File

@@ -308,25 +308,25 @@ get_sector(hdc_t *dev, drive_t *drive, off64_t *addr)
xta_log("%s: get_sector: wrong cylinder %d/%d\n",
dev->name, drive->cur_cyl, dev->track);
dev->sense = ERR_ILLADDR;
return (1);
return 1;
}
if (dev->head >= drive->hpc) {
xta_log("%s: get_sector: past end of heads\n", dev->name);
dev->sense = ERR_ILLADDR;
return (1);
return 1;
}
if (dev->sector >= drive->spt) {
xta_log("%s: get_sector: past end of sectors\n", dev->name);
dev->sense = ERR_ILLADDR;
return (1);
return 1;
}
/* Calculate logical address (block number) of desired sector. */
*addr = ((((off64_t) dev->track * drive->hpc) + dev->head) * drive->spt) + dev->sector;
return (0);
return 0;
}
static void
@@ -375,10 +375,11 @@ do_seek(hdc_t *dev, drive_t *drive, int cyl)
static void
do_format(hdc_t *dev, drive_t *drive, dcb_t *dcb)
{
int start_cyl, end_cyl;
int start_hd, end_hd;
int start_cyl;
int end_cyl;
int start_hd;
int end_hd;
off64_t addr;
int h, s;
/* Get the parameters from the DCB. */
if (dcb->cmd == CMD_FORMAT_DRIVE) {
@@ -413,8 +414,8 @@ do_fmt:
* data to fill the sectors with, so we will use
* that at least.
*/
for (h = start_hd; h < end_hd; h++) {
for (s = 0; s < drive->spt; s++) {
for (int h = start_hd; h < end_hd; h++) {
for (uint8_t s = 0; s < drive->spt; s++) {
/* Set the sector we need to write. */
dev->head = h;
dev->sector = s;
@@ -901,7 +902,7 @@ hdc_read(uint16_t port, void *priv)
break;
}
return (ret);
return ret;
}
/* Write to one of the controller registers. */
@@ -970,7 +971,7 @@ xta_init(const device_t *info)
char *bios_rev = NULL;
char *fn = NULL;
hdc_t *dev;
int c, i;
int c;
int max = XTA_NUM;
/* Allocate and initialize device block. */
@@ -1007,7 +1008,7 @@ xta_init(const device_t *info)
/* Load any disks for this device class. */
c = 0;
for (i = 0; i < HDD_NUM; i++) {
for (uint8_t i = 0; i < HDD_NUM; i++) {
if ((hdd[i].bus == HDD_BUS_XTA) && (hdd[i].xta_channel < max)) {
drive = &dev->drives[hdd[i].xta_channel];
@@ -1051,7 +1052,7 @@ xta_init(const device_t *info)
/* Create a timer for command delays. */
timer_add(&dev->timer, hdc_callback, dev, 0);
return (dev);
return dev;
}
static void
@@ -1059,14 +1060,13 @@ xta_close(void *priv)
{
hdc_t *dev = (hdc_t *) priv;
drive_t *drive;
int d;
/* Remove the I/O handler. */
io_removehandler(dev->base, 4,
hdc_read, NULL, NULL, hdc_write, NULL, NULL, dev);
/* Close all disks and their images. */
for (d = 0; d < XTA_NUM; d++) {
for (uint8_t d = 0; d < XTA_NUM; d++) {
drive = &dev->drives[d];
hdd_image_close(drive->hdd_num);

View File

@@ -145,7 +145,7 @@ xtide_init(const device_t *info)
xtide_read, NULL, NULL,
xtide_write, NULL, NULL, xtide);
return (xtide);
return xtide;
}
static int
@@ -177,7 +177,7 @@ xtide_at_init(const device_t *info)
device_add(&ide_isa_2ch_device);
return (xtide);
return xtide;
}
static int
@@ -208,7 +208,7 @@ xtide_acculogic_init(const device_t *info)
xtide_read, NULL, NULL,
xtide_write, NULL, NULL, xtide);
return (xtide);
return xtide;
}
static int
@@ -239,7 +239,7 @@ xtide_at_ps2_init(const device_t *info)
device_add(&ide_isa_2ch_device);
return (xtide);
return xtide;
}
static int

View File

@@ -41,23 +41,23 @@ hdd_init(void)
/* Clear all global data. */
memset(hdd, 0x00, sizeof(hdd));
return (0);
return 0;
}
int
hdd_string_to_bus(char *str, int cdrom)
{
if (!strcmp(str, "none"))
return (HDD_BUS_DISABLED);
return HDD_BUS_DISABLED;
if (!strcmp(str, "mfm") || !strcmp(str, "rll")) {
if (cdrom) {
no_cdrom:
ui_msgbox_header(MBX_ERROR, (wchar_t *) IDS_2131, (wchar_t *) IDS_4099);
return (0);
return 0;
}
return (HDD_BUS_MFM);
return HDD_BUS_MFM;
}
/* FIXME: delete 'rll' in a year or so.. --FvK */
@@ -65,40 +65,40 @@ no_cdrom:
if (cdrom)
goto no_cdrom;
return (HDD_BUS_ESDI);
return HDD_BUS_ESDI;
}
if (!strcmp(str, "ide_pio_only"))
return (HDD_BUS_IDE);
return HDD_BUS_IDE;
if (!strcmp(str, "ide"))
return (HDD_BUS_IDE);
return HDD_BUS_IDE;
if (!strcmp(str, "atapi_pio_only"))
return (HDD_BUS_ATAPI);
return HDD_BUS_ATAPI;
if (!strcmp(str, "atapi"))
return (HDD_BUS_ATAPI);
return HDD_BUS_ATAPI;
if (!strcmp(str, "eide"))
return (HDD_BUS_IDE);
return HDD_BUS_IDE;
if (!strcmp(str, "xta"))
return (HDD_BUS_XTA);
return HDD_BUS_XTA;
if (!strcmp(str, "atide"))
return (HDD_BUS_IDE);
return HDD_BUS_IDE;
if (!strcmp(str, "ide_pio_and_dma"))
return (HDD_BUS_IDE);
return HDD_BUS_IDE;
if (!strcmp(str, "atapi_pio_and_dma"))
return (HDD_BUS_ATAPI);
return HDD_BUS_ATAPI;
if (!strcmp(str, "scsi"))
return (HDD_BUS_SCSI);
return HDD_BUS_SCSI;
return (0);
return 0;
}
char *
@@ -136,22 +136,22 @@ hdd_bus_to_string(int bus, int cdrom)
break;
}
return (s);
return s;
}
int
hdd_is_valid(int c)
{
if (hdd[c].bus == HDD_BUS_DISABLED)
return (0);
return 0;
if (strlen(hdd[c].fn) == 0)
return (0);
return 0;
if ((hdd[c].tracks == 0) || (hdd[c].hpc == 0) || (hdd[c].spt == 0))
return (0);
return 0;
return (1);
return 1;
}
double
@@ -204,8 +204,9 @@ static void
hdd_readahead_update(hard_disk_t *hdd)
{
uint64_t elapsed_cycles;
double elapsed_us, seek_time;
uint32_t max_read_ahead, i;
double elapsed_us;
double seek_time;
uint32_t max_read_ahead;
uint32_t space_needed;
hdd_cache_t *cache = &hdd->cache;
@@ -219,7 +220,7 @@ hdd_readahead_update(hard_disk_t *hdd)
seek_time = 0.0;
for (i = 0; i < max_read_ahead; i++) {
for (uint32_t i = 0; i < max_read_ahead; i++) {
seek_time += hdd_seek_get_time(hdd, segment->ra_addr, HDD_OP_READ, 1, elapsed_us - seek_time);
if (seek_time > elapsed_us)
break;
@@ -252,7 +253,8 @@ static void
hdd_writecache_update(hard_disk_t *hdd)
{
uint64_t elapsed_cycles;
double elapsed_us, seek_time;
double elapsed_us;
double seek_time;
if (hdd->cache.write_pending) {
elapsed_cycles = tsc - hdd->cache.write_start_time;
@@ -383,13 +385,12 @@ static void
hdd_cache_init(hard_disk_t *hdd)
{
hdd_cache_t *cache = &hdd->cache;
uint32_t i;
cache->ra_segment = 0;
cache->ra_ongoing = 0;
cache->ra_start_time = 0;
for (i = 0; i < cache->num_segments; i++) {
for (uint32_t i = 0; i < cache->num_segments; i++) {
cache->segments[i].valid = 0;
cache->segments[i].lru = 0;
cache->segments[i].id = i;
@@ -401,12 +402,13 @@ hdd_cache_init(hard_disk_t *hdd)
static void
hdd_zones_init(hard_disk_t *hdd)
{
uint32_t lba = 0, track = 0;
uint32_t i, tracks;
uint32_t lba = 0;
uint32_t track = 0;
uint32_t tracks;
double revolution_usec = 60.0 / (double) hdd->rpm * 1000000.0;
hdd_zone_t *zone;
for (i = 0; i < hdd->num_zones; i++) {
for (uint32_t i = 0; i < hdd->num_zones; i++) {
zone = &hdd->zones[i];
zone->start_sector = lba;
zone->start_track = track;
@@ -467,10 +469,15 @@ void
hdd_preset_apply(int hdd_id)
{
hard_disk_t *hd = &hdd[hdd_id];
double revolution_usec, zone_percent;
uint32_t disk_sectors, sectors_per_surface, cylinders, cylinders_per_zone;
uint32_t total_sectors = 0, i;
uint32_t spt, zone_sectors;
double revolution_usec;
double zone_percent;
uint32_t disk_sectors;
uint32_t sectors_per_surface;
uint32_t cylinders;
uint32_t cylinders_per_zone;
uint32_t total_sectors = 0;
uint32_t spt;
uint32_t zone_sectors;
if (hd->speed_preset >= hdd_preset_get_num())
hd->speed_preset = 0;
@@ -503,7 +510,7 @@ hdd_preset_apply(int hdd_id)
hd->phy_cyl = cylinders;
cylinders_per_zone = cylinders / preset->zones;
for (i = 0; i < preset->zones; i++) {
for (uint32_t i = 0; i < preset->zones; i++) {
zone_percent = i * 100 / (double) preset->zones;
if (i < preset->zones - 1) {

View File

@@ -107,7 +107,7 @@ image_is_hdx(const char *s, int check_signature)
if (fread(&signature, 1, 8, f) != 8)
fatal("image_is_hdx(): Error reading signature\n");
fclose(f);
if (signature == 0xD778A82044445459ll)
if (signature == 0xD778A82044445459LL)
return 1;
else
return 0;
@@ -143,7 +143,11 @@ hdd_image_calc_chs(uint32_t *c, uint32_t *h, uint32_t *s, uint32_t size)
/* Calculate the geometry from size (in MB), using the algorithm provided in
"Virtual Hard Disk Image Format Specification, Appendix: CHS Calculation" */
uint64_t ts = ((uint64_t) size) << 11LL;
uint32_t spt, heads, cyl, cth;
uint32_t spt;
uint32_t heads;
uint32_t cyl;
uint32_t cth;
if (ts > 65535 * 16 * 255)
ts = 65535 * 16 * 255;
@@ -180,7 +184,7 @@ prepare_new_hard_disk(uint8_t id, uint64_t full_size)
uint64_t target_size = (full_size + hdd_images[id].base) - ftello64(hdd_images[id].file);
uint32_t size;
uint32_t t, i;
uint32_t t;
t = (uint32_t) (target_size >> 20); /* Amount of 1 MB blocks. */
size = (uint32_t) (target_size & 0xfffff); /* 1 MB mask. */
@@ -195,7 +199,7 @@ prepare_new_hard_disk(uint8_t id, uint64_t full_size)
/* First, write all the 1 MB blocks. */
if (t > 0) {
for (i = 0; i < t; i++) {
for (uint32_t i = 0; i < t; i++) {
fseek(hdd_images[id].file, 0, SEEK_END);
fwrite(empty_sector_1mb, 1, 1048576, hdd_images[id].file);
pclog("#");
@@ -224,9 +228,7 @@ prepare_new_hard_disk(uint8_t id, uint64_t full_size)
void
hdd_image_init(void)
{
int i;
for (i = 0; i < HDD_NUM; i++)
for (uint8_t i = 0; i < HDD_NUM; i++)
memset(&hdd_images[i], 0, sizeof(hdd_image_t));
}
@@ -235,10 +237,12 @@ hdd_image_load(int id)
{
uint32_t sector_size = 512;
uint32_t zero = 0;
uint64_t signature = 0xD778A82044445459ll;
uint64_t signature = 0xD778A82044445459LL;
uint64_t full_size = 0;
uint64_t spt = 0, hpc = 0, tracks = 0;
int c, ret;
uint64_t spt = 0;
uint64_t hpc = 0;
uint64_t tracks = 0;
int ret;
uint64_t s = 0;
char *fn = hdd[id].fn;
int is_hdx[2] = { 0, 0 };
@@ -306,7 +310,7 @@ hdd_image_load(int id)
fwrite(&(hdd[id].spt), 1, 4, hdd_images[id].file);
fwrite(&(hdd[id].hpc), 1, 4, hdd_images[id].file);
fwrite(&(hdd[id].tracks), 1, 4, hdd_images[id].file);
for (c = 0; c < 0x3f8; c++)
for (uint16_t c = 0; c < 0x3f8; c++)
fwrite(&zero, 1, 4, hdd_images[id].file);
hdd_images[id].type = HDD_IMAGE_HDI;
} else if (is_hdx[0]) {
@@ -560,8 +564,6 @@ hdd_image_zero(uint8_t id, uint32_t sector, uint32_t count)
int non_transferred_sectors = mvhd_format_sectors(hdd_images[id].vhd, sector, count);
hdd_images[id].pos = sector + count - non_transferred_sectors - 1;
} else {
uint32_t i = 0;
memset(empty_sector, 0, 512);
if (fseeko64(hdd_images[id].file, ((uint64_t) (sector) << 9LL) + hdd_images[id].base, SEEK_SET) == -1) {
@@ -569,7 +571,7 @@ hdd_image_zero(uint8_t id, uint32_t sector, uint32_t count)
return;
}
for (i = 0; i < count; i++) {
for (uint32_t i = 0; i < count; i++) {
if (feof(hdd_images[id].file))
break;

View File

@@ -118,7 +118,7 @@ const uint8_t mo_command_flags[0x100] = {
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
};
static uint64_t mo_mode_sense_page_flags = (GPMODEP_ALL_PAGES);
static uint64_t mo_mode_sense_page_flags = GPMODEP_ALL_PAGES;
static const mode_sense_pages_t mo_mode_sense_pages_default =
// clang-format off
@@ -306,9 +306,7 @@ mo_log(const char *fmt, ...)
int
find_mo_for_channel(uint8_t channel)
{
uint8_t i = 0;
for (i = 0; i < MO_NUM; i++) {
for (uint8_t i = 0; i < MO_NUM; i++) {
if ((mo_drives[i].bus_type == MO_BUS_ATAPI) && (mo_drives[i].ide_channel == channel))
return i;
}
@@ -340,8 +338,8 @@ int
mo_load(mo_t *dev, char *fn)
{
int is_mdi;
uint32_t size = 0;
unsigned int i, found = 0;
uint32_t size = 0;
unsigned int found = 0;
is_mdi = image_is_mdi(fn);
@@ -366,7 +364,7 @@ mo_load(mo_t *dev, char *fn)
dev->drv->base = 0x1000;
}
for (i = 0; i < KNOWN_MO_TYPES; i++) {
for (uint8_t i = 0; i < KNOWN_MO_TYPES; i++) {
if (size == (mo_types[i].sectors * mo_types[i].bytes_per_sector)) {
found = 1;
dev->drv->medium_size = mo_types[i].sectors;
@@ -584,9 +582,6 @@ mo_mode_sense(mo_t *dev, uint8_t *buf, uint32_t pos, uint8_t page, uint8_t block
pf = mo_mode_sense_page_flags;
int i = 0;
int j = 0;
uint8_t msplen;
page &= 0x3f;
@@ -602,14 +597,14 @@ mo_mode_sense(mo_t *dev, uint8_t *buf, uint32_t pos, uint8_t page, uint8_t block
buf[pos++] = (dev->drv->sector_size & 0xff);
}
for (i = 0; i < 0x40; i++) {
for (uint8_t i = 0; i < 0x40; i++) {
if ((page == GPMODE_ALL_PAGES) || (page == i)) {
if (pf & (1LL << ((uint64_t) page))) {
buf[pos++] = mo_mode_sense_read(dev, page_control, i, 0);
msplen = mo_mode_sense_read(dev, page_control, i, 1);
buf[pos++] = msplen;
mo_log("MO %i: MODE SENSE: Page [%02X] length %i\n", dev->id, i, msplen);
for (j = 0; j < msplen; j++)
for (uint8_t j = 0; j < msplen; j++)
buf[pos++] = mo_mode_sense_read(dev, page_control, i, 2 + j);
}
}
@@ -621,7 +616,8 @@ mo_mode_sense(mo_t *dev, uint8_t *buf, uint32_t pos, uint8_t page, uint8_t block
static void
mo_update_request_length(mo_t *dev, int len, int block_len)
{
int bt, min_len = 0;
int bt;
int min_len = 0;
dev->max_transfer_len = dev->request_length;
@@ -696,7 +692,8 @@ mo_bus_speed(mo_t *dev)
static void
mo_command_common(mo_t *dev)
{
double bytes_per_second, period;
double bytes_per_second;
double period;
dev->status = BUSY_STAT;
dev->phase = 1;
@@ -944,7 +941,6 @@ static int
mo_blocks(mo_t *dev, int32_t *len, int first_batch, int out)
{
*len = 0;
int i;
if (!dev->sector_len) {
mo_command_complete(dev);
@@ -961,7 +957,7 @@ mo_blocks(mo_t *dev, int32_t *len, int first_batch, int out)
*len = dev->requested_blocks * dev->drv->sector_size;
for (i = 0; i < dev->requested_blocks; i++) {
for (int i = 0; i < dev->requested_blocks; i++) {
if (fseek(dev->drv->f, dev->drv->base + (dev->sector_pos * dev->drv->sector_size) + (i * dev->drv->sector_size), SEEK_SET) == 1)
break;
@@ -1283,11 +1279,14 @@ static void
mo_command(scsi_common_t *sc, uint8_t *cdb)
{
mo_t *dev = (mo_t *) sc;
int pos = 0, block_desc = 0;
int pos = 0;
int block_desc = 0;
int ret;
int32_t len, max_len;
int32_t len;
int32_t max_len;
int32_t alloc_length;
int size_idx, idx = 0;
int size_idx;
int idx = 0;
unsigned preamble_len;
char device_identify[9] = { '8', '6', 'B', '_', 'M', 'O', '0', '0', 0 };
int32_t blen = 0;
@@ -1769,7 +1768,7 @@ mo_command(scsi_common_t *sc, uint8_t *cdb)
case GPCMD_ERASE_10:
case GPCMD_ERASE_12:
/*Relative address*/
if ((cdb[1] & 1))
if (cdb[1] & 1)
previous_pos = dev->sector_pos;
switch (cdb[0]) {
@@ -1782,7 +1781,7 @@ mo_command(scsi_common_t *sc, uint8_t *cdb)
}
/*Erase all remaining sectors*/
if ((cdb[1] & 4)) {
if (cdb[1] & 4) {
/* Cannot have a sector number when erase all*/
if (dev->sector_len) {
mo_invalid_field(dev);
@@ -1852,15 +1851,18 @@ mo_phase_data_out(scsi_common_t *sc)
{
mo_t *dev = (mo_t *) sc;
uint16_t block_desc_len, pos;
uint16_t block_desc_len;
uint16_t pos;
uint16_t param_list_len;
uint8_t error = 0;
uint8_t page, page_len;
uint8_t page;
uint8_t page_len;
uint32_t i = 0;
uint8_t hdr_len, val, old_val, ch;
uint8_t hdr_len;
uint8_t val;
uint8_t old_val;
uint8_t ch;
int len = 0;
@@ -1918,7 +1920,7 @@ mo_phase_data_out(scsi_common_t *sc)
if (!(mo_mode_sense_page_flags & (1LL << ((uint64_t) page))))
error |= 1;
else {
for (i = 0; i < page_len; i++) {
for (uint8_t i = 0; i < page_len; i++) {
ch = mo_mode_sense_pages_changeable.pages[page][i + 2];
val = dev->buffer[pos + i];
old_val = dev->ms_pages_saved.pages[page][i + 2];
@@ -2104,10 +2106,10 @@ void
mo_hard_reset(void)
{
mo_t *dev;
int c;
uint8_t scsi_id, scsi_bus;
uint8_t scsi_id;
uint8_t scsi_bus;
for (c = 0; c < MO_NUM; c++) {
for (uint8_t c = 0; c < MO_NUM; c++) {
if ((mo_drives[c].bus_type == MO_BUS_ATAPI) || (mo_drives[c].bus_type == MO_BUS_SCSI)) {
mo_log("MO hard_reset drive=%d\n", c);
@@ -2154,10 +2156,10 @@ void
mo_close(void)
{
mo_t *dev;
int c;
uint8_t scsi_id, scsi_bus;
uint8_t scsi_id;
uint8_t scsi_bus;
for (c = 0; c < MO_NUM; c++) {
for (uint8_t c = 0; c < MO_NUM; c++) {
if (mo_drives[c].bus_type == MO_BUS_SCSI) {
scsi_bus = (mo_drives[c].scsi_device_id >> 4) & 0x0f;
scsi_id = mo_drives[c].scsi_device_id & 0x0f;

View File

@@ -460,9 +460,7 @@ zip_log(const char *fmt, ...)
int
find_zip_for_channel(uint8_t channel)
{
uint8_t i = 0;
for (i = 0; i < ZIP_NUM; i++) {
for (uint8_t i = 0; i < ZIP_NUM; i++) {
if ((zip_drives[i].bus_type == ZIP_BUS_ATAPI) && (zip_drives[i].ide_channel == channel))
return i;
}
@@ -753,9 +751,6 @@ zip_mode_sense(zip_t *dev, uint8_t *buf, uint32_t pos, uint8_t page, uint8_t blo
else
pf = zip_mode_sense_page_flags;
int i = 0;
int j = 0;
uint8_t msplen;
page &= 0x3f;
@@ -771,14 +766,14 @@ zip_mode_sense(zip_t *dev, uint8_t *buf, uint32_t pos, uint8_t page, uint8_t blo
buf[pos++] = 0;
}
for (i = 0; i < 0x40; i++) {
for (uint8_t i = 0; i < 0x40; i++) {
if ((page == GPMODE_ALL_PAGES) || (page == i)) {
if (pf & (1LL << ((uint64_t) page))) {
buf[pos++] = zip_mode_sense_read(dev, page_control, i, 0);
msplen = zip_mode_sense_read(dev, page_control, i, 1);
buf[pos++] = msplen;
zip_log("ZIP %i: MODE SENSE: Page [%02X] length %i\n", dev->id, i, msplen);
for (j = 0; j < msplen; j++)
for (uint8_t j = 0; j < msplen; j++)
buf[pos++] = zip_mode_sense_read(dev, page_control, i, 2 + j);
}
}
@@ -790,7 +785,8 @@ zip_mode_sense(zip_t *dev, uint8_t *buf, uint32_t pos, uint8_t page, uint8_t blo
static void
zip_update_request_length(zip_t *dev, int len, int block_len)
{
int bt, min_len = 0;
int bt;
int min_len = 0;
dev->max_transfer_len = dev->request_length;
@@ -865,7 +861,8 @@ zip_bus_speed(zip_t *dev)
static void
zip_command_common(zip_t *dev)
{
double bytes_per_second, period;
double bytes_per_second;
double period;
dev->status = BUSY_STAT;
dev->phase = 1;
@@ -1122,7 +1119,6 @@ static int
zip_blocks(zip_t *dev, int32_t *len, int first_batch, int out)
{
*len = 0;
int i;
if (!dev->sector_len) {
zip_command_complete(dev);
@@ -1139,7 +1135,7 @@ zip_blocks(zip_t *dev, int32_t *len, int first_batch, int out)
*len = dev->requested_blocks << 9;
for (i = 0; i < dev->requested_blocks; i++) {
for (int i = 0; i < dev->requested_blocks; i++) {
if (fseek(dev->drv->f, dev->drv->base + (dev->sector_pos << 9) + (i << 9), SEEK_SET) == 1)
break;
@@ -1355,12 +1351,15 @@ static void
zip_command(scsi_common_t *sc, uint8_t *cdb)
{
zip_t *dev = (zip_t *) sc;
int pos = 0, block_desc = 0;
int pos = 0;
int block_desc = 0;
int ret;
int32_t len, max_len;
int32_t len;
int32_t max_len;
int32_t alloc_length;
uint32_t i = 0;
int size_idx, idx = 0;
int size_idx;
int idx = 0;
unsigned preamble_len;
int32_t blen = 0;
int32_t *BufLen;
@@ -2032,18 +2031,25 @@ zip_phase_data_out(scsi_common_t *sc)
{
zip_t *dev = (zip_t *) sc;
uint16_t block_desc_len, pos;
uint16_t block_desc_len;
uint16_t pos;
uint16_t param_list_len;
uint8_t error = 0;
uint8_t page, page_len;
uint8_t page;
uint8_t page_len;
uint32_t i = 0;
uint8_t hdr_len, val, old_val, ch;
uint8_t hdr_len;
uint8_t val;
uint8_t old_val;
uint8_t ch;
uint32_t last_to_write = 0;
uint32_t c, h, s;
uint32_t c;
uint32_t h;
uint32_t s;
int len = 0;
@@ -2325,10 +2331,10 @@ void
zip_hard_reset(void)
{
zip_t *dev;
int c;
uint8_t scsi_id, scsi_bus;
uint8_t scsi_id;
uint8_t scsi_bus;
for (c = 0; c < ZIP_NUM; c++) {
for (uint8_t c = 0; c < ZIP_NUM; c++) {
if ((zip_drives[c].bus_type == ZIP_BUS_ATAPI) || (zip_drives[c].bus_type == ZIP_BUS_SCSI)) {
zip_log("ZIP hard_reset drive=%d\n", c);
@@ -2375,10 +2381,10 @@ void
zip_close(void)
{
zip_t *dev;
int c;
uint8_t scsi_bus, scsi_id;
uint8_t scsi_bus;
uint8_t scsi_id;
for (c = 0; c < ZIP_NUM; c++) {
for (uint8_t c = 0; c < ZIP_NUM; c++) {
if (zip_drives[c].bus_type == ZIP_BUS_SCSI) {
scsi_bus = (zip_drives[c].scsi_device_id >> 4) & 0x0f;
scsi_id = zip_drives[c].scsi_device_id & 0x0f;