Changeset View
Changeset View
Standalone View
Standalone View
sys/net/bpf.c
Show First 20 Lines • Show All 1,509 Lines • ▼ Show 20 Lines | case BIOCFLUSH: | ||||
reset_d(d); | reset_d(d); | ||||
BPFD_UNLOCK(d); | BPFD_UNLOCK(d); | ||||
break; | break; | ||||
/* | /* | ||||
* Put interface into promiscuous mode. | * Put interface into promiscuous mode. | ||||
*/ | */ | ||||
case BIOCPROMISC: | case BIOCPROMISC: | ||||
BPF_LOCK(); | |||||
if (d->bd_bif == NULL) { | if (d->bd_bif == NULL) { | ||||
/* | /* | ||||
* No interface attached yet. | * No interface attached yet. | ||||
*/ | */ | ||||
error = EINVAL; | error = EINVAL; | ||||
break; | } else if (d->bd_promisc == 0) { | ||||
} | |||||
if (d->bd_promisc == 0) { | |||||
error = ifpromisc(d->bd_bif->bif_ifp, 1); | error = ifpromisc(d->bd_bif->bif_ifp, 1); | ||||
if (error == 0) | if (error == 0) | ||||
d->bd_promisc = 1; | d->bd_promisc = 1; | ||||
} else { | |||||
error = 0; | |||||
melifaro: Nit: maybe set error to 0 initially to avoid an additional condition? | |||||
markjAuthorUnsubmitted Done Inline ActionsThis branch is redundant, we can assume that error is already initialized to zero. That's what this handler did before, and others make the same assumption. So I'll just remove this bit. markj: This branch is redundant, we can assume that `error` is already initialized to zero. That's… | |||||
} | } | ||||
BPF_UNLOCK(); | |||||
break; | break; | ||||
/* | /* | ||||
* Get current data link type. | * Get current data link type. | ||||
*/ | */ | ||||
case BIOCGDLT: | case BIOCGDLT: | ||||
BPF_LOCK(); | BPF_LOCK(); | ||||
if (d->bd_bif == NULL) | if (d->bd_bif == NULL) | ||||
▲ Show 20 Lines • Show All 1,626 Lines • Show Last 20 Lines |
Nit: maybe set error to 0 initially to avoid an additional condition?