Fixed several warnings.

Fixed some small issues, mostly NULL-ptr related.
This commit is contained in:
waltje
2018-10-20 02:38:37 -04:00
parent 4fb728541b
commit 4a445127d8
33 changed files with 747 additions and 783 deletions

View File

@@ -8,7 +8,7 @@
*
* Handling of the SCSI controllers.
*
* Version: @(#)scsi.c 1.0.13 2018/10/16
* Version: @(#)scsi.c 1.0.14 2018/10/19
*
* Authors: Fred N. van Kempen, <decwiz@yahoo.com>
* Miran Grca, <mgrca8@gmail.com>
@@ -66,7 +66,7 @@ int scsi_card_do_log = ENABLE_SCSI_DEV_LOG;
#endif
static struct {
static const struct {
const char *internal_name;
const device_t *device;
} scsi_cards[] = {
@@ -147,10 +147,10 @@ scsi_card_has_config(int card)
}
#if defined(_LOGGING) && defined(ENABLE_SCSI_DEV_LOG)
void
scsi_card_log(int level, const char *fmt, ...)
{
#ifdef ENABLE_SCSI_DEV_LOG
va_list ap;
if (scsi_card_do_log >= level) {
@@ -158,8 +158,8 @@ scsi_card_log(int level, const char *fmt, ...)
pclog_ex(fmt, ap);
va_end(ap);
}
#endif
}
#endif
int

View File

@@ -8,7 +8,7 @@
*
* Emulation of SCSI (and ATAPI) CD-ROM drives.
*
* Version: @(#)scsi_cdrom.c 1.0.3 2018/10/18
* Version: @(#)scsi_cdrom.c 1.0.5 2018/10/19
*
* Authors: Fred N. van Kempen, <decwiz@yahoo.com>
* Miran Grca, <mgrca8@gmail.com>
@@ -86,9 +86,7 @@ typedef struct {
uint16_t len;
uint8_t control;
} gesn_cdb_t;
#pragma pack(pop)
#pragma pack(push,1)
typedef struct {
uint16_t len;
uint8_t notification_class;
@@ -352,10 +350,10 @@ static void mode_sense_load(scsi_cdrom_t *dev);
static void scsi_cdrom_callback(void *p);
void
#if defined(_LOGGING) && defined(ENABLE_SCSI_CDROM_LOG)
static void
scsi_cdrom_log(int level, const char *fmt, ...)
{
#ifdef ENABLE_SCSI_CDROM_LOG
va_list ap;
if (scsi_cdrom_do_log >= level) {
@@ -363,8 +361,8 @@ scsi_cdrom_log(int level, const char *fmt, ...)
pclog_ex(fmt, ap);
va_end(ap);
}
#endif
}
#endif
static void
@@ -2730,7 +2728,9 @@ irq_raise(scsi_cdrom_t *dev)
static int
read_from_dma(scsi_cdrom_t *dev)
{
#ifdef _LOGGING
int32_t *BufLen = &scsi_devices[dev->drv->bus_id.scsi.id][dev->drv->bus_id.scsi.lun].buffer_length;
#endif
int ret = 0;
if (dev->drv->bus_type == CDROM_BUS_SCSI)
@@ -2801,8 +2801,10 @@ write_to_scsi_dma(uint8_t scsi_id, uint8_t scsi_lun)
static int
write_to_dma(scsi_cdrom_t *dev)
{
#ifdef _LOGGING
scsi_device_t *sd = &scsi_devices[dev->drv->bus_id.scsi.id][dev->drv->bus_id.scsi.lun];
int32_t *BufLen = &sd->buffer_length;
#endif
int ret = 0;
if (dev->drv->bus_type == CDROM_BUS_SCSI) {
@@ -3044,7 +3046,7 @@ scsi_cdrom_stop(void *priv)
{
scsi_cdrom_t *dev = (scsi_cdrom_t *)priv;
if (dev->drv->ops && dev->drv->ops->stop)
if (dev->drv && dev->drv->ops && dev->drv->ops->stop)
dev->drv->ops->stop(dev->drv);
}
@@ -3114,12 +3116,14 @@ static void
scsi_cdrom_identify(void *priv, int ide_has_dma)
{
ide_t *ide = (ide_t *)priv;
#ifdef _LOGGING
scsi_cdrom_t *dev;
char device_identify[9] = { 'E', 'M', 'U', '_', 'C', 'D', '0', '0', 0 };
dev = (scsi_cdrom_t *) ide->p;
device_identify[7] = dev->id + 0x30;
#endif
DEBUG("ATAPI Identify: %s\n", device_identify);
ide->buffer[0] = 0x8000 | (5<<8) | 0x80 | (2<<5); /* ATAPI device, CD-ROM drive, removable media, accelerated DRQ */

View File

@@ -8,7 +8,7 @@
*
* Definitions for the SCSI CD-ROM module.
*
* Version: @(#)scsi_cdrom.h 1.0.2 2018/10/17
* Version: @(#)scsi_cdrom.h 1.0.3 2018/10/19
*
* Authors: Fred N. van Kempen, <decwiz@yahoo.com>
* Miran Grca, <mgrca8@gmail.com>
@@ -83,8 +83,6 @@ typedef struct {
#define scsi_cdrom_ascq dev->sense[13]
extern void scsi_cdrom_log(int level, const char *fmt, ...);
//extern void scsi_cdrom_reset(void *p);

View File

@@ -8,7 +8,7 @@
*
* The generic SCSI device command handler.
*
* Version: @(#)scsi_device.c 1.0.11 2018/10/16
* Version: @(#)scsi_device.c 1.0.12 2018/10/19
*
* Authors: Fred N. van Kempen, <decwiz@yahoo.com>
* Miran Grca, <mgrca8@gmail.com>
@@ -60,7 +60,7 @@ static const uint8_t scsi_null_device_sense[18] = {
static uint8_t
scsi_device_target_command(scsi_device_t *dev, uint8_t *cdb)
target_command(scsi_device_t *dev, uint8_t *cdb)
{
if (dev->command && dev->err_stat_to_scsi) {
dev->command(dev->p, cdb);
@@ -72,7 +72,7 @@ scsi_device_target_command(scsi_device_t *dev, uint8_t *cdb)
static void
scsi_device_target_callback(scsi_device_t *dev)
target_callback(scsi_device_t *dev)
{
if (dev->callback)
dev->callback(dev->p);
@@ -80,7 +80,7 @@ scsi_device_target_callback(scsi_device_t *dev)
static int
scsi_device_target_err_stat_to_scsi(scsi_device_t *dev)
target_err_stat_to_scsi(scsi_device_t *dev)
{
if (dev->err_stat_to_scsi)
return dev->err_stat_to_scsi(dev->p);
@@ -168,13 +168,16 @@ scsi_device_command_phase0(scsi_device_t *dev, uint8_t *cdb)
return;
}
/* Finally, execute the SCSI command immediately and get the transfer length. */
/* Execute the SCSI command immediately and get the transfer length. */
dev->phase = SCSI_PHASE_COMMAND;
dev->status = scsi_device_target_command(dev, cdb);
dev->status = target_command(dev, cdb);
if (dev->phase == SCSI_PHASE_STATUS) {
/* Command completed (either OK or error) - call the phase callback to complete the command. */
scsi_device_target_callback(dev);
/*
* Command completed (either OK or error) -
* Call the phase callback to complete the command.
*/
target_callback(dev);
}
/* If the phase is DATA IN or DATA OUT, finish this here. */
}
@@ -187,11 +190,14 @@ scsi_device_command_phase1(scsi_device_t *dev)
return;
/* Call the second phase. */
scsi_device_target_callback(dev);
dev->status = scsi_device_target_err_stat_to_scsi(dev);
target_callback(dev);
dev->status = target_err_stat_to_scsi(dev);
/* Command second phase complete - call the callback to complete the command. */
scsi_device_target_callback(dev);
/*
* Command second phase complete -
* Call the callback to complete the command.
*/
target_callback(dev);
}
@@ -202,10 +208,10 @@ scsi_device_get_buf_len(scsi_device_t *dev)
}
#if defined(_LOGGING) && defined(ENABLE_SCSI_LOG)
void
scsi_log(int level, const char *fmt, ...)
{
#ifdef ENABLE_SCSI_LOG
va_list ap;
if (scsi_do_log >= level) {
@@ -213,5 +219,5 @@ scsi_log(int level, const char *fmt, ...)
pclog_ex(fmt, ap);
va_end(ap);
}
#endif
}
#endif

View File

@@ -8,7 +8,7 @@
*
* Emulation of SCSI fixed disks.
*
* Version: @(#)scsi_disk.c 1.0.15 2018/10/16
* Version: @(#)scsi_disk.c 1.0.17 2018/10/19
*
* Authors: Fred N. van Kempen, <decwiz@yahoo.com>
* Miran Grca, <mgrca8@gmail.com>
@@ -171,10 +171,10 @@ int scsi_disk_do_log = ENABLE_SCSI_DISK_LOG;
#endif
void
#if defined(_LOGGING) && defined(ENABLE_SCSI_DISK_LOG)
static void
scsi_disk_log(int level, const char *fmt, ...)
{
#ifdef ENABLE_SCSI_DISK_LOG
va_list ap;
if (scsi_disk_do_log >= level) {
@@ -182,8 +182,8 @@ scsi_disk_log(int level, const char *fmt, ...)
pclog_ex(fmt, ap);
va_end(ap);
}
#endif
}
#endif
/* Translates ATAPI status (ERR_STAT flag) to SCSI status. */
@@ -593,7 +593,9 @@ static void
scsi_disk_command(void *p, uint8_t *cdb)
{
scsi_disk_t *dev = (scsi_disk_t *)p;
#ifdef _LOGGING
uint8_t *hdbufferb;
#endif
int32_t *BufLen;
int32_t len, max_len, alloc_length;
int pos = 0;
@@ -604,7 +606,9 @@ scsi_disk_command(void *p, uint8_t *cdb)
char device_identify_ex[15] = { 'E', 'M', 'U', '_', 'H', 'D', '0', '0', ' ', 'v', '0'+EMU_VER_MAJOR, '.', '0'+EMU_VER_MINOR, '0'+EMU_VER_REV, 0 };
int block_desc = 0;
#ifdef _LOGGING
hdbufferb = scsi_devices[dev->drv->bus_id.scsi.id][dev->drv->bus_id.scsi.lun].cmd_buffer;
#endif
BufLen = &scsi_devices[dev->drv->bus_id.scsi.id][dev->drv->bus_id.scsi.lun].buffer_length;
last_sector = hdd_image_get_last_sector(dev->id);

View File

@@ -8,7 +8,7 @@
*
* Emulation of SCSI fixed and removable disks.
*
* Version: @(#)scsi_disk.h 1.0.4 2018/10/14
* Version: @(#)scsi_disk.h 1.0.5 2018/10/19
*
* Authors: Fred N. van Kempen, <decwiz@yahoo.com>
* Miran Grca, <mgrca8@gmail.com>
@@ -76,7 +76,6 @@ extern void scsi_reloadhd(int id);
extern void scsi_unloadhd(int scsi_id, int scsi_lun, int id);
#endif
extern void scsi_disk_log(int level, const char *fmt, ...);
extern void scsi_disk_global_init(void);
extern void scsi_disk_hard_reset(void);
extern void scsi_disk_close(void);