From 97ea1cf463b6500ebe6961396957e137ab3801b8 Mon Sep 17 00:00:00 2001 From: Richard Cornwell Date: Sun, 9 Jun 2019 15:22:11 -0400 Subject: [PATCH] I7000: Fixed tape handling errors and coverity errors. --- I7000/i7000_ht.c | 4 ++-- I7000/i7000_mt.c | 16 ++++---------- I7000/i701_sys.c | 54 ++++++++++++++++++++++++------------------------ 3 files changed, 33 insertions(+), 41 deletions(-) diff --git a/I7000/i7000_ht.c b/I7000/i7000_ht.c index efda218a..7e3cd0cf 100644 --- a/I7000/i7000_ht.c +++ b/I7000/i7000_ht.c @@ -183,8 +183,8 @@ MTAB ht_mod[] = { {MTUF_WLK, MTUF_WLK, "write locked", "LOCKED", NULL, NULL, NULL, "no Write ring in place"}, {MTAB_XTD | MTAB_VUN, 0, "FORMAT", "FORMAT", - &sim_tape_set_fmt, &sim_tape_show_fmt, NULL, - "Set/Display tape format (SIMH, E11, TPC, P7B, AWS, TAR)" }, + &sim_tape_set_fmt, &sim_tape_show_fmt, NULL, + "Set/Display tape format (SIMH, E11, TPC, P7B)" }, {MTAB_XTD | MTAB_VUN, 0, "LENGTH", "LENGTH", NULL, &sim_tape_show_capac, NULL, "Set unit n capacity to arg MB (0 = unlimited)" }, diff --git a/I7000/i7000_mt.c b/I7000/i7000_mt.c index ce605594..23f26471 100644 --- a/I7000/i7000_mt.c +++ b/I7000/i7000_mt.c @@ -254,7 +254,7 @@ MTAB mt_mod[] = { #endif {MTAB_XTD | MTAB_VUN, 0, "FORMAT", "FORMAT", &sim_tape_set_fmt, &sim_tape_show_fmt, NULL, - "Set/Display tape format (SIMH, E11, TPC, P7B, AWS, TAR)" }, + "Set/Display tape format (SIMH, E11, TPC, P7B)"}, {MTAB_XTD | MTAB_VUN, 0, "LENGTH", "LENGTH", &sim_tape_set_capac, &sim_tape_show_capac, NULL, "Set unit n capacity to arg MB (0 = unlimited)" }, @@ -604,12 +604,14 @@ uint32 mt_cmd(UNIT * uptr, uint16 cmd, uint16 dev) case IO_SDL: uptr->u5 |= MT_RDY; /* Command is quick */ uptr->flags |= MTUF_LDN; + sim_tape_set_dens (uptr, MT_DENS_200, NULL, NULL); sim_debug(DEBUG_CMD, dptr, "SDN unit=%d low\n", unit); return SCPE_OK; case IO_SDH: uptr->u5 |= MT_RDY; /* Command is quick */ uptr->flags &= ~MTUF_LDN; + sim_tape_set_dens (uptr, MT_DENS_556, NULL, NULL); sim_debug(DEBUG_CMD, dptr, "SDN unit=%d high\n", unit); return SCPE_OK; @@ -1334,21 +1336,13 @@ mt_ini(UNIT * uptr, t_bool f) t_stat mt_reset(DEVICE * dptr) { - UNIT *uptr = dptr->units; - uint32 i; - for (i = 0; i < dptr->numunits; i++) { - sim_tape_set_dens (uptr, - ((uptr->flags & MTUF_LDN) ? MT_DENS_200 : MT_DENS_556), - NULL, NULL); - uptr++; - } return SCPE_OK; } t_stat mt_tape_density(UNIT * uptr, int32 val, CONST char *cptr, void *desc) { - return SCPE_OK; +return sim_tape_set_dens(uptr, (val == MTUF_LDN) ? MT_DENS_200 : MT_DENS_556, NULL, NULL); } t_stat @@ -1361,8 +1355,6 @@ mt_attach(UNIT * uptr, CONST char *file) uptr->u3 = 0; uptr->u5 |= MT_RDY; uptr->flags |= MTUF_ONLINE; - uptr->dynflags = MT_200_VALID | MT_556_VALID | - (((uptr->flags & MTUF_LDN) ? MT_556_VALID : MT_200_VALID) < UNIT_V_DF_TAPE); return SCPE_OK; } diff --git a/I7000/i701_sys.c b/I7000/i701_sys.c index 28dceb21..1c75b578 100644 --- a/I7000/i701_sys.c +++ b/I7000/i701_sys.c @@ -170,8 +170,8 @@ sim_load(FILE * fileref, CONST char *cptr, CONST char *fnam, int flag) } } } else if (match_ext(fnam, "oct")) { - while (fgets(&buf[0], 160, fileref) != 0) { - for(p = &buf[0]; *p == ' ' || *p == '\t'; p++); + while (fgets((char *)buf, 80, fileref) != 0) { + for(p = (char *)buf; *p == ' ' || *p == '\t'; p++); /* Grab address */ for(addr = 0; *p >= '0' && *p <= '7'; p++) addr = (addr << 3) + *p - '0'; @@ -184,8 +184,8 @@ sim_load(FILE * fileref, CONST char *cptr, CONST char *fnam, int flag) } } } else if (match_ext(fnam, "txt")) { - while (fgets(&buf[0], 160, fileref) != 0) { - for(p = &buf[0]; *p == ' ' || *p == '\t'; p++); + while (fgets((char *)buf, 80, fileref) != 0) { + for(p = (char *)buf; *p == ' ' || *p == '\t'; p++); /* Grab address */ for(addr = 0; *p >= '0' && *p <= '7'; p++) addr = (addr << 3) + *p - '0'; @@ -413,31 +413,31 @@ parse_sym(CONST char *cptr, t_addr addr, UNIT * uptr, t_value * val, int32 sw) if (sw & SWMASK('M')) { t_opcode *op; - do { - i = 0; - sign = 0; - f = 0; - if (*cptr == ',') { - d <<= 18; - cptr++; - } - /* Skip blanks */ - while (isspace(*cptr)) - cptr++; - /* Grab opcode */ - cptr = get_glyph(cptr, opcode, ','); + i = 0; + sign = 0; + f = 0; +next: + /* Skip blanks */ + while (isspace(*cptr)) + cptr++; + /* Grab opcode */ + cptr = get_glyph(cptr, opcode, ','); - if ((op = find_opcode(opcode, base_ops)) != 0) { - d |= (t_uint64) op->opbase << 12; - } else { - return STOP_UUO; - } + if ((op = find_opcode(opcode, base_ops)) != 0) { + d |= (t_uint64) op->opbase << 12; + } else { + return STOP_UUO; + } - cptr = get_glyph(cptr, opcode, ','); - tag = parse_addr(&cpu_dev, opcode, &arg); - if (*arg != opcode[0]) - d += (t_value)tag; - } while (*cptr == ','); + cptr = get_glyph(cptr, opcode, ','); + tag = parse_addr(&cpu_dev, opcode, &arg); + if (*arg != opcode[0]) + d += (t_value)tag; + if (*cptr == ',') { + d <<= 18; + cptr++; + goto next; + } if (*cptr != '\0') return STOP_UUO; *val = d;