pkdrv/if: fixed check for invalid adapter_num, added assert if netif can't be initialized

This commit is contained in:
goldsimon 2008-11-24 17:34:18 +00:00
parent 234cfd1dcf
commit 5f05529a22
2 changed files with 4 additions and 1 deletions

View File

@ -166,11 +166,13 @@ init_adapter(int adapter_num, char *mac_addr, input_fn input, void *arg)
}
/* invalid adapter index -> check this after printing the adapters */
if (adapter_num < 0) {
printf("Invalid adapter_num: %d\n", adapter_num);
free(pa);
return NULL;
}
/* adapter index out of range */
if (adapter_num >= AdapterNum) {
if (adapter_num > AdapterNum) {
printf("Invalid adapter_num: %d\n", adapter_num);
free(pa);
return NULL;
}

View File

@ -122,6 +122,7 @@ low_level_init(struct netif *netif)
if ((netif->state = init_adapter(PACKET_LIB_ADAPTER_NR, adapter_mac_addr,
ethernetif_process_input, netif)) == NULL) {
printf("ERROR initializing network adapter %d!\n", PACKET_LIB_ADAPTER_NR);
LWIP_ASSERT("ERROR initializing network adapter!\n", 0);
return;
}