From f5f4c96ccd9415f06bdb7ad4c2f7319a41291cdc Mon Sep 17 00:00:00 2001 From: Roberto Sancho Villa <32797258+rsanchovilla@users.noreply.github.com> Date: Thu, 3 May 2018 21:59:16 +0200 Subject: [PATCH] I650: Fix coverity errors --- I650/i650_cdp.c | 12 +++++++----- I650/i650_cdr.c | 5 ++--- I650/i650_cpu.c | 12 +++++++----- I650/i650_defs.h | 4 ++-- I650/i650_sys.c | 6 ++++-- 5 files changed, 22 insertions(+), 17 deletions(-) diff --git a/I650/i650_cdp.c b/I650/i650_cdp.c index cf36f54d..2517b724 100644 --- a/I650/i650_cdp.c +++ b/I650/i650_cdp.c @@ -54,7 +54,7 @@ t_stat cdp_show_wiring (FILE *st, UNIT *uptr, int32 val, CONST void t_stat cdp_set_echo (UNIT *uptr, int32 val, CONST char *cptr, void *desc); t_stat cdp_show_echo (FILE *st, UNIT *uptr, int32 val, CONST void *desc); -UNIT cdp_unit[] = { +UNIT cdp_unit[4] = { {UDATA(cdp_srv, UNIT_CDP, 0), 600}, // unit 0 is the printing mechanism of 407 {UDATA(cdp_srv, UNIT_CDP, 0), 600}, {UDATA(cdp_srv, UNIT_CDP, 0), 600}, @@ -122,11 +122,13 @@ void encode_lpt_num(t_int64 d, int l) d = d / 10; s[i] = '0' + n; } - if (pad == ' ') for(i=0;i<9;i++) { - if (s[i] != '0') break; - s[i] = ' '; - } s[10] = 0; + if (pad == ' ') { + for(i=0;i<9;i++) { + if (s[i] != '0') break; + s[i] = ' '; + } + } encode_lpt_str(&s[10-l]); } diff --git a/I650/i650_cdr.c b/I650/i650_cdr.c index c0aa8de3..261eccd8 100644 --- a/I650/i650_cdr.c +++ b/I650/i650_cdr.c @@ -53,7 +53,7 @@ const char *cdr_description(DEVICE *dptr); t_stat cdr_set_wiring (UNIT *uptr, int32 val, CONST char *cptr, void *desc); t_stat cdr_show_wiring (FILE *st, UNIT *uptr, int32 val, CONST void *desc); -UNIT cdr_unit[] = { +UNIT cdr_unit[4] = { {UDATA(cdr_srv, UNIT_CDR, 0), 300}, // Unit 0 used internally for carddeck operations simulator specific command {UDATA(cdr_srv, UNIT_CDR, 0), 300}, // unit 1 is default for initial model (1954) {UDATA(cdr_srv, UNIT_CDR, 0), 300}, // storage unit (1955) allows two extra card/readers for a total of 3 @@ -113,7 +113,7 @@ int decode_8word_wiring(struct _card_data * data, int addr) c1 = c1 & 0x3FF; // remove X and Y punches c2 = data->hol_to_ascii[c1]; // convert to ascii again c2 = c2 - '0'; // convert ascii to binary digit - if ((c2 < 0) || (c2 > 9)) c2 = 0; // nondigits chars interpreted as zero + if (c2 > 9) c2 = 0; // nondigits chars interpreted as zero d = d * 10 + c2; } // end of word. set sign @@ -168,7 +168,6 @@ void decode_soap_symb_info(struct _card_data * data, int addr) p = da * 80; for (i=0;i<80;i++) DRUM_Symbolic_Buffer[p+i] = 0; // clear drum[da] symbolic info - if (i2-41 >= 80) i2 = 80-1 + 41; // only copy max 79 chars for (i=41;i<=i2;i++) { if ((i==47) || (i==50) || (i==55)) DRUM_Symbolic_Buffer[p++] = 32; // add space separation between op, da, ia fields DRUM_Symbolic_Buffer[p++] = buf[i]; diff --git a/I650/i650_cpu.c b/I650/i650_cpu.c index d1c0da9a..aff850b0 100644 --- a/I650/i650_cpu.c +++ b/I650/i650_cpu.c @@ -924,7 +924,7 @@ sim_instr(void) break; } // should wait for drum to fetch inst? - if ((AR >= 0) && (AR < (int)MEMSIZE)) { + if (AR < (int)MEMSIZE) { if ((AR % 50) != DrumAddr) continue; // yes } CpuStepsUsed = 0; // init inst execution @@ -1144,10 +1144,12 @@ cpu_set_size(UNIT * uptr, int32 val, CONST char *cptr, void *desc) if (v == 2) {v = 4000;} else v = 0; if ((v <= 0) || (v > MAXMEMSIZE)) return SCPE_ARG; - for (i = v; i < MEMSIZE; i++) { - if ((DRUM[i] != 0) || (DRUM_NegativeZeroFlag[i] != 0)) { - mc = 1; - break; + if (v < 4000) { + for (i = v; i < MEMSIZE; i++) { + if ((DRUM[i] != 0) || (DRUM_NegativeZeroFlag[i] != 0)) { + mc = 1; + break; + } } } for (i=0;i