diff --git a/I1620/i1620_cd.c b/I1620/i1620_cd.c index 5f539300..d16847e4 100644 --- a/I1620/i1620_cd.c +++ b/I1620/i1620_cd.c @@ -350,7 +350,7 @@ if (feof (cdr_unit.fileref)) /* eof? */ return STOP_NOCD; if (ferror (cdr_unit.fileref)) { /* error? */ ind[IN_RDCHK] = 1; /* set read check */ - sim_printf ("CDR I/O error: %s", strerror (errno)); + sim_perror ("CDR I/O error"); clearerr (cdr_unit.fileref); return SCPE_IOERR; } @@ -533,7 +533,7 @@ fputs (cdp_buf, cdp_unit.fileref); /* write card */ cdp_unit.pos = ftell (cdp_unit.fileref); /* count char */ if (ferror (cdp_unit.fileref)) { /* error? */ ind[IN_WRCHK] = 1; - sim_printf ("CDR I/O error: %s", strerror (errno)); + sim_perror ("CDR I/O error"); clearerr (cdp_unit.fileref); return SCPE_IOERR; } diff --git a/I1620/i1620_lp.c b/I1620/i1620_lp.c index aedc55ca..0ff48ad8 100644 --- a/I1620/i1620_lp.c +++ b/I1620/i1620_lp.c @@ -264,7 +264,7 @@ if (lpt_bptr) { /* any line? */ lpt_buf_init (); /* reinit buf */ if (ferror (lpt_unit.fileref)) { /* error? */ ind[IN_PRCHK] = ind[IN_WRCHK] = 1; /* wr, pri check */ - sim_printf ("LPT I/O error: %s", strerror (errno)); + sim_perror ("LPT I/O error"); clearerr (lpt_unit.fileref); return SCPE_IOERR; } @@ -315,7 +315,7 @@ ind[IN_PRCH9] = CHP (9, cct[cct_ptr]) != 0; /* set indicators */ ind[IN_PRCH12] = CHP (12, cct[cct_ptr]) != 0; if (ferror (lpt_unit.fileref)) { /* error? */ ind[IN_PRCHK] = ind[IN_WRCHK] = 1; /* wr, pri check */ - sim_printf ("LPT I/O error: %s", strerror (errno)); + sim_perror ("LPT I/O error"); clearerr (lpt_unit.fileref); return SCPE_IOERR; } diff --git a/I1620/i1620_pt.c b/I1620/i1620_pt.c index 935d0ac2..e7d3eef3 100644 --- a/I1620/i1620_pt.c +++ b/I1620/i1620_pt.c @@ -334,7 +334,7 @@ do { if (feof (ptr_unit.fileref)) sim_printf ("PTR end of file\n"); else - sim_printf ("PTR I/O error: %s", strerror (errno)); + sim_perror ("PTR I/O error");; clearerr (ptr_unit.fileref); return SCPE_IOERR; } @@ -490,7 +490,7 @@ if ((ptp_unit.flags & UNIT_ATT) == 0) { /* attached? */ } if (putc (c, ptp_unit.fileref) == EOF) { /* write char */ ind[IN_WRCHK] = 1; /* error? */ - sim_printf ("PTP I/O error: %s", strerror (errno)); + sim_perror ("PTP I/O error"); clearerr (ptp_unit.fileref); return SCPE_IOERR; } diff --git a/scp.c b/scp.c index fb5f1074..751f0839 100644 --- a/scp.c +++ b/scp.c @@ -9583,7 +9583,10 @@ if (buf != stackbuf) void sim_perror (const char *msg) { -sim_printf ("%s: %s\n", msg, strerror (errno)); +int saved_errno = errno; + +perror (msg); +sim_printf ("%s: %s\n", msg, strerror (saved_errno)); } /* Print command result message to stdout, sim_log (if enabled) and sim_deb (if enabled) */ diff --git a/sim_disk.c b/sim_disk.c index 584984ea..7b960a63 100644 --- a/sim_disk.c +++ b/sim_disk.c @@ -1349,13 +1349,16 @@ return SCPE_OK; t_stat sim_disk_perror (UNIT *uptr, const char *msg) { +int saved_errno = errno; + if (!(uptr->flags & UNIT_ATTABLE)) /* not attachable? */ return SCPE_NOATT; switch (DK_GET_FMT (uptr)) { /* case on format */ case DKUF_F_STD: /* SIMH format */ case DKUF_F_VHD: /* VHD format */ case DKUF_F_RAW: /* Raw Physical Disk Access */ - sim_printf ("%s %s: %s\n", sim_uname(uptr), msg, strerror(errno)); + perror (msg); + sim_printf ("%s %s: %s\n", sim_uname(uptr), msg, strerror(saved_errno)); default: ; }