SCP: Fix Coverity identified issues/noise
This commit is contained in:
parent
716df3c297
commit
2840e3b67f
2 changed files with 32 additions and 30 deletions
|
@ -4240,7 +4240,7 @@ static void ansi_fill_text_buffer (FILE *f, char *buf, size_t buf_size, size_t r
|
||||||
memcpy (buf + offset, tmp, move_size);
|
memcpy (buf + offset, tmp, move_size);
|
||||||
offset += move_size;
|
offset += move_size;
|
||||||
if (offset == buf_size) {
|
if (offset == buf_size) {
|
||||||
fseek (f, start + move_size, SEEK_SET);
|
(void)fseek (f, start + move_size, SEEK_SET);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
60
sim_timer.c
60
sim_timer.c
|
@ -2530,8 +2530,8 @@ else {
|
||||||
}
|
}
|
||||||
crtc->hz = 0; /* back to 0 */
|
crtc->hz = 0; /* back to 0 */
|
||||||
}
|
}
|
||||||
|
sim_debug (DBG_CAL|DBG_INT, &sim_timer_dev, "_rtcn_configure_calibrated_clock(newtmr=%d) - Changing Calibrated Timer from %d (%dHz) to %d (%dHz)\n", newtmr, sim_calb_tmr, crtc->last_hz, tmr, rtc->hz);
|
||||||
}
|
}
|
||||||
sim_debug (DBG_CAL|DBG_INT, &sim_timer_dev, "_rtcn_configure_calibrated_clock(newtmr=%d) - Changing Calibrated Timer from %d (%dHz) to %d (%dHz)\n", newtmr, sim_calb_tmr, crtc->hz, tmr, crtc->hz);
|
|
||||||
sim_calb_tmr = tmr;
|
sim_calb_tmr = tmr;
|
||||||
}
|
}
|
||||||
sim_calb_tmr = tmr;
|
sim_calb_tmr = tmr;
|
||||||
|
@ -2767,36 +2767,38 @@ if ((inst_delay == 0) && (usec_delay != 0))
|
||||||
inst_delay_d = inst_delay = 1; /* Minimum non-zero delay is 1 instruction */
|
inst_delay_d = inst_delay = 1; /* Minimum non-zero delay is 1 instruction */
|
||||||
if (uptr->usecs_remaining != 0.0) /* No calibrated timer yet, wait one cycle */
|
if (uptr->usecs_remaining != 0.0) /* No calibrated timer yet, wait one cycle */
|
||||||
inst_delay_d = inst_delay = 1; /* Minimum non-zero delay is 1 instruction */
|
inst_delay_d = inst_delay = 1; /* Minimum non-zero delay is 1 instruction */
|
||||||
crtc = &rtcs[sim_calb_tmr];
|
if (sim_calb_tmr != -1) {
|
||||||
if ((sim_calb_tmr != -1) && (crtc->hz)) { /* Calibrated Timer available? */
|
crtc = &rtcs[sim_calb_tmr];
|
||||||
int32 inst_til_tick = sim_activate_time (crtc->timer_unit) - 1;
|
if (crtc->hz) { /* Calibrated Timer available? */
|
||||||
int32 ticks_til_calib = crtc->hz - crtc->ticks;
|
int32 inst_til_tick = sim_activate_time (crtc->timer_unit) - 1;
|
||||||
double usecs_per_tick = floor (1000000.0 / crtc->hz);
|
int32 ticks_til_calib = crtc->hz - crtc->ticks;
|
||||||
int32 inst_til_calib = inst_til_tick + ((ticks_til_calib - 1) * crtc->currd);
|
double usecs_per_tick = floor (1000000.0 / crtc->hz);
|
||||||
uint32 usecs_til_calib = (uint32)ceil(inst_til_calib / inst_per_usec);
|
int32 inst_til_calib = inst_til_tick + ((ticks_til_calib - 1) * crtc->currd);
|
||||||
|
uint32 usecs_til_calib = (uint32)ceil(inst_til_calib / inst_per_usec);
|
||||||
|
|
||||||
if ((uptr != crtc->timer_unit) && /* Not scheduling calibrated timer */
|
if ((uptr != crtc->timer_unit) && /* Not scheduling calibrated timer */
|
||||||
(inst_til_tick > 0)) { /* and tick not pending? */
|
(inst_til_tick > 0)) { /* and tick not pending? */
|
||||||
if (inst_delay_d > (double)inst_til_calib) { /* long wait? */
|
if (inst_delay_d > (double)inst_til_calib) { /* long wait? */
|
||||||
stat = sim_clock_coschedule_tmr (uptr, sim_calb_tmr, ticks_til_calib - 1);
|
stat = sim_clock_coschedule_tmr (uptr, sim_calb_tmr, ticks_til_calib - 1);
|
||||||
uptr->usecs_remaining = (stat == SCPE_OK) ? usec_delay - usecs_til_calib : 0.0;
|
uptr->usecs_remaining = (stat == SCPE_OK) ? usec_delay - usecs_til_calib : 0.0;
|
||||||
sim_debug (DBG_TIM, &sim_timer_dev, "sim_timer_activate_after(%s, %.0f usecs) - coscheduling with with calibrated timer(%d), ticks=%d, usecs_remaining=%.0f usecs, inst_til_tick=%d, ticks_til_calib=%d, usecs_til_calib=%u\n",
|
sim_debug (DBG_TIM, &sim_timer_dev, "sim_timer_activate_after(%s, %.0f usecs) - coscheduling with with calibrated timer(%d), ticks=%d, usecs_remaining=%.0f usecs, inst_til_tick=%d, ticks_til_calib=%d, usecs_til_calib=%u\n",
|
||||||
sim_uname(uptr), usec_delay, sim_calb_tmr, ticks_til_calib, uptr->usecs_remaining, inst_til_tick, ticks_til_calib, usecs_til_calib);
|
sim_uname(uptr), usec_delay, sim_calb_tmr, ticks_til_calib, uptr->usecs_remaining, inst_til_tick, ticks_til_calib, usecs_til_calib);
|
||||||
sim_debug (DBG_CHK, &sim_timer_dev, "sim_timer_activate_after(%s, %.0f usecs) - result = %.0f usecs, %.0f usecs\n",
|
sim_debug (DBG_CHK, &sim_timer_dev, "sim_timer_activate_after(%s, %.0f usecs) - result = %.0f usecs, %.0f usecs\n",
|
||||||
sim_uname(uptr), usec_delay, sim_timer_activate_time_usecs (ouptr), sim_timer_activate_time_usecs (uptr));
|
sim_uname(uptr), usec_delay, sim_timer_activate_time_usecs (ouptr), sim_timer_activate_time_usecs (uptr));
|
||||||
return stat;
|
return stat;
|
||||||
}
|
}
|
||||||
if ((usec_delay > (2 * usecs_per_tick)) &&
|
if ((usec_delay > (2 * usecs_per_tick)) &&
|
||||||
(ticks_til_calib > 1)) { /* long wait? */
|
(ticks_til_calib > 1)) { /* long wait? */
|
||||||
double usecs_til_tick = floor (inst_til_tick / inst_per_usec);
|
double usecs_til_tick = floor (inst_til_tick / inst_per_usec);
|
||||||
|
|
||||||
stat = sim_clock_coschedule_tmr (uptr, sim_calb_tmr, 0);
|
stat = sim_clock_coschedule_tmr (uptr, sim_calb_tmr, 0);
|
||||||
uptr->usecs_remaining = (stat == SCPE_OK) ? usec_delay - usecs_til_tick : 0.0;
|
uptr->usecs_remaining = (stat == SCPE_OK) ? usec_delay - usecs_til_tick : 0.0;
|
||||||
sim_debug (DBG_TIM, &sim_timer_dev, "sim_timer_activate_after(%s, %.0f usecs) - coscheduling with with calibrated timer(%d), ticks=%d, usecs_remaining=%.0f usecs, inst_til_tick=%d, usecs_til_tick=%.0f\n",
|
sim_debug (DBG_TIM, &sim_timer_dev, "sim_timer_activate_after(%s, %.0f usecs) - coscheduling with with calibrated timer(%d), ticks=%d, usecs_remaining=%.0f usecs, inst_til_tick=%d, usecs_til_tick=%.0f\n",
|
||||||
sim_uname(uptr), usec_delay, sim_calb_tmr, 0, uptr->usecs_remaining, inst_til_tick, usecs_til_tick);
|
sim_uname(uptr), usec_delay, sim_calb_tmr, 0, uptr->usecs_remaining, inst_til_tick, usecs_til_tick);
|
||||||
sim_debug (DBG_CHK, &sim_timer_dev, "sim_timer_activate_after(%s, %.0f usecs) - result = %.0f usecs, %.0f usecs\n",
|
sim_debug (DBG_CHK, &sim_timer_dev, "sim_timer_activate_after(%s, %.0f usecs) - result = %.0f usecs, %.0f usecs\n",
|
||||||
sim_uname(uptr), usec_delay, sim_timer_activate_time_usecs (ouptr), sim_timer_activate_time_usecs (uptr));
|
sim_uname(uptr), usec_delay, sim_timer_activate_time_usecs (ouptr), sim_timer_activate_time_usecs (uptr));
|
||||||
return stat;
|
return stat;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue