Skip to content

Commit

Permalink
More warning reduction.
Browse files Browse the repository at this point in the history
  • Loading branch information
bscottm committed Nov 28, 2023
1 parent fe1abad commit 14a06ad
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 16 deletions.
16 changes: 8 additions & 8 deletions sim_console.c
Original file line number Diff line number Diff line change
Expand Up @@ -531,7 +531,7 @@ struct BITSAMPLE_REG {
typedef struct REMOTE REMOTE;
struct REMOTE {
int32 buf_size;
int32 buf_ptr;
size_t buf_ptr;
char *buf;
char *act_buf;
size_t act_buf_size;
Expand Down Expand Up @@ -952,7 +952,7 @@ sim_switches = saved_switches; /* restore original switches */

/* Clear pending actions */

static char *sim_rem_clract (int32 line)
static char *sim_rem_clract (size_t line)
{
REMOTE *rem = &sim_rem_consoles[line];

Expand All @@ -962,7 +962,7 @@ return rem->act = NULL;

/* Set up pending actions */

static void sim_rem_setact (int32 line, const char *action)
static void sim_rem_setact (size_t line, const char *action)
{
if (action) {
size_t act_size = strlen (action) + 1;
Expand All @@ -981,7 +981,7 @@ else

/* Get next pending action, if any */

static char *sim_rem_getact (int32 line, char *buf, int32 size)
static char *sim_rem_getact (size_t line, char *buf, size_t size)
{
char *ep;
size_t lnt;
Expand Down Expand Up @@ -1296,10 +1296,10 @@ return stat;

t_stat sim_rem_con_repeat_svc (UNIT *uptr)
{
int line = uptr - rem_con_repeat_units;
size_t line = uptr - rem_con_repeat_units;
REMOTE *rem = &sim_rem_consoles[line];

sim_debug (DBG_REP, &sim_remote_console, "sim_rem_con_repeat_svc(line=%d) - interval=%d usecs\n", line, rem->repeat_interval);
sim_debug (DBG_REP, &sim_remote_console, "sim_rem_con_repeat_svc(line=%" SIZE_T_FMT "u) - interval=%d usecs\n", line, rem->repeat_interval);
if (rem->repeat_interval) {
rem->repeat_pending = TRUE;
sim_activate_after (uptr, rem->repeat_interval); /* reschedule */
Expand Down Expand Up @@ -1362,10 +1362,10 @@ for (line = 0; line < sim_rem_con_tmxr.lines; line++)

t_stat sim_rem_con_smp_collect_svc (UNIT *uptr)
{
int line = uptr - rem_con_smp_smpl_units;
size_t line = uptr - rem_con_smp_smpl_units;
REMOTE *rem = &sim_rem_consoles[line];

sim_debug (DBG_SAM, &sim_remote_console, "sim_rem_con_smp_collect_svc(line=%d) - interval=%d, dither=%d%%\n", line, rem->smp_sample_interval, rem->smp_sample_dither_pct);
sim_debug (DBG_SAM, &sim_remote_console, "sim_rem_con_smp_collect_svc(line=%" SIZE_T_FMT "u) - interval=%d, dither=%d%%\n", line, rem->smp_sample_interval, rem->smp_sample_dither_pct);
if (rem->smp_sample_interval && (rem->smp_reg_count != 0)) {
int32 event_time = rem->smp_sample_interval;

Expand Down
13 changes: 9 additions & 4 deletions sim_fio.c
Original file line number Diff line number Diff line change
Expand Up @@ -161,8 +161,7 @@ return c;

void sim_buf_copy_swapped (void *dbuf, const void *sbuf, size_t size, size_t count)
{
size_t j;
size_t k;
size_t j, k;
const unsigned char *sptr = (const unsigned char *)sbuf;
unsigned char *dptr = (unsigned char *)dbuf;

Expand All @@ -171,8 +170,12 @@ if (sim_end || (size == sizeof (char))) {
return;
}
for (j = 0; j < count; j++) { /* loop on items */
for (k = size - 1; k > 0; k--)
*(dptr + k) = *sptr++;
/* Unsigned countdown loop. Predecrement k before it's used inside the
loop so that k == 0 in the loop body to process the last item, then
terminate. Initialize k to size for the same reason: the predecrement
gives us size - 1 in the loop body. */
for (k = size; k > 0; /* empty */)
*(dptr + --k) = *sptr++;
dptr = dptr + size;
}
}
Expand Down Expand Up @@ -953,6 +956,8 @@ char *sim_getcwd (char *buf, size_t buf_size)
{
#if defined (VMS)
return getcwd (buf, buf_size, 0);
#elif defined(__MINGW64__) ||defined(_MSC_VER) || defined(__MINGW32__)
return _getcwd (buf, (int) buf_size);
#else
return getcwd (buf, buf_size);
#endif
Expand Down
11 changes: 7 additions & 4 deletions sim_imd.c
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,8 @@ static t_stat diskParse(DISK_INFO *myDisk, uint32 isVerbose)
uint8 sectorHeadMap[256];
uint8 sectorCylMap[256];
uint32 sectorSize, sectorHeadwithFlags, sectRecordType;
uint32 hdrBytes, i;
size_t hdrBytes;
uint32 i;
uint8 start_sect;

uint32 TotalSectorCount = 0;
Expand Down Expand Up @@ -160,7 +161,7 @@ static t_stat diskParse(DISK_INFO *myDisk, uint32 isVerbose)
break; /* detected end of IMD file */

if (hdrBytes != 5) {
sim_printf("SIM_IMD: Header read returned %d bytes instead of 5.\n", hdrBytes);
sim_printf("SIM_IMD: Header read returned %" SIZE_T_FMT "u bytes instead of 5.\n", hdrBytes);
return (SCPE_OPENERR);
}

Expand Down Expand Up @@ -361,7 +362,8 @@ t_stat diskCreate(FILE *fileref, const char *ctlr_comment)
char *curptr;
char *result;
uint8 answer;
int32 len, remaining;
size_t len;
size_t remaining;

if(fileref == NULL) {
return (SCPE_OPENERR);
Expand All @@ -386,7 +388,8 @@ t_stat diskCreate(FILE *fileref, const char *ctlr_comment)
remaining = MAX_COMMENT_LEN;
do {
sim_printf("IMD> ");
result = fgets(curptr, remaining - 3, stdin);
/* ISO C says that the 2nd argument is an int, not size_t. */
result = fgets(curptr, (int) (remaining - 3), stdin);
if ((result == NULL) || (strcmp(curptr, ".\n") == 0)) {
remaining = 0;
} else {
Expand Down

0 comments on commit 14a06ad

Please sign in to comment.