Skip to content

Commit a9912ce

Browse files
committed
DISK: cppcheck suggestions
1 parent 1e07b04 commit a9912ce

1 file changed

Lines changed: 11 additions & 5 deletions

File tree

sim_disk.c

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -618,10 +618,11 @@ t_stat sim_disk_clr_async (UNIT *uptr)
618618
#if !defined(SIM_ASYNCH_IO)
619619
return SCPE_NOFNC;
620620
#else
621-
struct disk_context *ctx = (struct disk_context *)uptr->disk_ctx;
621+
struct disk_context *ctx;
622622

623623
/* make sure device exists */
624-
if (!ctx) return SCPE_UNATT;
624+
if (uptr == NULL || (ctx = (struct disk_context *) uptr->disk_ctx, ctx == NULL))
625+
return SCPE_UNATT;
625626

626627
sim_debug_unit (ctx->dbit, uptr, "sim_disk_clr_async(unit=%d)\n", (int)(uptr - ctx->dptr->units));
627628

@@ -946,16 +947,21 @@ return SCPE_OK;
946947
*/
947948
static void _sim_disk_io_flush (UNIT *uptr)
948949
{
949-
uint32 f = DK_GET_FMT (uptr);
950+
if (uptr == NULL)
951+
return;
950952

951953
#if defined (SIM_ASYNCH_IO)
952-
struct disk_context *ctx = (struct disk_context *)uptr->disk_ctx;
954+
struct disk_context *ctx;
955+
956+
if (ctx = (struct disk_context *)uptr->disk_ctx, ctx == NULL)
957+
return;
953958

954959
sim_disk_clr_async (uptr);
955960
if (sim_asynch_enabled)
956961
sim_disk_set_async (uptr, ctx->asynch_io_latency);
957962
#endif
958-
switch (f) { /* case on format */
963+
964+
switch (DK_GET_FMT (uptr)) { /* case on format */
959965
case DKUF_F_STD: /* Simh */
960966
fflush (uptr->fileref);
961967
break;

0 commit comments

Comments
 (0)