From 21ebaeb8b8c9e170676c64e428ba2fb7b2ba082c Mon Sep 17 00:00:00 2001 From: Richard Cornwell Date: Sun, 19 Mar 2017 12:04:22 -0400 Subject: [PATCH] SIMCARD: fixed Coverity issues. --- scp.c | 16 +++++++++++----- sim_card.c | 5 +++-- 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/scp.c b/scp.c index 38d1f56..8aeb5a6 100644 --- a/scp.c +++ b/scp.c @@ -3544,7 +3544,7 @@ else { result = test_search (&val, &sim_stabr); /* test condition */ } else { /* Handle memory case */ - if (!get_asearch (gbuf, sim_dfdev->dradix, &sim_staba) || /* parse condition */ + if (!get_asearch (gbuf, sim_dfdev ? sim_dfdev->dradix : sim_dflt_dev->dradix, &sim_staba) || /* parse condition */ (sim_staba.boolop == -1)) /* relational op reqd */ return SCPE_MISVAL; reason = get_aval (addr, sim_dfdev, sim_dfunit);/* get data */ @@ -6141,10 +6141,14 @@ t_bool suppress_warning = ((sim_switches & SWMASK ('Q')) != 0); t_bool warned = FALSE; sim_switches &= ~(SWMASK ('F') | SWMASK ('D') | SWMASK ('Q')); /* remove digested switches */ -#define READ_S(xx) if (read_line ((xx), sizeof(xx), rfile) == NULL) \ - return SCPE_IOERR; -#define READ_I(xx) if (sim_fread (&xx, sizeof (xx), 1, rfile) == 0) \ - return SCPE_IOERR; +#define READ_S(xx) if (read_line ((xx), sizeof(xx), rfile) == NULL) { \ + r = SCPE_IOERR; \ + goto Cleanup_Return; \ + } +#define READ_I(xx) if (sim_fread (&xx, sizeof (xx), 1, rfile) == 0) { \ + r = SCPE_IOERR; \ + goto Cleanup_Return; \ + } fstat (fileno (rfile), &rstat); READ_S (buf); /* [V2.5+] read version */ @@ -6431,6 +6435,8 @@ for (j=0, r = SCPE_OK; jflags & UNIT_CARD_MODE; switch(mode) { + default: case MODE_TEXT: sim_debug(DEBUG_CARD, dptr, "text: ["); /* Check for special codes */ @@ -656,7 +657,7 @@ sim_read_card(UNIT * uptr) if ((uptr->flags & MODE_LOWER) == 0) c = toupper(c); switch(uptr->flags & MODE_CHAR) { - case 0: + default: case MODE_026: temp = ascii_to_hol_026[(int)c]; break; @@ -895,7 +896,7 @@ sim_punch_card(UNIT * uptr, UNIT *stkuptr) case MODE_OCTAL: sim_debug(DEBUG_CARD, dptr, "octal: ["); out[outp++] = '~'; - for (i = 80; i > 0; i--) { + for (i = 79; i >= 0; i--) { if (data->image[i] != 0) break; }