SCP: Fix potential error return checks (COVERITY)
This commit is contained in:
parent
3e54264253
commit
36f09d223f
1 changed files with 15 additions and 4 deletions
19
scp.c
19
scp.c
|
@ -3740,6 +3740,8 @@ if (NULL == sim_gotofile) return SCPE_UNK; /* only valid inside of
|
||||||
get_glyph (fcptr, gbuf1, 0);
|
get_glyph (fcptr, gbuf1, 0);
|
||||||
if ('\0' == gbuf1[0]) return SCPE_ARG; /* unspecified goto target */
|
if ('\0' == gbuf1[0]) return SCPE_ARG; /* unspecified goto target */
|
||||||
fpos = ftell(sim_gotofile); /* Save start position */
|
fpos = ftell(sim_gotofile); /* Save start position */
|
||||||
|
if (fpos < 0)
|
||||||
|
return SCPE_IERR;
|
||||||
rewind(sim_gotofile); /* start search for label */
|
rewind(sim_gotofile); /* start search for label */
|
||||||
sim_goto_line[sim_do_depth] = 0; /* reset line number */
|
sim_goto_line[sim_do_depth] = 0; /* reset line number */
|
||||||
sim_do_echo = 0; /* Don't echo while searching for label */
|
sim_do_echo = 0; /* Don't echo while searching for label */
|
||||||
|
@ -3761,7 +3763,8 @@ while (1) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
sim_do_echo = saved_do_echo; /* restore echo mode */
|
sim_do_echo = saved_do_echo; /* restore echo mode */
|
||||||
fseek(sim_gotofile, fpos, SEEK_SET); /* restore start position */
|
if (fseek(sim_gotofile, fpos, SEEK_SET)) /* restore start position */
|
||||||
|
return SCPE_IERR;
|
||||||
sim_goto_line[sim_do_depth] = saved_goto_line; /* restore start line number */
|
sim_goto_line[sim_do_depth] = saved_goto_line; /* restore start line number */
|
||||||
return SCPE_ARG;
|
return SCPE_ARG;
|
||||||
}
|
}
|
||||||
|
@ -6603,7 +6606,8 @@ for (i = 1; (dptr = sim_devices[i]) != NULL; i++) { /* reposition all */
|
||||||
for (j = 0; j < dptr->numunits; j++) { /* seq devices */
|
for (j = 0; j < dptr->numunits; j++) { /* seq devices */
|
||||||
uptr = dptr->units + j;
|
uptr = dptr->units + j;
|
||||||
if ((uptr->flags & (UNIT_ATT + UNIT_SEQ)) == (UNIT_ATT + UNIT_SEQ))
|
if ((uptr->flags & (UNIT_ATT + UNIT_SEQ)) == (UNIT_ATT + UNIT_SEQ))
|
||||||
sim_fseek (uptr->fileref, uptr->pos, SEEK_SET);
|
if (sim_fseek (uptr->fileref, uptr->pos, SEEK_SET))
|
||||||
|
return sim_messagef (SCPE_IERR, "Can't seek to %u in %s for %s\n", (unsigned)uptr->pos, uptr->filename, sim_uname (uptr));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
stop_cpu = 0;
|
stop_cpu = 0;
|
||||||
|
@ -7407,7 +7411,11 @@ for (i = 0, j = addr; i < sim_emax; i++, j = j + dptr->aincr) {
|
||||||
SZ_LOAD (sz, sim_eval[i], uptr->filebuf, loc);
|
SZ_LOAD (sz, sim_eval[i], uptr->filebuf, loc);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
sim_fseek (uptr->fileref, (t_addr)(sz * loc), SEEK_SET);
|
if (sim_fseek (uptr->fileref, (t_addr)(sz * loc), SEEK_SET)) {
|
||||||
|
clearerr (uptr->fileref);
|
||||||
|
reason = SCPE_IOERR;
|
||||||
|
break;
|
||||||
|
}
|
||||||
sim_fread (&sim_eval[i], sz, 1, uptr->fileref);
|
sim_fread (&sim_eval[i], sz, 1, uptr->fileref);
|
||||||
if ((feof (uptr->fileref)) &&
|
if ((feof (uptr->fileref)) &&
|
||||||
!(uptr->flags & UNIT_FIX)) {
|
!(uptr->flags & UNIT_FIX)) {
|
||||||
|
@ -7498,7 +7506,10 @@ for (i = 0, j = addr; i < count; i++, j = j + dptr->aincr) {
|
||||||
uptr->hwmark = (uint32) loc + 1;
|
uptr->hwmark = (uint32) loc + 1;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
sim_fseek (uptr->fileref, (t_addr)(sz * loc), SEEK_SET);
|
if (sim_fseek (uptr->fileref, (t_addr)(sz * loc), SEEK_SET)) {
|
||||||
|
clearerr (uptr->fileref);
|
||||||
|
return SCPE_IOERR;
|
||||||
|
}
|
||||||
sim_fwrite (&sim_eval[i], sz, 1, uptr->fileref);
|
sim_fwrite (&sim_eval[i], sz, 1, uptr->fileref);
|
||||||
if (ferror (uptr->fileref)) {
|
if (ferror (uptr->fileref)) {
|
||||||
clearerr (uptr->fileref);
|
clearerr (uptr->fileref);
|
||||||
|
|
Loading…
Add table
Reference in a new issue