Fix systematic off-by-one errors in unit number range checks.

Found by:       FlexeLint
This commit is contained in:
phk 2003-05-31 16:57:01 +00:00
parent 7e21db8a8f
commit 01f6601707
6 changed files with 11 additions and 11 deletions

View File

@ -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);

View File

@ -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);
}

View File

@ -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);
}

View File

@ -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);
}

View File

@ -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;
}

View File

@ -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 */