I1620: Fix Coverity identified problems

CPU: Added error test on device addr
DP:    Fixed bug in write check function test
TTY:  Fixed tab stop array overrun at right margin
This commit is contained in:
Bob Supnik 2017-03-14 04:48:14 -07:00 committed by Mark Pizzolato
parent b95e8704d2
commit f586105051
3 changed files with 13 additions and 8 deletions

View file

@ -1,6 +1,6 @@
/* i1620_cpu.c: IBM 1620 CPU simulator /* i1620_cpu.c: IBM 1620 CPU simulator
Copyright (c) 2002-2015, Robert M. Supnik Copyright (c) 2002-2017, Robert M. Supnik
Permission is hereby granted, free of charge, to any person obtaining a Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the "Software"), copy of this software and associated documentation files (the "Software"),
@ -26,6 +26,7 @@
This CPU module incorporates code and comments from the 1620 simulator by This CPU module incorporates code and comments from the 1620 simulator by
Geoff Kuenning, with his permission. Geoff Kuenning, with his permission.
13-Mar-17 RMS Added error test on device addr (COVERITY)
07-May-15 RMS Added missing TFL instruction (Tom McBride) 07-May-15 RMS Added missing TFL instruction (Tom McBride)
28-Mar-15 RMS Revised to use sim_printf 28-Mar-15 RMS Revised to use sim_printf
26-Mar-15 RMS Separated compare from add/sub flows (Tom McBride) 26-Mar-15 RMS Separated compare from add/sub flows (Tom McBride)
@ -753,6 +754,8 @@ while (reason == 0) { /* loop until halted */
case OP_K: case OP_K:
dev = get_2d (ADDR_A (saved_PC, I_IO)); /* get IO dev */ dev = get_2d (ADDR_A (saved_PC, I_IO)); /* get IO dev */
if (dev < 0) /* invalid digits? */
return STOP_INVDIG;
if (k_valid_p[dev]) { /* validate P? */ if (k_valid_p[dev]) { /* validate P? */
reason = get_addr (pla, 5, TRUE, &PAR); /* get P addr */ reason = get_addr (pla, 5, TRUE, &PAR); /* get P addr */
if (reason != SCPE_OK) /* stop if error */ if (reason != SCPE_OK) /* stop if error */
@ -761,7 +764,7 @@ while (reason == 0) { /* loop until halted */
else PAR = 0; else PAR = 0;
f0 = M[ADDR_A (saved_PC, I_CTL)] & DIGIT; /* get function */ f0 = M[ADDR_A (saved_PC, I_CTL)] & DIGIT; /* get function */
f1 = M[ADDR_A (saved_PC, I_CTL + 1)] & DIGIT; f1 = M[ADDR_A (saved_PC, I_CTL + 1)] & DIGIT;
if ((dev < 0) || (iodisp[dev] == NULL)) /* undefined dev? */ if (iodisp[dev] == NULL) /* undefined dev? */
reason = STOP_INVIO; /* stop */ reason = STOP_INVIO; /* stop */
else reason = iodisp[dev] (op, PAR, f0, f1); /* call device */ else reason = iodisp[dev] (op, PAR, f0, f1); /* call device */
break; break;

View file

@ -1,6 +1,6 @@
/* i1620_dp.c: IBM 1311 disk simulator /* i1620_dp.c: IBM 1311 disk simulator
Copyright (c) 2002-2015, Robert M. Supnik Copyright (c) 2002-2017, Robert M. Supnik
Permission is hereby granted, free of charge, to any person obtaining a Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the "Software"), copy of this software and associated documentation files (the "Software"),
@ -35,6 +35,7 @@
to mean the implied sector number that would be in place if the disk pack to mean the implied sector number that would be in place if the disk pack
had been formatted with sequential sector numbers. had been formatted with sequential sector numbers.
13-Mar-17 RMS Fixed bug in write check function test (COVERITY)
18-Oct-02 RMS Fixed bug in error testing (Hans Pufal) 18-Oct-02 RMS Fixed bug in error testing (Hans Pufal)
*/ */
@ -190,7 +191,7 @@ if (f1 >= FNC_WRI) /* invalid func? */
if (op == OP_RN) /* read? set wch */ if (op == OP_RN) /* read? set wch */
qwc = f1 & FNC_WCH; qwc = f1 & FNC_WCH;
else if (op == OP_WN) { /* write? */ else if (op == OP_WN) { /* write? */
if (op & FNC_WCH) /* cant check */ if (f1 & FNC_WCH) /* cant check */
return STOP_INVFNC; return STOP_INVFNC;
f1 = f1 + FNC_WRI; /* offset fnc */ f1 = f1 + FNC_WRI; /* offset fnc */
} }
@ -224,7 +225,7 @@ switch (f1 & ~(FNC_WCH | FNC_NRL)) { /* case on function */
} }
break; /* done, clean up */ break; /* done, clean up */
case FNC_SEC + FNC_WRI: /* write */ case FNC_SEC + FNC_WRI: /* write sectors */
if (cnt <= 0) /* bad count? */ if (cnt <= 0) /* bad count? */
return STOP_INVDCN; return STOP_INVDCN;
psec = dp_fndsec (uptr, sec, FALSE); /* find sector */ psec = dp_fndsec (uptr, sec, FALSE); /* find sector */

View file

@ -1,6 +1,6 @@
/* i1620_tty.c: IBM 1620 typewriter /* i1620_tty.c: IBM 1620 typewriter
Copyright (c) 2002-2015, Robert M. Supnik Copyright (c) 2002-2017, Robert M. Supnik
Permission is hereby granted, free of charge, to any person obtaining a Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the "Software"), copy of this software and associated documentation files (the "Software"),
@ -25,6 +25,7 @@
tty console typewriter tty console typewriter
13-Mar-17 RMS Fixed tab stop array overrun at right margin (COVERITY)
21-Feb-15 TFM Option to provide single digit numeric output 21-Feb-15 TFM Option to provide single digit numeric output
05-Feb-15 TFM Changes to translate tables and valid input char. 05-Feb-15 TFM Changes to translate tables and valid input char.
02-Jan-14 RMS Added variable tab stops 02-Jan-14 RMS Added variable tab stops
@ -420,7 +421,7 @@ int32 rpt;
if (c == '\t') { /* tab? */ if (c == '\t') { /* tab? */
for (rpt = tto_col + 1; /* find tab stop */ for (rpt = tto_col + 1; /* find tab stop */
(tto_tabs[rpt] == 0) && (rpt <= TTO_COLMAX); (rpt <= TTO_COLMAX) && (tto_tabs[rpt] == 0);
rpt++) ; rpt++) ;
for ( ; tto_col < rpt; tto_col++) for ( ; tto_col < rpt; tto_col++)
sim_putchar (' '); /* use spaces */ sim_putchar (' '); /* use spaces */