Fix systematic off-by-one errors in unit number range checks.
Found by: FlexeLint
This commit is contained in:
parent
170ff8a070
commit
dc5b07a729
@ -156,7 +156,7 @@ get_trace_data_from_l1(i4b_trace_hdr_t *hdr, int len, char *buf)
|
||||
|
||||
/* check valid unit no */
|
||||
|
||||
if((unit = hdr->unit) > NI4BTRC)
|
||||
if((unit = hdr->unit) >= NI4BTRC)
|
||||
{
|
||||
printf("i4b_trace: get_trace_data_from_l1 - unit > NI4BTRC!\n");
|
||||
return(0);
|
||||
|
@ -502,8 +502,8 @@ avma1pp_attach_avma1pp(device_t dev)
|
||||
bzero(sc, sizeof(struct l1_softc));
|
||||
|
||||
/* probably not really required */
|
||||
if(unit > IFPI_MAXUNIT) {
|
||||
printf("avma1pp%d: Error, unit > IFPI_MAXUNIT!\n", unit);
|
||||
if(unit >= IFPI_MAXUNIT) {
|
||||
printf("avma1pp%d: Error, unit >= IFPI_MAXUNIT!\n", unit);
|
||||
splx(s);
|
||||
return(ENXIO);
|
||||
}
|
||||
|
@ -457,8 +457,8 @@ avma1pp2_attach_avma1pp(device_t dev)
|
||||
bzero(sc, sizeof(struct l1_softc));
|
||||
|
||||
/* probably not really required */
|
||||
if(unit > IFPI2_MAXUNIT) {
|
||||
printf("ifpi2-%d: Error, unit > IFPI_MAXUNIT!\n", unit);
|
||||
if(unit >= IFPI2_MAXUNIT) {
|
||||
printf("ifpi2-%d: Error, unit >= IFPI_MAXUNIT!\n", unit);
|
||||
splx(s);
|
||||
return(ENXIO);
|
||||
}
|
||||
|
@ -470,8 +470,8 @@ avm_pnp_attach(device_t dev)
|
||||
bzero(sc, sizeof(struct l1_softc));
|
||||
|
||||
/* probably not really required */
|
||||
if(unit > IFPNP_MAXUNIT) {
|
||||
printf("avm_pnp%d: Error, unit > IFPNP_MAXUNIT!\n", unit);
|
||||
if(unit >= IFPNP_MAXUNIT) {
|
||||
printf("avm_pnp%d: Error, unit >= IFPNP_MAXUNIT!\n", unit);
|
||||
splx(s);
|
||||
return(ENXIO);
|
||||
}
|
||||
|
@ -1523,9 +1523,9 @@ itjc_attach(device_t dev)
|
||||
bzero(sc, sizeof(struct l1_softc));
|
||||
|
||||
/* Probably not really required. */
|
||||
if (unit > ITJC_MAXUNIT)
|
||||
if (unit >= ITJC_MAXUNIT)
|
||||
{
|
||||
printf("itjc%d: Error, unit > ITJC_MAXUNIT!\n", unit);
|
||||
printf("itjc%d: Error, unit >= ITJC_MAXUNIT!\n", unit);
|
||||
splx(s);
|
||||
return ENXIO;
|
||||
}
|
||||
|
@ -226,8 +226,8 @@ void i4b_next_l2state(l2_softc_t *l2sc, int event)
|
||||
int (*savpostfsmfunc)(int) = NULL;
|
||||
|
||||
/* check event number */
|
||||
if(event > N_EVENTS)
|
||||
panic("i4b_l2fsm.c: event > N_EVENTS\n");
|
||||
if(event >= N_EVENTS)
|
||||
panic("i4b_l2fsm.c: event >= N_EVENTS\n");
|
||||
|
||||
/* get current state and check it */
|
||||
if((currstate = l2sc->Q921_state) > N_STATES) /* failsafe */
|
||||
|
Loading…
Reference in New Issue
Block a user