From 73d7aee71fd1060666d4efba24e029e884cda193 Mon Sep 17 00:00:00 2001 From: Mark Pizzolato Date: Fri, 9 Oct 2015 04:12:25 -0700 Subject: [PATCH] SCP: Add printf style format argument validation for all functions which take printf arguments. These include: sim_printf(), sim_messagef(), Fprint() and sim_debug(). Fix current use of these functions which had invalid arguments. --- PDP11/pdp11_dmc.c | 2 +- PDP11/pdp11_dup.c | 2 +- PDP11/pdp11_kmc.c | 4 ++-- PDP11/pdp11_rq.c | 2 +- PDP11/pdp11_tq.c | 6 +++--- PDP11/pdp11_vh.c | 2 +- VAX/vax_vs.c | 8 ++++---- scp.c | 6 +++--- scp.h | 17 ++++++++++++----- sim_disk.c | 4 ++-- sim_ether.c | 2 +- sim_tape.c | 48 +++++++++++++++++++++++------------------------ sim_tmxr.h | 2 +- 13 files changed, 56 insertions(+), 49 deletions(-) diff --git a/PDP11/pdp11_dmc.c b/PDP11/pdp11_dmc.c index e0e01113..78728505 100644 --- a/PDP11/pdp11_dmc.c +++ b/PDP11/pdp11_dmc.c @@ -2834,7 +2834,7 @@ else { /* DMP */ sim_debug(DBG_WRN, controller->device, "%s%d: Transmit Buffer command (not processed yet)\n", controller->device->name, controller->index); } else { - sim_debug(DBG_WRN, controller->device, "%s%d: Unrecognised command code %hu\n", controller->device->name, controller->index, controller->transfer_type); + sim_debug(DBG_WRN, controller->device, "%s%d: Unrecognised command code 0x%X\n", controller->device->name, controller->index, controller->transfer_type); } controller->transfer_state = Idle; diff --git a/PDP11/pdp11_dup.c b/PDP11/pdp11_dup.c index c44731c2..a43c8a56 100644 --- a/PDP11/pdp11_dup.c +++ b/PDP11/pdp11_dup.c @@ -921,7 +921,7 @@ if (!tmxr_tpbusyln(&dup_ldsc[dup])) { /* Not Busy sending? */ breturn = TRUE; } sim_debug (DBG_TRC, DUPDPTR, "dup_put_msg_bytes(dup=%d, len=%d, start=%s, end=%s) %s\n", - dup, len, start ? "TRUE" : "FALSE", end ? "TRUE" : "FALSE", breturn ? "Good" : "Busy"); + dup, (int)len, start ? "TRUE" : "FALSE", end ? "TRUE" : "FALSE", breturn ? "Good" : "Busy"); if (breturn && (tmxr_tpbusyln (&dup_ldsc[dup]) || dup_xmtpkbytes[dup])) { if (dup_xmt_complete_callback[dup]) dup_svc(dup_units+dup); diff --git a/PDP11/pdp11_kmc.c b/PDP11/pdp11_kmc.c index 9c1872de..eee574d3 100644 --- a/PDP11/pdp11_kmc.c +++ b/PDP11/pdp11_kmc.c @@ -1756,7 +1756,7 @@ static void kmc_baseIn (int32 k, dupstate *d, uint16 cmdsel2, uint8 line) { csraddress = sel6 & SEL6_II_DUPCSR; if ((sel4 != 0) || (cmdsel2 & SEL2_II_RESERVED)) { - sim_debug (DF_ERR, &kmc_dev, "KMC%u: BASE IN reserved bits set\n"); + sim_debug (DF_ERR, &kmc_dev, "KMC%u: BASE IN reserved bits set\n", k); kmc_halt (k, HALT_BADCSR); return; } @@ -1839,7 +1839,7 @@ static void kmc_ctrlIn (int32 k, dupstate *d, int line) { (sel6 & SEL6_CI_DDCMP)? "DDCMP":"Bit-stuffing", (sel6 & SEL6_CI_HDX)? "half" : "full"); if (sel6 & SEL6_CI_ENASS) { - sim_debug (DF_CMD, &kmc_dev, " SS:%u", + sim_debug (DF_CMD, &kmc_dev, " SS:%u-%d", (sel6 & SEL6_CI_SADDR), line); } sim_debug (DF_CMD, &kmc_dev, "\n"); diff --git a/PDP11/pdp11_rq.c b/PDP11/pdp11_rq.c index e1cafa69..430fbf08 100644 --- a/PDP11/pdp11_rq.c +++ b/PDP11/pdp11_rq.c @@ -2130,7 +2130,7 @@ uint32 bc = GETP32 (pkt, RW_WBCL); /* byte count */ uint32 bl = GETP32 (pkt, RW_WBLL); /* block addr */ uint32 ma = GETP32 (pkt, RW_WMPL); /* block addr */ -sim_debug (DBG_TRC, rq_devmap[cp->cnum], "rq_svc(unit=%d, pkt=%d, cmd=%s, lbn=%0X, bc=%0x, phase=%s)\n", +sim_debug (DBG_TRC, rq_devmap[cp->cnum], "rq_svc(unit=%ld, pkt=%d, cmd=%s, lbn=%0X, bc=%0x, phase=%s)\n", uptr-rq_devmap[cp->cnum]->units, pkt, rq_cmdname[cp->pak[pkt].d[CMD_OPC]&0x3f], bl, bc, uptr->io_complete ? "bottom" : "top"); diff --git a/PDP11/pdp11_tq.c b/PDP11/pdp11_tq.c index b38e6513..8969be0c 100644 --- a/PDP11/pdp11_tq.c +++ b/PDP11/pdp11_tq.c @@ -742,7 +742,7 @@ if ((pkt == 0) && tq_pip) { /* polling? */ UNIT *up = tq_getucb (tq_pkt[pkt].d[CMD_UN]); if (up) - sim_debug (DBG_REQ, &tq_dev, "cmd=%04X(%3s), mod=%04X, unit=%d, bc=%04X%04X, ma=%04X%04X, obj=%d, pos=0x%X\n", + sim_debug (DBG_REQ, &tq_dev, "cmd=%04X(%3s), mod=%04X, unit=%d, bc=%04X%04X, ma=%04X%04X, obj=%d, pos=0x%" T_ADDR_FMT "X\n", tq_pkt[pkt].d[CMD_OPC], tq_cmdname[tq_pkt[pkt].d[CMD_OPC]&0x3f], tq_pkt[pkt].d[CMD_MOD], tq_pkt[pkt].d[CMD_UN], tq_pkt[pkt].d[RW_BCH], tq_pkt[pkt].d[RW_BCL], @@ -1311,7 +1311,7 @@ uint32 ntmk = GETP32 (pkt, POS_TMCL); /* #tmk to skp */ struct tq_req_results *res = (struct tq_req_results *)uptr->results; int32 io_complete = res->io_complete; -sim_debug (DBG_TRC, &tq_dev, "tq_svc(unit=%d, pkt=%d, cmd=%s, mdf=0x%0X, bc=0x%0x, phase=%s)\n", +sim_debug (DBG_TRC, &tq_dev, "tq_svc(unit=%ld, pkt=%d, cmd=%s, mdf=0x%0X, bc=0x%0x, phase=%s)\n", uptr-tq_dev.units, pkt, tq_cmdname[tq_pkt[pkt].d[CMD_OPC]&0x3f], mdf, bc, uptr->io_complete ? "bottom" : "top"); @@ -1822,7 +1822,7 @@ UNIT *up = tq_getucb (tq_pkt[pkt].d[CMD_UN]); if (pkt == 0) /* any packet? */ return OK; if (up) - sim_debug (DBG_REQ, &tq_dev, "rsp=%04X, sts=%04X, rszl=%04X, obj=%d, pos=%d\n", + sim_debug (DBG_REQ, &tq_dev, "rsp=%04X, sts=%04X, rszl=%04X, obj=%d, pos=%" T_ADDR_FMT "d\n", tq_pkt[pkt].d[RSP_OPF], tq_pkt[pkt].d[RSP_STS], tq_pkt[pkt].d[RW_RSZL], up->objp, up->pos); else diff --git a/PDP11/pdp11_vh.c b/PDP11/pdp11_vh.c index cf8a9d13..81b1af1b 100644 --- a/PDP11/pdp11_vh.c +++ b/PDP11/pdp11_vh.c @@ -867,7 +867,7 @@ fprintf (stderr, "\rtqln %d\n", 64 - tmxr_tqln (lp->tmln)); } sim_debug(DBG_REG, &vh_dev, "vh_rd(PA=0x%08X [%s], access=%d, data=0x%X)\n", PA, - ((vh_unit[vh].flags & UNIT_MODEDHU) ? vh_rd_dhu_regs : vh_rd_dhv_regs)[(PA >> 1) & 07], access, data); + ((vh_unit[vh].flags & UNIT_MODEDHU) ? vh_rd_dhu_regs : vh_rd_dhv_regs)[(PA >> 1) & 07], access, *data); return (SCPE_OK); } diff --git a/VAX/vax_vs.c b/VAX/vax_vs.c index 61ed2642..120e573f 100644 --- a/VAX/vax_vs.c +++ b/VAX/vax_vs.c @@ -154,23 +154,23 @@ sim_debug (DBG_SERIAL, &vs_dev, "vax -> mouse: %c\n", c); switch (c) { case 0x52: /* R */ - sim_debug (DBG_CMD, &vs_dev, "set mode incremental\n", c); + sim_debug (DBG_CMD, &vs_dev, "set mode incremental(%c)\n", c); vs_mode = VSXXX_INC; break; case 0x44: /* D */ - sim_debug (DBG_CMD, &vs_dev, "set mode prompt\n", c); + sim_debug (DBG_CMD, &vs_dev, "set mode prompt(%c)\n", c); vs_mode = VSXXX_PROMPT; break; case 0x50: /* P */ - sim_debug (DBG_CMD, &vs_dev, "poll\n", c); + sim_debug (DBG_CMD, &vs_dev, "poll(%c)\n", c); vs_mode = VSXXX_PROMPT; vs_sendupd (); break; case 0x54: /* T */ - sim_debug (DBG_CMD, &vs_dev, "test\n", c); + sim_debug (DBG_CMD, &vs_dev, "test(%c)\n", c); vs_reset (&vs_dev); vs_state = VSXXX_TEST; /* send self test report */ vs_buf[0] = RPT_TEST | RPT_SYNC | (VSXXX_REV & RPT_REV); diff --git a/scp.c b/scp.c index 259b9585..0bfbd611 100644 --- a/scp.c +++ b/scp.c @@ -9916,9 +9916,9 @@ void sim_data_trace(DEVICE *dptr, UNIT *uptr, const uint8 *data, const char *pos { if (sim_deb && (dptr->dctrl & reason)) { - sim_debug (reason, dptr, "%s %s %slen: %08X\n", sim_uname(uptr), txt, position, len); + sim_debug (reason, dptr, "%s %s %slen: %08X\n", sim_uname(uptr), txt, position, (unsigned int)len); if (data && len) { - size_t i, same, group, sidx, oidx; + unsigned int i, same, group, sidx, oidx; char outbuf[80], strbuf[18]; static char hex[] = "0123456789ABCDEF"; @@ -9946,7 +9946,7 @@ if (sim_deb && (dptr->dctrl & reason)) { sim_debug (reason, dptr, "%04X%-48s %s\n", i, outbuf, strbuf); } if (same > 0) { - sim_debug (reason, dptr, "%04X thru %04X same as above\n", i-(16*same), len-1); + sim_debug (reason, dptr, "%04X thru %04X same as above\n", i-(16*same), (unsigned int)(len-1)); } } } diff --git a/scp.h b/scp.h index 367d75fb..1272031d 100644 --- a/scp.h +++ b/scp.h @@ -101,6 +101,13 @@ t_stat screenshot_cmd (int32 flag, char *ptr); t_stat spawn_cmd (int32 flag, char *ptr); t_stat echo_cmd (int32 flag, char *ptr); +/* Allow compiler to help validate printf style format arguments */ +#if defined __GNUC__ +#define GCC_FMT_ATTR(n, m) __attribute__ ((format (__printf__, n, m))) +#else +#define GCC_FMT_ATTR(n, m) +#endif + /* Utility routines */ t_stat sim_process_event (void); @@ -144,7 +151,7 @@ t_stat sim_decode_quoted_string (const char *iptr, uint8 *optr, uint32 *osize); char *sim_encode_quoted_string (const uint8 *iptr, uint32 size); void fprint_buffer_string (FILE *st, const uint8 *buf, uint32 size); t_value strtotv (const char *cptr, const char **endptr, uint32 radix); -int Fprintf (FILE *f, const char* fmt, ...); +int Fprintf (FILE *f, const char* fmt, ...) GCC_FMT_ATTR(2, 3); t_stat sim_set_memory_load_file (const unsigned char *data, size_t size); int Fgetc (FILE *f); t_stat fprint_val (FILE *stream, t_value val, uint32 rdx, uint32 wid, uint32 fmt); @@ -188,9 +195,9 @@ t_stat show_dev_debug (FILE *st, DEVICE *dptr, UNIT *uptr, int32 flag, char *cpt const char *sim_error_text (t_stat stat); t_stat sim_string_to_stat (char *cptr, t_stat *cond); t_stat sim_cancel_step (void); -void sim_printf (const char* fmt, ...); +void sim_printf (const char* fmt, ...) GCC_FMT_ATTR(1, 2); void sim_perror (const char* msg); -t_stat sim_messagef (t_stat stat, const char* fmt, ...); +t_stat sim_messagef (t_stat stat, const char* fmt, ...) GCC_FMT_ATTR(2, 3); void sim_data_trace(DEVICE *dptr, UNIT *uptr, const uint8 *data, const char *position, size_t len, const char *txt, uint32 reason); void sim_debug_bits_hdr (uint32 dbits, DEVICE* dptr, const char *header, BITFIELD* bitdefs, uint32 before, uint32 after, int terminate); @@ -201,9 +208,9 @@ void sim_debug_bits (uint32 dbits, DEVICE* dptr, BITFIELD* bitdefs, #endif #ifdef CANT_USE_MACRO_VA_ARGS #define _sim_debug sim_debug -void sim_debug (uint32 dbits, DEVICE* dptr, const char* fmt, ...); +void sim_debug (uint32 dbits, DEVICE* dptr, const char* fmt, ...) GCC_FMT_ATTR(3, 4); #else -void _sim_debug (uint32 dbits, DEVICE* dptr, const char* fmt, ...); +void _sim_debug (uint32 dbits, DEVICE* dptr, const char* fmt, ...) GCC_FMT_ATTR(3, 4); #define sim_debug(dbits, dptr, ...) if (sim_deb && dptr && ((dptr)->dctrl & dbits)) _sim_debug (dbits, dptr, __VA_ARGS__); else (void)0 #endif void fprint_stopped_gen (FILE *st, t_stat v, REG *pc, DEVICE *dptr); diff --git a/sim_disk.c b/sim_disk.c index b4a4fc68..6893f8e1 100644 --- a/sim_disk.c +++ b/sim_disk.c @@ -237,7 +237,7 @@ static t_bool _disk_is_active (UNIT *uptr) struct disk_context *ctx = (struct disk_context *)uptr->disk_ctx; if (ctx) { - sim_debug (ctx->dbit, ctx->dptr, "_disk_is_active(unit=%d, dop=%d)\n", uptr-ctx->dptr->units, ctx->io_dop); + sim_debug (ctx->dbit, ctx->dptr, "_disk_is_active(unit=%ld, dop=%d)\n", uptr-ctx->dptr->units, ctx->io_dop); return (ctx->io_dop != DOP_DONE); } return FALSE; @@ -248,7 +248,7 @@ static void _disk_cancel (UNIT *uptr) struct disk_context *ctx = (struct disk_context *)uptr->disk_ctx; if (ctx) { - sim_debug (ctx->dbit, ctx->dptr, "_disk_cancel(unit=%d, dop=%d)\n", uptr-ctx->dptr->units, ctx->io_dop); + sim_debug (ctx->dbit, ctx->dptr, "_disk_cancel(unit=%ld, dop=%d)\n", uptr-ctx->dptr->units, ctx->io_dop); if (ctx->asynch_io) { pthread_mutex_lock (&ctx->io_lock); while (ctx->io_dop != DOP_DONE) diff --git a/sim_ether.c b/sim_ether.c index 91788d34..a3c1259b 100644 --- a/sim_ether.c +++ b/sim_ether.c @@ -1872,7 +1872,7 @@ else memset(&voa, 0, sizeof(voa)); if (!strcmp(savname, "vde:vdedevice")) { - sim_printf ("Eth: Must specify actual vde device name (i.e. vde:/tmp/switch)\r\n", errbuf); + sim_printf ("Eth: Must specify actual vde device name (i.e. vde:/tmp/switch)\r\n"); return SCPE_OPENERR; } if (!(*handle = (void*) vde_open(savname+4, "simh", &voa))) diff --git a/sim_tape.c b/sim_tape.c index 58e24dc9..098ef3bd 100644 --- a/sim_tape.c +++ b/sim_tape.c @@ -173,7 +173,7 @@ if ((!callback) || !ctx->asynch_io) pthread_mutex_lock (&ctx->io_lock); \ \ sim_debug (ctx->dbit, ctx->dptr, \ - "sim_tape AIO_CALL(op=%d, unit=%d)\n", op, uptr-ctx->dptr->units);\ + "sim_tape AIO_CALL(op=%d, unit=%ld)\n", op, uptr-ctx->dptr->units);\ \ if (ctx->callback) \ abort(); /* horrible mistake, stop */ \ @@ -227,7 +227,7 @@ struct tape_context *ctx = (struct tape_context *)uptr->tape_ctx; ++sched_priority.sched_priority; pthread_setschedparam (pthread_self(), sched_policy, &sched_priority); - sim_debug (ctx->dbit, ctx->dptr, "_tape_io(unit=%d) starting\n", uptr-ctx->dptr->units); + sim_debug (ctx->dbit, ctx->dptr, "_tape_io(unit=%ld) starting\n", uptr-ctx->dptr->units); pthread_mutex_lock (&ctx->io_lock); pthread_cond_signal (&ctx->startup_cond); /* Signal we're ready to go */ @@ -296,7 +296,7 @@ struct tape_context *ctx = (struct tape_context *)uptr->tape_ctx; } pthread_mutex_unlock (&ctx->io_lock); - sim_debug (ctx->dbit, ctx->dptr, "_tape_io(unit=%d) exiting\n", uptr-ctx->dptr->units); + sim_debug (ctx->dbit, ctx->dptr, "_tape_io(unit=%ld) exiting\n", uptr-ctx->dptr->units); return NULL; } @@ -315,7 +315,7 @@ static void _tape_completion_dispatch (UNIT *uptr) struct tape_context *ctx = (struct tape_context *)uptr->tape_ctx; TAPE_PCALLBACK callback = ctx->callback; -sim_debug (ctx->dbit, ctx->dptr, "_tape_completion_dispatch(unit=%d, top=%d, callback=%p)\n", uptr-ctx->dptr->units, ctx->io_top, ctx->callback); +sim_debug (ctx->dbit, ctx->dptr, "_tape_completion_dispatch(unit=%ld, top=%d, callback=%p)\n", uptr-ctx->dptr->units, ctx->io_top, ctx->callback); if (ctx->io_top != TOP_DONE) abort(); /* horribly wrong, stop */ @@ -331,7 +331,7 @@ static t_bool _tape_is_active (UNIT *uptr) struct tape_context *ctx = (struct tape_context *)uptr->tape_ctx; if (ctx) { - sim_debug (ctx->dbit, ctx->dptr, "_tape_is_active(unit=%d, top=%d)\n", uptr-ctx->dptr->units, ctx->io_top); + sim_debug (ctx->dbit, ctx->dptr, "_tape_is_active(unit=%ld, top=%d)\n", uptr-ctx->dptr->units, ctx->io_top); return (ctx->io_top != TOP_DONE); } return FALSE; @@ -342,7 +342,7 @@ static void _tape_cancel (UNIT *uptr) struct tape_context *ctx = (struct tape_context *)uptr->tape_ctx; if (ctx) { - sim_debug (ctx->dbit, ctx->dptr, "_tape_cancel(unit=%d, top=%d)\n", uptr-ctx->dptr->units, ctx->io_top); + sim_debug (ctx->dbit, ctx->dptr, "_tape_cancel(unit=%ld, top=%d)\n", uptr-ctx->dptr->units, ctx->io_top); if (ctx->asynch_io) { pthread_mutex_lock (&ctx->io_lock); while (ctx->io_top != TOP_DONE) @@ -1047,7 +1047,7 @@ t_mtrlnt i, tbc, rbc; t_addr opos; t_stat st; -sim_debug (ctx->dbit, ctx->dptr, "sim_tape_rdrecf(unit=%d, buf=%p, max=%d)\n", uptr-ctx->dptr->units, buf, max); +sim_debug (ctx->dbit, ctx->dptr, "sim_tape_rdrecf(unit=%ld, buf=%p, max=%d)\n", uptr-ctx->dptr->units, buf, max); opos = uptr->pos; /* old position */ if (MTSE_OK != (st = sim_tape_rdlntf (uptr, &tbc))) /* read rec lnt */ @@ -1111,7 +1111,7 @@ uint32 f = MT_GET_FMT (uptr); t_mtrlnt i, rbc, tbc; t_stat st; -sim_debug (ctx->dbit, ctx->dptr, "sim_tape_rdrecr(unit=%d, buf=%p, max=%d)\n", uptr-ctx->dptr->units, buf, max); +sim_debug (ctx->dbit, ctx->dptr, "sim_tape_rdrecr(unit=%ld, buf=%p, max=%d)\n", uptr-ctx->dptr->units, buf, max); if (MTSE_OK != (st = sim_tape_rdlntr (uptr, &tbc))) /* read rec lnt */ return st; @@ -1161,7 +1161,7 @@ struct tape_context *ctx = (struct tape_context *)uptr->tape_ctx; uint32 f = MT_GET_FMT (uptr); t_mtrlnt sbc; -sim_debug (ctx->dbit, ctx->dptr, "sim_tape_wrrecf(unit=%d, buf=%p, bc=%d)\n", uptr-ctx->dptr->units, buf, bc); +sim_debug (ctx->dbit, ctx->dptr, "sim_tape_wrrecf(unit=%ld, buf=%p, bc=%d)\n", uptr-ctx->dptr->units, buf, bc); sim_tape_data_trace(uptr, buf, bc, "Record Write", ctx->dptr->dctrl & MTSE_DBG_DAT, MTSE_DBG_STR); MT_CLR_PNU (uptr); @@ -1240,7 +1240,7 @@ t_stat sim_tape_wrtmk (UNIT *uptr) { struct tape_context *ctx = (struct tape_context *)uptr->tape_ctx; -sim_debug (ctx->dbit, ctx->dptr, "sim_tape_wrtmk(unit=%d)\n", uptr-ctx->dptr->units); +sim_debug (ctx->dbit, ctx->dptr, "sim_tape_wrtmk(unit=%ld)\n", uptr-ctx->dptr->units); if (MT_GET_FMT (uptr) == MTUF_F_P7B) { /* P7B? */ uint8 buf = P7B_EOF; /* eof mark */ return sim_tape_wrrecf (uptr, &buf, 1); /* write char */ @@ -1264,7 +1264,7 @@ t_stat sim_tape_wreom (UNIT *uptr) t_stat result; struct tape_context *ctx = (struct tape_context *)uptr->tape_ctx; -sim_debug (ctx->dbit, ctx->dptr, "sim_tape_wreom(unit=%d)\n", uptr-ctx->dptr->units); +sim_debug (ctx->dbit, ctx->dptr, "sim_tape_wreom(unit=%ld)\n", uptr-ctx->dptr->units); if (MT_GET_FMT (uptr) == MTUF_F_P7B) /* cant do P7B */ return MTSE_FMT; @@ -1292,7 +1292,7 @@ t_stat sim_tape_wreomrw (UNIT *uptr) struct tape_context *ctx = (struct tape_context *)uptr->tape_ctx; t_stat r; -sim_debug (ctx->dbit, ctx->dptr, "sim_tape_wreomrw(unit=%d)\n", uptr-ctx->dptr->units); +sim_debug (ctx->dbit, ctx->dptr, "sim_tape_wreomrw(unit=%ld)\n", uptr-ctx->dptr->units); if (MT_GET_FMT (uptr) == MTUF_F_P7B) /* cant do P7B */ return MTSE_FMT; r = sim_tape_wrdata (uptr, MTR_EOM); @@ -1424,7 +1424,7 @@ const uint32 format = MT_GET_FMT (uptr); /* tape format */ const uint32 meta_size = sizeof (t_mtrlnt); /* bytes per metadatum */ const uint32 min_rec_size = 2 + sizeof (t_mtrlnt) * 2; /* smallest data record size */ -sim_debug (ctx->dbit, ctx->dptr, "sim_tape_wrgap(unit=%d, gaplen=%p)\n", uptr-ctx->dptr->units, gaplen); +sim_debug (ctx->dbit, ctx->dptr, "sim_tape_wrgap(unit=%ld, gaplen=%u)\n", uptr-ctx->dptr->units, gaplen); MT_CLR_PNU (uptr); @@ -1591,7 +1591,7 @@ t_stat sim_tape_sprecf (UNIT *uptr, t_mtrlnt *bc) struct tape_context *ctx = (struct tape_context *)uptr->tape_ctx; t_stat st; -sim_debug (ctx->dbit, ctx->dptr, "sim_tape_sprecf(unit=%d)\n", uptr-ctx->dptr->units); +sim_debug (ctx->dbit, ctx->dptr, "sim_tape_sprecf(unit=%ld)\n", uptr-ctx->dptr->units); st = sim_tape_rdlntf (uptr, bc); /* get record length */ *bc = MTR_L (*bc); @@ -1632,7 +1632,7 @@ struct tape_context *ctx = (struct tape_context *)uptr->tape_ctx; t_stat st; t_mtrlnt tbc; -sim_debug (ctx->dbit, ctx->dptr, "sim_tape_sprecsf(unit=%d, count=%d)\n", uptr-ctx->dptr->units, count); +sim_debug (ctx->dbit, ctx->dptr, "sim_tape_sprecsf(unit=%ld, count=%d)\n", uptr-ctx->dptr->units, count); *skipped = 0; while (*skipped < count) { /* loopo */ @@ -1677,7 +1677,7 @@ t_stat sim_tape_sprecr (UNIT *uptr, t_mtrlnt *bc) struct tape_context *ctx = (struct tape_context *)uptr->tape_ctx; t_stat st; -sim_debug (ctx->dbit, ctx->dptr, "sim_tape_sprecr(unit=%d)\n", uptr-ctx->dptr->units); +sim_debug (ctx->dbit, ctx->dptr, "sim_tape_sprecr(unit=%ld)\n", uptr-ctx->dptr->units); if (MT_TST_PNU (uptr)) { MT_CLR_PNU (uptr); @@ -1724,7 +1724,7 @@ struct tape_context *ctx = (struct tape_context *)uptr->tape_ctx; t_stat st; t_mtrlnt tbc; -sim_debug (ctx->dbit, ctx->dptr, "sim_tape_sprecsr(unit=%d, count=%d)\n", uptr-ctx->dptr->units, count); +sim_debug (ctx->dbit, ctx->dptr, "sim_tape_sprecsr(unit=%ld, count=%d)\n", uptr-ctx->dptr->units, count); *skipped = 0; while (*skipped < count) { /* loopo */ @@ -1773,7 +1773,7 @@ t_stat st; t_bool last_tapemark = FALSE; uint32 filerecsskipped; -sim_debug (ctx->dbit, ctx->dptr, "sim_tape_spfilebyrecf(unit=%d, count=%d, check_leot=%d)\n", uptr-ctx->dptr->units, count, check_leot); +sim_debug (ctx->dbit, ctx->dptr, "sim_tape_spfilebyrecf(unit=%ld, count=%d, check_leot=%d)\n", uptr-ctx->dptr->units, count, check_leot); if (check_leot) { t_mtrlnt rbc; @@ -1841,7 +1841,7 @@ t_stat sim_tape_spfilef (UNIT *uptr, uint32 count, uint32 *skipped) struct tape_context *ctx = (struct tape_context *)uptr->tape_ctx; uint32 totalrecsskipped; -sim_debug (ctx->dbit, ctx->dptr, "sim_tape_spfilef(unit=%d, count=%d)\n", uptr-ctx->dptr->units, count); +sim_debug (ctx->dbit, ctx->dptr, "sim_tape_spfilef(unit=%ld, count=%d)\n", uptr-ctx->dptr->units, count); return sim_tape_spfilebyrecf (uptr, count, skipped, &totalrecsskipped, FALSE); } @@ -1882,7 +1882,7 @@ struct tape_context *ctx = (struct tape_context *)uptr->tape_ctx; t_stat st; uint32 filerecsskipped; -sim_debug (ctx->dbit, ctx->dptr, "sim_tape_spfilebyrecr(unit=%d, count=%d)\n", uptr-ctx->dptr->units, count); +sim_debug (ctx->dbit, ctx->dptr, "sim_tape_spfilebyrecr(unit=%ld, count=%d)\n", uptr-ctx->dptr->units, count); *skipped = 0; *recsskipped = 0; @@ -1935,7 +1935,7 @@ t_stat sim_tape_spfiler (UNIT *uptr, uint32 count, uint32 *skipped) struct tape_context *ctx = (struct tape_context *)uptr->tape_ctx; uint32 totalrecsskipped; -sim_debug (ctx->dbit, ctx->dptr, "sim_tape_spfiler(unit=%d, count=%d)\n", uptr-ctx->dptr->units, count); +sim_debug (ctx->dbit, ctx->dptr, "sim_tape_spfiler(unit=%ld, count=%d)\n", uptr-ctx->dptr->units, count); return sim_tape_spfilebyrecr (uptr, count, skipped, &totalrecsskipped); } @@ -1956,7 +1956,7 @@ t_stat sim_tape_rewind (UNIT *uptr) struct tape_context *ctx = (struct tape_context *)uptr->tape_ctx; if (uptr->flags & UNIT_ATT) { - sim_debug (ctx->dbit, ctx->dptr, "sim_tape_rewind(unit=%d)\n", uptr-ctx->dptr->units); + sim_debug (ctx->dbit, ctx->dptr, "sim_tape_rewind(unit=%ld)\n", uptr-ctx->dptr->units); } uptr->pos = 0; MT_CLR_PNU (uptr); @@ -1979,7 +1979,7 @@ t_stat sim_tape_position (UNIT *uptr, uint32 flags, uint32 recs, uint32 *recsski struct tape_context *ctx = (struct tape_context *)uptr->tape_ctx; t_stat r = MTSE_OK; -sim_debug (ctx->dbit, ctx->dptr, "sim_tape_position(unit=%d, flags=0x%X, recs=%d, files=%d)\n", uptr-ctx->dptr->units, flags, recs, files); +sim_debug (ctx->dbit, ctx->dptr, "sim_tape_position(unit=%ld, flags=0x%X, recs=%d, files=%d)\n", uptr-ctx->dptr->units, flags, recs, files); *recsskipped = *filesskipped = *objectsskipped = 0; if (flags & MTPOS_M_REW) @@ -2043,7 +2043,7 @@ MT_CLR_PNU (uptr); if (!(uptr->flags & UNIT_ATT)) /* attached? */ return SCPE_OK; -sim_debug (ctx->dbit, ctx->dptr, "sim_tape_reset(unit=%d)\n", (int)(uptr-ctx->dptr->units)); +sim_debug (ctx->dbit, ctx->dptr, "sim_tape_reset(unit=%ld)\n", uptr-ctx->dptr->units); _sim_tape_io_flush(uptr); AIO_VALIDATE; diff --git a/sim_tmxr.h b/sim_tmxr.h index ff4c1921..3bcd3d12 100644 --- a/sim_tmxr.h +++ b/sim_tmxr.h @@ -254,7 +254,7 @@ t_stat tmxr_start_poll (void); t_stat tmxr_stop_poll (void); void _tmxr_debug (uint32 dbits, TMLN *lp, const char *msg, char *buf, int bufsize); #define tmxr_debug(dbits, lp, msg, buf, bufsize) if (sim_deb && (lp)->mp && (lp)->mp->dptr && ((dbits) & (lp)->mp->dptr->dctrl)) _tmxr_debug (dbits, lp, msg, buf, bufsize); else (void)0 -#define tmxr_debug_msg(dbits, lp, msg) if (sim_deb && (lp)->mp && (lp)->mp->dptr && ((dbits) & (lp)->mp->dptr->dctrl)) sim_debug (dbits, (lp)->mp->dptr, msg); else (void)0 +#define tmxr_debug_msg(dbits, lp, msg) if (sim_deb && (lp)->mp && (lp)->mp->dptr && ((dbits) & (lp)->mp->dptr->dctrl)) sim_debug (dbits, (lp)->mp->dptr, "%s", msg); else (void)0 #define tmxr_debug_return(lp, val) if (sim_deb && (val) && (lp)->mp && (lp)->mp->dptr && (TMXR_DBG_RET & (lp)->mp->dptr->dctrl)) sim_debug (TMXR_DBG_RET, (lp)->mp->dptr, "Ln%d: 0x%x\n", (int)((lp)-(lp)->mp->ldsc), val); else (void)0 #define tmxr_debug_trace(mp, msg) if (sim_deb && (mp)->dptr && (TMXR_DBG_TRC & (mp)->dptr->dctrl)) sim_debug (TMXR_DBG_TRC, mp->dptr, "%s\n", (msg)); else (void)0 #define tmxr_debug_trace_line(lp, msg) if (sim_deb && (lp)->mp && (lp)->mp->dptr && (TMXR_DBG_TRC & (lp)->mp->dptr->dctrl)) sim_debug (TMXR_DBG_TRC, (lp)->mp->dptr, "Ln%d:%s\n", (int)((lp)-(lp)->mp->ldsc), (msg)); else (void)0