1
0
mirror of https://github.com/simh/simh.git synced 2026-01-26 04:01:38 +00:00

ibmpc, isys80xx, imds-225: Fix Coverity identified problems

This commit is contained in:
Bill Beech
2017-03-17 14:24:44 -07:00
parent b64f3cd1c7
commit 0f41c24cb8
8 changed files with 42 additions and 16 deletions

View File

@@ -391,12 +391,14 @@ t_stat isbc201_attach (UNIT *uptr, CONST char *cptr)
fseek(fp, 0, SEEK_SET);
if (flen == -1) {
sim_printf(" isbc201_attach: File error\n");
fclose(fp);
return SCPE_IOERR;
}
if (fdc201[fdcnum].fdd[fddnum].buf == NULL) { /* no buffer allocated */
fdc201[fdcnum].fdd[fddnum].buf = (uint8 *)malloc(flen);
if (fdc201[fdcnum].fdd[fddnum].buf == NULL) {
sim_printf(" isbc201_attach: Malloc error\n");
fclose(fp);
return SCPE_MEM;
}
}
@@ -450,8 +452,7 @@ uint8 isbc201_get_dn(void)
{
int i;
// for (i=0; i<SBC201_NUM; i++)
for (i=0; i<=SBC201_NUM; i++)
for (i=0; i<SBC201_NUM; i++)
if (port >= fdc201[i].baseport && port <= fdc201[i].baseport + 7)
return i;
sim_printf("isbc201_get_dn: port %04X not in isbc202 device table\n", port);

View File

@@ -405,12 +405,14 @@ t_stat isbc202_attach (UNIT *uptr, CONST char *cptr)
fseek(fp, 0, SEEK_SET);
if (flen == -1) {
sim_printf(" isbc202_attach: File error\n");
fclose(fp);
return SCPE_IOERR;
}
if (fdc202[fdcnum].fdd[fddnum].buf == NULL) { /* no buffer allocated */
fdc202[fdcnum].fdd[fddnum].buf = (uint8 *)malloc(flen);
if (fdc202[fdcnum].fdd[fddnum].buf == NULL) {
sim_printf(" isbc202_attach: Malloc error\n");
fclose(fp);
return SCPE_MEM;
}
}
@@ -477,8 +479,7 @@ uint8 isbc202_get_dn(void)
{
int i;
// for (i=0; i<SBC202_NUM; i++)
for (i=0; i<=SBC202_NUM; i++)
for (i=0; i<SBC202_NUM; i++)
if (port >= fdc202[i].baseport && port <= fdc202[i].baseport + 7)
return i;
sim_printf("isbc202_get_dn: port %04X not in isbc202 device table\n", port);

View File

@@ -1071,12 +1071,14 @@ t_stat isbc208_attach (UNIT *uptr, CONST char *cptr)
fseek(fp, 0, SEEK_SET);
if (flen == -1) {
sim_printf(" isbc208_attach: File error\n");
fclose(fp);
return SCPE_IOERR;
}
if (isbc208_buf[uptr->u6] == NULL) { /* no buffer allocated */
isbc208_buf[uptr->u6] = (uint8 *)malloc(flen);
if (isbc208_buf[uptr->u6] == NULL) {
sim_printf(" iSBC208_attach: Malloc error\n");
fclose(fp);
return SCPE_MEM;
}
}

View File

@@ -420,12 +420,14 @@ t_stat zx200a_attach (UNIT *uptr, CONST char *cptr)
fseek(fp, 0, SEEK_SET);
if (flen == -1) {
sim_printf(" zx200a_attach: File error\n");
fclose(fp);
return SCPE_IOERR;
}
if (zx200a[fdcnum].fdd[fddnum].buf == NULL) { /* no buffer allocated */
zx200a[fdcnum].fdd[fddnum].buf = (uint8 *)malloc(flen);
if (zx200a[fdcnum].fdd[fddnum].buf == NULL) {
sim_printf(" zx200a_attach: Malloc error\n");
fclose(fp);
return SCPE_MEM;
}
}