From 56688be95192abe65e82ca5816e41efa99fcad1d Mon Sep 17 00:00:00 2001 From: Mark Pizzolato Date: Sat, 12 Mar 2022 07:58:04 -0800 Subject: [PATCH] SWTP6800: Fix Coverity issue --- swtp6800/common/bootrom.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/swtp6800/common/bootrom.c b/swtp6800/common/bootrom.c index 9e4d12ce..77f97d91 100644 --- a/swtp6800/common/bootrom.c +++ b/swtp6800/common/bootrom.c @@ -131,20 +131,21 @@ DEVICE BOOTROM_dev = { t_stat BOOTROM_attach (UNIT *uptr, CONST char *cptr) { t_stat r; - t_addr image_size, capac; + t_offset image_size; + t_addr capac; int i; sim_debug (DEBUG_flow, &BOOTROM_dev, "BOOTROM_attach: cptr=%s\n", cptr); if ((r = attach_unit (uptr, cptr)) != SCPE_OK) { sim_debug (DEBUG_flow, &BOOTROM_dev, "BOOTROM_attach: Error\n"); - return r; + return sim_messagef (r, "BOOTROM_attach: Failure\n"); } image_size = (t_addr)sim_fsize_ex (BOOTROM_unit.fileref); if (image_size <= 0) { - sim_printf("BOOTROM_attach: File error\n"); - return SCPE_IOERR; - } - for (capac = 0x200, i=1; capac < image_size; capac <<= 1, i++); + detach_unit (uptr); + return sim_messagef(SCPE_IOERR,"BOOTROM_attach: File empty\n"); + } + for (capac = 0x200, i=1; capac < (t_addr)image_size; capac <<= 1, i++); if (i > (UNIT_2764>>UNIT_V_MSIZE)) { detach_unit (uptr); return SCPE_ARG;