I650: Fix coverity errors

This commit is contained in:
Roberto Sancho Villa 2018-05-03 21:59:16 +02:00
parent a4b5160437
commit f5f4c96ccd
5 changed files with 22 additions and 17 deletions

View file

@ -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]);
}

View file

@ -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];

View file

@ -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<MAXMEMSIZE * 80;i++)

View file

@ -89,12 +89,12 @@ extern DEVICE cp_dev;
extern DIB cdr_dib;
extern DEVICE cdr_dev;
extern uint32 cdr_cmd(UNIT *, uint16, uint16);
extern UNIT cdr_unit[];
extern UNIT cdr_unit[4];
extern DIB cdp_dib;
extern DEVICE cdp_dev;
extern uint32 cdp_cmd(UNIT *, uint16, uint16);
extern UNIT cdp_unit[];
extern UNIT cdp_unit[4];
/* Device status information stored in u5 */
#define URCSTA_ERR 0002 /* Error reading record */

View file

@ -618,7 +618,7 @@ t_stat deck_load(CONST char *fn, uint16 * DeckImage, int * nCards)
{
UNIT * uptr = &cdr_unit[0];
struct _card_data *data;
t_stat r;
t_stat r, r2;
int i, convert_to_ascii;
uint16 c;
@ -657,7 +657,8 @@ t_stat deck_load(CONST char *fn, uint16 * DeckImage, int * nCards)
}
// deattach file from cdr unit 0
r = (cdr_dev.detach)(uptr);
r2 = (cdr_dev.detach)(uptr);
if (r == SCPE_OK) r = r2;
if (r != SCPE_OK) return r;
return SCPE_OK;
@ -809,6 +810,7 @@ static t_stat deck_join_cmd(CONST char *cptr)
cptr = cptr0; // restore cptr to scan source filenames
nDeck = nCards = 0;
memset(DeckImage, 0, sizeof(DeckImage));
while (1) {
while (sim_isspace (*cptr)) cptr++; // trim leading spc