Compiler suggested cleanup
This commit is contained in:
parent
c046a29cba
commit
0450a9b430
7 changed files with 60 additions and 71 deletions
12
scp.c
12
scp.c
|
@ -888,9 +888,10 @@ while (stat != SCPE_EXIT) { /* in case exit */
|
|||
cptr = (*sim_vm_read) (cbuf, CBUFSIZE, stdin);
|
||||
}
|
||||
else cptr = read_line_p ("sim> ", cbuf, CBUFSIZE, stdin);/* read with prmopt*/
|
||||
if (cptr == NULL) /* EOF? */
|
||||
if (cptr == NULL) { /* EOF? */
|
||||
if (sim_ttisatty()) continue; /* ignore tty EOF */
|
||||
else break; /* otherwise exit */
|
||||
}
|
||||
if (*cptr == 0) /* ignore blank */
|
||||
continue;
|
||||
sub_args (cbuf, gbuf, sizeof(gbuf), argv);
|
||||
|
@ -1242,11 +1243,12 @@ do {
|
|||
if (staying &&
|
||||
(sim_on_check[sim_do_depth]) &&
|
||||
(stat != SCPE_OK) &&
|
||||
(stat != SCPE_STEP))
|
||||
(stat != SCPE_STEP)) {
|
||||
if ((stat <= SCPE_MAX_ERR) && sim_on_actions[sim_do_depth][stat])
|
||||
sim_brk_act[sim_do_depth] = sim_on_actions[sim_do_depth][stat];
|
||||
else
|
||||
sim_brk_act[sim_do_depth] = sim_on_actions[sim_do_depth][0];
|
||||
}
|
||||
if (sim_vm_post != NULL)
|
||||
(*sim_vm_post) (TRUE);
|
||||
} while (staying);
|
||||
|
@ -2995,11 +2997,12 @@ if (uptr == NULL)
|
|||
return SCPE_IERR;
|
||||
if (!(uptr->flags & UNIT_ATTABLE)) /* attachable? */
|
||||
return SCPE_NOATT;
|
||||
if (!(uptr->flags & UNIT_ATT)) /* not attached? */
|
||||
if (!(uptr->flags & UNIT_ATT)) { /* not attached? */
|
||||
if (sim_switches & SIM_SW_REST) /* restoring? */
|
||||
return SCPE_OK; /* allow detach */
|
||||
else
|
||||
return SCPE_NOATT; /* complain */
|
||||
}
|
||||
if ((dptr = find_dev_from_unit (uptr)) == NULL)
|
||||
return SCPE_OK;
|
||||
if (uptr->flags & UNIT_BUF) {
|
||||
|
@ -3672,7 +3675,7 @@ for (i = 1; (dptr = sim_devices[i]) != NULL; i++) { /* flush attached files
|
|||
uptr = dptr->units + j;
|
||||
if ((uptr->flags & UNIT_ATT) && /* attached, */
|
||||
!(uptr->flags & UNIT_BUF) && /* not buffered, */
|
||||
(uptr->fileref)) /* real file, */
|
||||
(uptr->fileref)) { /* real file, */
|
||||
if (uptr->io_flush) /* unit specific flush routine */
|
||||
uptr->io_flush (uptr);
|
||||
else
|
||||
|
@ -3681,6 +3684,7 @@ for (i = 1; (dptr = sim_devices[i]) != NULL; i++) { /* flush attached files
|
|||
fflush (uptr->fileref);
|
||||
}
|
||||
}
|
||||
}
|
||||
sim_cancel (&sim_step_unit); /* cancel step timer */
|
||||
sim_throt_cancel (); /* cancel throttle */
|
||||
AIO_UPDATE_QUEUE;
|
||||
|
|
57
sim_disk.c
57
sim_disk.c
|
@ -1028,7 +1028,7 @@ if (created) {
|
|||
}
|
||||
|
||||
capac = size_function (uptr->fileref);
|
||||
if (capac && (capac != (t_addr)-1))
|
||||
if (capac && (capac != (t_addr)-1)) {
|
||||
if (dontautosize) {
|
||||
if ((capac < (uptr->capac*ctx->capac_factor)) && (DKUF_F_STD != DK_GET_FMT (uptr))) {
|
||||
if (!sim_quiet) {
|
||||
|
@ -1043,6 +1043,7 @@ if (capac && (capac != (t_addr)-1))
|
|||
else
|
||||
if ((capac > (uptr->capac*ctx->capac_factor)) || (DKUF_F_STD != DK_GET_FMT (uptr)))
|
||||
uptr->capac = capac/ctx->capac_factor;
|
||||
}
|
||||
|
||||
#if defined (SIM_ASYNCH_IO)
|
||||
sim_disk_set_async (uptr, completion_delay);
|
||||
|
@ -1201,10 +1202,11 @@ if (ctx->dptr->dctrl & reason) {
|
|||
strbuf[sidx] = '\0';
|
||||
sim_debug (reason, ctx->dptr, "%04X%-48s %s\n", i, outbuf, strbuf);
|
||||
}
|
||||
if (same > 0)
|
||||
if (same > 0) {
|
||||
sim_debug (reason, ctx->dptr, "%04X thru %04X same as above\n", i-(16*same), len-1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -1524,7 +1526,7 @@ return TRUE;
|
|||
static t_stat sim_os_disk_info_raw (FILE *Disk, uint32 *sector_size, uint32 *removable)
|
||||
{
|
||||
DWORD IoctlReturnSize;
|
||||
#ifndef __GNUC__
|
||||
#ifdef IOCTL_STORAGE_GET_DEVICE_NUMBER
|
||||
STORAGE_DEVICE_NUMBER Device;
|
||||
|
||||
ZeroMemory (&Device, sizeof (Device));
|
||||
|
@ -2192,19 +2194,9 @@ typedef struct _VHD_DynamicDiskHeader {
|
|||
#define VHD_BAT_FREE_ENTRY (0xFFFFFFFF)
|
||||
#define VHD_DATA_BLOCK_ALIGNMENT ((uint64)4096) /* Optimum when underlying storage has 4k sectors */
|
||||
|
||||
static char *VHD_DiskTypes[] =
|
||||
{
|
||||
"None", /* 0 */
|
||||
"Reserved (deprecated)", /* 1 */
|
||||
"Fixed hard disk", /* 2 */
|
||||
#define VHD_DT_Fixed 2
|
||||
"Dynamic hard disk", /* 3 */
|
||||
#define VHD_DT_Dynamic 3
|
||||
"Differencing hard disk", /* 4 */
|
||||
#define VHD_DT_Differencing 4
|
||||
"Reserved (deprecated)", /* 5 */
|
||||
"Reserved (deprecated)", /* 6 */
|
||||
};
|
||||
#define VHD_DT_Fixed 2 /* Fixed hard disk */
|
||||
#define VHD_DT_Dynamic 3 /* Dynamic hard disk */
|
||||
#define VHD_DT_Differencing 4 /* Differencing hard disk */
|
||||
|
||||
static uint32 NtoHl(uint32 value);
|
||||
|
||||
|
@ -2345,13 +2337,14 @@ if (!File) {
|
|||
Return = errno;
|
||||
goto Return_Cleanup;
|
||||
}
|
||||
if (ModifiedTimeStamp)
|
||||
if (ModifiedTimeStamp) {
|
||||
if (stat (szVHDPath, &statb)) {
|
||||
Return = errno;
|
||||
goto Return_Cleanup;
|
||||
}
|
||||
else
|
||||
*ModifiedTimeStamp = NtoHl ((uint32)(statb.st_mtime-946684800));
|
||||
}
|
||||
position = sim_fsize_ex (File);
|
||||
if (((int64)position) == -1) {
|
||||
Return = errno;
|
||||
|
@ -3168,11 +3161,12 @@ for (i=0; i < strlen (FullParentVHDPath); i++)
|
|||
ExpandToFullPath (szVHDPath, FullVHDPath, BytesPerSector);
|
||||
HostPathToVhdPath (FullVHDPath, FullVHDPath, BytesPerSector);
|
||||
for (i=0, RelativeMatch=UpDirectories=0; i<strlen(FullVHDPath); i++)
|
||||
if (FullVHDPath[i] == '\\')
|
||||
if (FullVHDPath[i] == '\\') {
|
||||
if (memcmp (FullVHDPath, FullParentVHDPath, i+1))
|
||||
++UpDirectories;
|
||||
else
|
||||
RelativeMatch = i;
|
||||
}
|
||||
if (RelativeMatch) {
|
||||
char UpDir[4] = "..\\";
|
||||
|
||||
|
@ -3410,33 +3404,6 @@ for (i=0; i<BufferSize; ++i)
|
|||
return TRUE;
|
||||
}
|
||||
|
||||
static t_bool
|
||||
VhdBlockHasAllZeroSectors(void *Block, size_t BlockSize)
|
||||
{
|
||||
uint8 *BitMap = (uint8 *)Block;
|
||||
size_t SectorSize = 512;
|
||||
size_t BitMapSize = (BlockSize/SectorSize+7)/8;
|
||||
uint8 *Buffer = BitMap + BitMapSize;
|
||||
size_t Sector;
|
||||
|
||||
for (Sector=0; Sector<BlockSize/SectorSize; ++Sector) {
|
||||
/* We need Endian rules for BitMap interpretation
|
||||
These are not documented in the Version 1.0 specification, AND
|
||||
observations of Virtual PC's and Hyper-V's use of VHD's suggests
|
||||
that they really don't manage this detail at the sector level.
|
||||
What they appear to do is that whenever a Block is instantiated
|
||||
All potential bitmap bits are set to 1 which means that the
|
||||
current block has fully populated data for the current VHD.
|
||||
The same is true in the differencing disk case (i.e. a copy of
|
||||
the whole block is made from the parent to the current
|
||||
differencing disk whenever any data is written to a new block). */
|
||||
if (!BufferIsZeros(Buffer, SectorSize))
|
||||
return FALSE;
|
||||
Buffer += SectorSize;
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static t_stat
|
||||
WriteVirtualDiskSectors(VHDHANDLE hVHD,
|
||||
uint8 *buf,
|
||||
|
|
|
@ -528,6 +528,7 @@ void eth_packet_trace_ex(ETH_DEV* dev, const uint8 *msg, int len, char* txt, int
|
|||
int i, same, group, sidx, oidx;
|
||||
char outbuf[80], strbuf[18];
|
||||
static char hex[] = "0123456789ABCDEF";
|
||||
|
||||
for (i=same=0; i<len; i += 16) {
|
||||
if ((i > 0) && (0 == memcmp(&msg[i], &msg[i-16], 16))) {
|
||||
++same;
|
||||
|
@ -551,10 +552,11 @@ void eth_packet_trace_ex(ETH_DEV* dev, const uint8 *msg, int len, char* txt, int
|
|||
strbuf[sidx] = '\0';
|
||||
sim_debug(reason, dev->dptr, "%04X%-48s %s\n", i, outbuf, strbuf);
|
||||
}
|
||||
if (same > 0)
|
||||
if (same > 0) {
|
||||
sim_debug(reason, dev->dptr, "%04X thru %04X same as above\n", i-(16*same), len-1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void eth_packet_trace(ETH_DEV* dev, const uint8 *msg, int len, char* txt)
|
||||
|
@ -666,6 +668,7 @@ void eth_zero(ETH_DEV* dev)
|
|||
static ETH_DEV **eth_open_devices = NULL;
|
||||
static int eth_open_device_count = 0;
|
||||
|
||||
#if defined (USE_NETWORK) || defined (USE_SHARED)
|
||||
static void _eth_add_to_open_list (ETH_DEV* dev)
|
||||
{
|
||||
eth_open_devices = realloc(eth_open_devices, (eth_open_device_count+1)*sizeof(*eth_open_devices));
|
||||
|
@ -684,6 +687,7 @@ for (i=0; i<eth_open_device_count; ++i)
|
|||
break;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
t_stat eth_show (FILE* st, UNIT* uptr, int32 val, void* desc)
|
||||
{
|
||||
|
|
|
@ -1246,11 +1246,12 @@ int written;
|
|||
|
||||
written = write (port, (void *) buffer, (size_t) count); /* write the buffer to the serial port */
|
||||
|
||||
if (written == -1)
|
||||
if (written == -1) {
|
||||
if (errno != EAGAIN) /* unexpected error? */
|
||||
sim_error_serial ("write", errno); /* report it */
|
||||
else
|
||||
written = 0; /* not an error, but nothing written */
|
||||
}
|
||||
|
||||
return (int32) written; /* return number of characters written */
|
||||
}
|
||||
|
|
11
sim_sock.c
11
sim_sock.c
|
@ -534,11 +534,12 @@ if (hostp != NULL) {
|
|||
}
|
||||
}
|
||||
if (host) /* host wanted? */
|
||||
if (hostp != NULL)
|
||||
if (hostp != NULL) {
|
||||
if (strlen(hostp) >= host_len)
|
||||
return SCPE_ARG; /* no room */
|
||||
else
|
||||
strcpy (host, hostp);
|
||||
}
|
||||
if (validate_addr) {
|
||||
struct addrinfo *ai_host, *ai_validate, *ai;
|
||||
t_stat status;
|
||||
|
@ -575,7 +576,6 @@ WORD wVersionRequested;
|
|||
WSADATA wsaData;
|
||||
wVersionRequested = MAKEWORD (2, 2);
|
||||
|
||||
|
||||
err = WSAStartup (wVersionRequested, &wsaData); /* start Winsock */
|
||||
if (err != 0)
|
||||
printf ("Winsock: startup error %d\n", err);
|
||||
|
@ -583,9 +583,16 @@ if (err != 0)
|
|||
load_ws2 ();
|
||||
#endif /* endif AF_INET6 */
|
||||
#else /* Use native addrinfo APIs */
|
||||
#if defined(AF_INET6)
|
||||
p_getaddrinfo = (getaddrinfo_func)getaddrinfo;
|
||||
p_getnameinfo = (getnameinfo_func)getnameinfo;
|
||||
p_freeaddrinfo = (freeaddrinfo_func)freeaddrinfo;
|
||||
#else
|
||||
/* Native APIs not available, connect stubs */
|
||||
p_getaddrinfo = (getaddrinfo_func)s_getaddrinfo;
|
||||
p_getnameinfo = (getnameinfo_func)s_getnameinfo;
|
||||
p_freeaddrinfo = (freeaddrinfo_func)s_freeaddrinfo;
|
||||
#endif /* endif AF_INET6 */
|
||||
#endif /* endif _WIN32 */
|
||||
#if defined (SIGPIPE)
|
||||
signal (SIGPIPE, SIG_IGN); /* no pipe signals */
|
||||
|
|
16
sim_tape.c
16
sim_tape.c
|
@ -515,10 +515,11 @@ if (ctx->dptr->dctrl & reason) {
|
|||
strbuf[sidx] = '\0';
|
||||
sim_debug (reason, ctx->dptr, "%04X%-48s %s\n", i, outbuf, strbuf);
|
||||
}
|
||||
if (same > 0)
|
||||
if (same > 0) {
|
||||
sim_debug (reason, ctx->dptr, "%04X thru %04X same as above\n", i-(16*same), len-1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Read record length forward (internal routine)
|
||||
|
@ -1640,8 +1641,9 @@ t_stat sim_tape_rewind (UNIT *uptr)
|
|||
{
|
||||
struct tape_context *ctx = (struct tape_context *)uptr->tape_ctx;
|
||||
|
||||
if (uptr->flags & UNIT_ATT)
|
||||
if (uptr->flags & UNIT_ATT) {
|
||||
sim_debug (ctx->dbit, ctx->dptr, "sim_tape_rewind(unit=%d)\n", uptr-ctx->dptr->units);
|
||||
}
|
||||
uptr->pos = 0;
|
||||
MT_CLR_PNU (uptr);
|
||||
return MTSE_OK;
|
||||
|
@ -1868,10 +1870,14 @@ t_stat sim_tape_show_capac (FILE *st, UNIT *uptr, int32 val, void *desc)
|
|||
if (uptr->capac) {
|
||||
if (uptr->capac >= (t_addr) 1000000)
|
||||
fprintf (st, "capacity=%dMB", (uint32) (uptr->capac / ((t_addr) 1000000)));
|
||||
else if (uptr->capac >= (t_addr) 1000)
|
||||
else {
|
||||
if (uptr->capac >= (t_addr) 1000)
|
||||
fprintf (st, "capacity=%dKB", (uint32) (uptr->capac / ((t_addr) 1000)));
|
||||
else fprintf (st, "capacity=%dB", (uint32) uptr->capac);
|
||||
else
|
||||
fprintf (st, "capacity=%dB", (uint32) uptr->capac);
|
||||
}
|
||||
else fprintf (st, "unlimited capacity");
|
||||
}
|
||||
else
|
||||
fprintf (st, "unlimited capacity");
|
||||
return SCPE_OK;
|
||||
}
|
||||
|
|
|
@ -896,7 +896,7 @@ if (sim_is_active_bool (uptr)) /* already active? */
|
|||
inst_per_sec = sim_timer_inst_per_sec ();
|
||||
inst_delay = (int32)((inst_per_sec*usec_delay)/1000000.0);
|
||||
#if defined(SIM_ASYNCH_IO) && defined(SIM_ASYNCH_CLOCKS)
|
||||
if ((sim_calb_tmr == -1) || /* if No timer initialized
|
||||
if ((sim_calb_tmr == -1) || /* if No timer initialized */
|
||||
(inst_delay < rtc_currd[sim_calb_tmr]) || /* or sooner than next clock tick? */
|
||||
(rtc_elapsed[sim_calb_tmr] < sim_idle_stable) || /* or not idle stable yet */
|
||||
(!(sim_asynch_enabled && sim_asynch_timer))) { /* or asynch disabled */
|
||||
|
|
Loading…
Add table
Reference in a new issue