Permalink
Browse files

Compiler cleanup for issues noticed during x64 compiles

  • Loading branch information...
1 parent 01337fe commit aa7c50eb38c05141fb761c8af5f2a828dc28651a @markpizz markpizz committed Jan 17, 2012
Showing with 36 additions and 34 deletions.
  1. +10 −9 scp.c
  2. +10 −10 sim_disk.c
  3. +3 −3 sim_fio.c
  4. +3 −3 sim_sock.c
  5. +1 −1 sim_sock.h
  6. +4 −3 sim_tape.c
  7. +5 −5 sim_tmxr.c
View
19 scp.c
@@ -1826,7 +1826,7 @@ return SCPE_OK;
t_stat show_unit (FILE *st, DEVICE *dptr, UNIT *uptr, int32 flag)
{
-int32 u = uptr - dptr->units;
+int32 u = (int32)(uptr - dptr->units);
if (flag > 1)
fprintf (st, " %s%d", sim_dname (dptr), u);
@@ -2460,7 +2460,7 @@ if (uptr->flags & UNIT_BUFABLE) { /* buffer? */
if (uptr->filebuf == NULL) /* no buffer? */
return attach_err (uptr, SCPE_MEM); /* error */
if (!sim_quiet) printf ("%s: buffering file in memory\n", sim_dname (dptr));
- uptr->hwmark = sim_fread (uptr->filebuf, /* read file */
+ uptr->hwmark = (uint32)sim_fread (uptr->filebuf, /* read file */
SZ_D (dptr), cap, uptr->fileref);
uptr->flags = uptr->flags | UNIT_BUF; /* set buffered */
}
@@ -2985,7 +2985,7 @@ for ( ;; ) { /* device loop */
READ_I (blkcnt); /* block count */
if (blkcnt < 0) /* compressed? */
limit = -blkcnt;
- else limit = sim_fread (mbuf, sz, blkcnt, rfile);
+ else limit = (int32)sim_fread (mbuf, sz, blkcnt, rfile);
if (limit <= 0) /* invalid or err? */
return SCPE_IOERR;
for (j = 0; j < limit; j++, k = k + (dptr->aincr)) {
@@ -3766,7 +3766,7 @@ for (i = 0, j = addr; i < sim_emax; i++, j = j + dptr->aincr) {
SZ_LOAD (sz, sim_eval[i], uptr->filebuf, loc);
}
else {
- sim_fseek (uptr->fileref, sz * loc, SEEK_SET);
+ sim_fseek (uptr->fileref, (t_addr)(sz * loc), SEEK_SET);
sim_fread (&sim_eval[i], sz, 1, uptr->fileref);
if ((feof (uptr->fileref)) &&
!(uptr->flags & UNIT_FIX)) {
@@ -3857,7 +3857,7 @@ for (i = 0, j = addr; i < count; i++, j = j + dptr->aincr) {
uptr->hwmark = (uint32) loc + 1;
}
else {
- sim_fseek (uptr->fileref, sz * loc, SEEK_SET);
+ sim_fseek (uptr->fileref, (t_addr)(sz * loc), SEEK_SET);
sim_fwrite (&sim_eval[i], sz, 1, uptr->fileref);
if (ferror (uptr->fileref)) {
clearerr (uptr->fileref);
@@ -4384,7 +4384,7 @@ REG *find_reg (char *cptr, char **optr, DEVICE *dptr)
{
char *tptr;
REG *rptr;
-uint32 slnt;
+size_t slnt;
if ((cptr == NULL) || (dptr == NULL) || (dptr->registers == NULL))
return NULL;
@@ -4569,7 +4569,8 @@ return pptr;
SCHTAB *get_search (char *cptr, int32 radix, SCHTAB *schptr)
{
-int32 c, logop, cmpop;
+int32 c;
+size_t logop, cmpop;
t_value logval, cmpval;
char *sptr, *tptr;
const char logstr[] = "|&^", cmpstr[] = "=!><";
@@ -4599,11 +4600,11 @@ for (logop = cmpop = -1; c = *cptr++; ) { /* loop thru clauses */
else return NULL;
} /* end for */
if (logop >= 0) {
- schptr->logic = logop;
+ schptr->logic = (int32)logop;
schptr->mask = logval;
}
if (cmpop >= 0) {
- schptr->boolop = cmpop;
+ schptr->boolop = (int32)cmpop;
schptr->comp = cmpval;
}
return schptr;
View
@@ -473,7 +473,7 @@ if (!err) {
memset (&buf[i*ctx->xfer_element_size], 0, tbc-(i*ctx->xfer_element_size));
err = ferror (uptr->fileref);
if ((!err) && (sectsread))
- *sectsread = (i*ctx->xfer_element_size+ctx->sector_size-1)/ctx->sector_size;
+ *sectsread = (t_seccnt)((i*ctx->xfer_element_size+ctx->sector_size-1)/ctx->sector_size);
}
return err;
}
@@ -587,7 +587,7 @@ if (!err) {
i = sim_fwrite (buf, ctx->xfer_element_size, tbc/ctx->xfer_element_size, uptr->fileref);
err = ferror (uptr->fileref);
if ((!err) && (sectswritten))
- *sectswritten = (i*ctx->xfer_element_size+ctx->sector_size-1)/ctx->sector_size;
+ *sectswritten = (t_seccnt)((i*ctx->xfer_element_size+ctx->sector_size-1)/ctx->sector_size);
}
return err;
}
@@ -826,7 +826,7 @@ if (sim_switches & SWMASK ('C')) { /* create vhd disk & cop
else {
uint8 *copy_buf = malloc (1024*1024);
t_lba lba;
- t_seccnt sectors_per_buffer = (1024*1024)/sector_size;
+ t_seccnt sectors_per_buffer = (t_seccnt)((1024*1024)/sector_size);
t_lba total_sectors = (t_lba)(uptr->capac/sector_size);
t_seccnt sects = sectors_per_buffer;
@@ -894,12 +894,12 @@ uptr->disk_ctx = ctx = (struct disk_context *)calloc(1, sizeof(struct disk_conte
if ((uptr->filename == NULL) || (uptr->disk_ctx == NULL))
return _err_return (uptr, SCPE_MEM);
strncpy (uptr->filename, cptr, CBUFSIZE); /* save name */
-ctx->sector_size = sector_size; /* save sector_size */
-ctx->xfer_element_size = xfer_element_size; /* save xfer_element_size */
+ctx->sector_size = (uint32)sector_size; /* save sector_size */
+ctx->xfer_element_size = (uint32)xfer_element_size; /* save xfer_element_size */
ctx->dptr = dptr; /* save DEVICE pointer */
ctx->dbit = dbit; /* save debug bit */
ctx->auto_format = auto_format; /* save that we auto selected format */
-ctx->storage_sector_size = sector_size; /* Default */
+ctx->storage_sector_size = (uint32)sector_size; /* Default */
if (sim_switches & SWMASK ('R')) { /* read only? */
if ((uptr->flags & UNIT_ROABLE) == 0) /* allowed? */
return _err_return (uptr, SCPE_NORO); /* no, error */
@@ -1470,7 +1470,7 @@ if (Removable) {
return TRUE;
}
-static t_stat sim_os_disk_info_raw (FILE *Disk, size_t *sector_size, uint32 *removable)
+static t_stat sim_os_disk_info_raw (FILE *Disk, uint32 *sector_size, uint32 *removable)
{
DWORD IoctlReturnSize;
#ifndef __GNUC__
@@ -2822,7 +2822,7 @@ ExpandToFullPath (const char *szFileSpec,
size_t BufferSize)
{
#ifdef _WIN32
-GetFullPathNameA (szFileSpec, BufferSize, szFullFileSpecBuffer, NULL);
+GetFullPathNameA (szFileSpec, (DWORD)BufferSize, szFullFileSpecBuffer, NULL);
#else
strncpy (szFullFileSpecBuffer, szFileSpec, BufferSize);
#endif
@@ -2905,14 +2905,14 @@ hVHD->Dynamic.ParentLocatorEntries[6].PlatformDataOffset = NtoHll (LocatorPositi
if (RelativeMatch) {
memcpy (hVHD->Dynamic.ParentLocatorEntries[5].PlatformCode, "W2ru", 4);
hVHD->Dynamic.ParentLocatorEntries[5].PlatformDataSpace = NtoHl (BytesPerSector);
- hVHD->Dynamic.ParentLocatorEntries[5].PlatformDataLength = NtoHl (2*strlen(RelativeParentVHDPath));
+ hVHD->Dynamic.ParentLocatorEntries[5].PlatformDataLength = NtoHl ((uint32)(2*strlen(RelativeParentVHDPath)));
hVHD->Dynamic.ParentLocatorEntries[5].Reserved = 0;
hVHD->Dynamic.ParentLocatorEntries[5].PlatformDataOffset = NtoHll (LocatorPosition+LocatorsWritten*BytesPerSector);
++LocatorsWritten;
}
memcpy (hVHD->Dynamic.ParentLocatorEntries[4].PlatformCode, "W2ku", 4);
hVHD->Dynamic.ParentLocatorEntries[4].PlatformDataSpace = NtoHl (BytesPerSector);
-hVHD->Dynamic.ParentLocatorEntries[4].PlatformDataLength = NtoHl (2*strlen(FullParentVHDPath));
+hVHD->Dynamic.ParentLocatorEntries[4].PlatformDataLength = NtoHl ((uint32)(2*strlen(FullParentVHDPath)));
hVHD->Dynamic.ParentLocatorEntries[4].Reserved = 0;
hVHD->Dynamic.ParentLocatorEntries[4].PlatformDataOffset = NtoHll (LocatorPosition+LocatorsWritten*BytesPerSector);
++LocatorsWritten;
View
@@ -96,7 +96,7 @@ if (sim_end || (count == 0) || (size == sizeof (char)))
return;
for (j = 0, dptr = sptr = (unsigned char *) bptr; /* loop on items */
j < count; j++) {
- for (k = size - 1; k >= (((int32) size + 1) / 2); k--) {
+ for (k = (int32)(size - 1); k >= (((int32) size + 1) / 2); k--) {
by = *sptr; /* swap end-for-end */
*sptr++ = *(dptr + k);
*(dptr + k) = by;
@@ -130,7 +130,7 @@ if (sim_end || (size == sizeof (char))) {
return;
}
for (j = 0; j < count; j++) { /* loop on items */
- for (k = size - 1; k >= 0; k--)
+ for (k = (int32)(size - 1); k >= 0; k--)
*(dptr + k) = *sptr++;
dptr = dptr + size;
}
@@ -153,7 +153,7 @@ if (lcnt) nbuf = nbuf + 1;
else lcnt = nelem;
total = 0;
sptr = (unsigned char *) bptr; /* init input ptr */
-for (i = nbuf; i > 0; i--) { /* loop on buffers */
+for (i = (int32)nbuf; i > 0; i--) { /* loop on buffers */
c = (i == 1)? lcnt: nelem;
sim_buf_copy_swapped (sim_flip, sptr, size, c);
sptr = sptr + size * count;
View
@@ -90,7 +90,7 @@ void sim_close_sock (SOCKET sock, t_bool master)
return;
}
-SOCKET sim_setnonblock (SOCKET sock)
+int32 sim_setnonblock (SOCKET sock)
{
return SOCKET_ERROR;
}
@@ -289,15 +289,15 @@ return;
}
#if defined (_WIN32) /* Windows */
-SOCKET sim_setnonblock (SOCKET sock)
+int32 sim_setnonblock (SOCKET sock)
{
unsigned long non_block = 1;
return ioctlsocket (sock, FIONBIO, &non_block); /* set nonblocking */
}
#elif defined (VMS) /* VMS */
-SOCKET sim_setnonblock (SOCKET sock)
+int32 sim_setnonblock (SOCKET sock)
{
int non_block = 1;
View
@@ -83,6 +83,6 @@ int32 sim_check_conn (SOCKET sock, t_bool rd);
int32 sim_read_sock (SOCKET sock, char *buf, int32 nbytes);
int32 sim_write_sock (SOCKET sock, char *msg, int32 nbytes);
void sim_close_sock (SOCKET sock, t_bool master);
-SOCKET sim_setnonblock (SOCKET sock);
+int32 sim_setnonblock (SOCKET sock);
#endif
View
@@ -764,7 +764,7 @@ if (rbc > max) { /* rec out of range? */
uptr->pos = opos;
return MTSE_INVRL;
}
-i = sim_fread (buf, sizeof (uint8), rbc, uptr->fileref);/* read record */
+i = (t_mtrlnt)sim_fread (buf, sizeof (uint8), rbc, uptr->fileref);/* read record */
if (ferror (uptr->fileref)) { /* error? */
MT_SET_PNU (uptr);
uptr->pos = opos;
@@ -823,7 +823,7 @@ if (st = sim_tape_rdlntr (uptr, &tbc)) /* read rec lnt */
*bc = rbc = MTR_L (tbc); /* strip error flag */
if (rbc > max) /* rec out of range? */
return MTSE_INVRL;
-i = sim_fread (buf, sizeof (uint8), rbc, uptr->fileref);/* read record */
+i = (t_mtrlnt)sim_fread (buf, sizeof (uint8), rbc, uptr->fileref);/* read record */
if (ferror (uptr->fileref)) /* error? */
return sim_tape_ioerr (uptr);
for ( ; i < rbc; i++) /* fill with 0's */
@@ -1765,7 +1765,8 @@ uint32 sim_tape_tpc_map (UNIT *uptr, t_addr *map)
{
t_addr tpos;
t_tpclnt bc;
-uint32 i, objc;
+size_t i;
+uint32 objc;
if ((uptr == NULL) || (uptr->fileref == NULL))
return 0;
View
@@ -212,14 +212,14 @@ if (newsock != INVALID_SOCKET) { /* got a live one? */
lp->cnms = sim_os_msec (); /* time of conn */
if (!mp->buffered) {
lp->txbpi = 0; /* init buf pointers */
- lp->txbpr = lp->txbsz - strlen (msgbuf);
+ lp->txbpr = (int32)(lp->txbsz - strlen (msgbuf));
lp->rxcnt = lp->txcnt = lp->txdrp = 0; /* init counters */
}
else
if (lp->txcnt > lp->txbsz)
lp->txbpr = (lp->txbpi + 1) % lp->txbsz;
else
- lp->txbpr = lp->txbsz - strlen (msgbuf);
+ lp->txbpr = (int32)(lp->txbsz - strlen (msgbuf));
lp->tsta = 0; /* init telnet state */
lp->xmte = 1; /* enable transmit */
lp->dstb = 0; /* default bin mode */
@@ -228,7 +228,7 @@ if (newsock != INVALID_SOCKET) { /* got a live one? */
tmxr_linemsg (lp, msgbuf); /* beginning of buffer */
lp->txbpi = psave; /* restore insertion pointer */
tmxr_poll_tx (mp); /* flush output */
- lp->txcnt -= strlen (msgbuf); /* adjust statistics */
+ lp->txcnt -= (int32)strlen (msgbuf); /* adjust statistics */
return i;
}
} /* end if newsock */
@@ -752,15 +752,15 @@ return SCPE_NOFNC;
void tmxr_msg (SOCKET sock, char *msg)
{
if (sock)
- sim_write_sock (sock, msg, strlen (msg));
+ sim_write_sock (sock, msg, (int32)strlen (msg));
return;
}
void tmxr_linemsg (TMLN *lp, char *msg)
{
int32 len;
-for (len = strlen (msg); len > 0; --len)
+for (len = (int32)strlen (msg); len > 0; --len)
tmxr_putc_ln (lp, *msg++);
return;
}

0 comments on commit aa7c50e

Please sign in to comment.