IfAPI: Style cleanup

Summary:
Clean up style issues from IfAPI additions.

Casts to (struct ifnet *) made sense when `if_t` was a `void *`, but
since it's a `struct ifnet *` it no longer makes sense.  Fix whitespace
errors, among others.

Reviewed by:	kib, glebius
Sponsored by:	Juniper Networks, Inc.
Differential Revision: https://reviews.freebsd.org/D38499
This commit is contained in:
Justin Hibbits 2023-02-10 16:33:30 -05:00
parent a3a76c3d90
commit aac2d19d93
2 changed files with 72 additions and 104 deletions

View File

@ -3964,7 +3964,6 @@ if_setlladdr(struct ifnet *ifp, const u_char *lladdr, int len)
static int static int
if_requestencap_default(struct ifnet *ifp, struct if_encap_req *req) if_requestencap_default(struct ifnet *ifp, struct if_encap_req *req)
{ {
if (req->rtype != IFENCAP_LL) if (req->rtype != IFENCAP_LL)
return (EOPNOTSUPP); return (EOPNOTSUPP);
@ -4034,7 +4033,6 @@ if_tunnel_check_nesting(struct ifnet *ifp, struct mbuf *m, uint32_t cookie,
int int
if_gethwaddr(struct ifnet *ifp, struct ifreq *ifr) if_gethwaddr(struct ifnet *ifp, struct ifreq *ifr)
{ {
if (ifp->if_hw_addr == NULL) if (ifp->if_hw_addr == NULL)
return (ENODEV); return (ENODEV);
@ -4121,7 +4119,6 @@ if_transmit_default(struct ifnet *ifp, struct mbuf *m)
static void static void
if_input_default(struct ifnet *ifp __unused, struct mbuf *m) if_input_default(struct ifnet *ifp __unused, struct mbuf *m)
{ {
m_freem(m); m_freem(m);
} }
@ -4198,47 +4195,42 @@ if_setbaudrate(struct ifnet *ifp, uint64_t baudrate)
uint64_t uint64_t
if_getbaudrate(const if_t ifp) if_getbaudrate(const if_t ifp)
{ {
return (ifp->if_baudrate);
return (((struct ifnet *)ifp)->if_baudrate);
} }
int int
if_setcapabilities(if_t ifp, int capabilities) if_setcapabilities(if_t ifp, int capabilities)
{ {
((struct ifnet *)ifp)->if_capabilities = capabilities; ifp->if_capabilities = capabilities;
return (0); return (0);
} }
int int
if_setcapabilitiesbit(if_t ifp, int setbit, int clearbit) if_setcapabilitiesbit(if_t ifp, int setbit, int clearbit)
{ {
((struct ifnet *)ifp)->if_capabilities &= ~clearbit; ifp->if_capabilities &= ~clearbit;
((struct ifnet *)ifp)->if_capabilities |= setbit; ifp->if_capabilities |= setbit;
return (0); return (0);
} }
int int
if_getcapabilities(const if_t ifp) if_getcapabilities(const if_t ifp)
{ {
return ((struct ifnet *)ifp)->if_capabilities; return (ifp->if_capabilities);
} }
int int
if_setcapenable(if_t ifp, int capabilities) if_setcapenable(if_t ifp, int capabilities)
{ {
((struct ifnet *)ifp)->if_capenable = capabilities; ifp->if_capenable = capabilities;
return (0); return (0);
} }
int int
if_setcapenablebit(if_t ifp, int setcap, int clearcap) if_setcapenablebit(if_t ifp, int setcap, int clearcap)
{ {
if(clearcap) ifp->if_capenable &= ~clearcap;
((struct ifnet *)ifp)->if_capenable &= ~clearcap; ifp->if_capenable |= setcap;
if(setcap)
((struct ifnet *)ifp)->if_capenable |= setcap;
return (0); return (0);
} }
@ -4281,19 +4273,19 @@ if_setcapenable2bit(if_t ifp, int setcap, int clearcap)
const char * const char *
if_getdname(const if_t ifp) if_getdname(const if_t ifp)
{ {
return ((struct ifnet *)ifp)->if_dname; return (ifp->if_dname);
} }
void void
if_setdname(if_t ifp, const char *dname) if_setdname(if_t ifp, const char *dname)
{ {
((struct ifnet *)ifp)->if_dname = dname; ifp->if_dname = dname;
} }
const char * const char *
if_name(if_t ifp) if_name(if_t ifp)
{ {
return ((struct ifnet *)ifp)->if_xname; return (ifp->if_xname);
} }
int int
@ -4301,7 +4293,7 @@ if_setname(if_t ifp, const char *name)
{ {
if (strlen(name) > sizeof(ifp->if_xname) - 1) if (strlen(name) > sizeof(ifp->if_xname) - 1)
return (ENAMETOOLONG); return (ENAMETOOLONG);
strlcpy(ifp->if_xname, name, sizeof(ifp->if_xname)); strcpy(ifp->if_xname, name);
return (0); return (0);
} }
@ -4309,14 +4301,14 @@ if_setname(if_t ifp, const char *name)
int int
if_togglecapenable(if_t ifp, int togglecap) if_togglecapenable(if_t ifp, int togglecap)
{ {
((struct ifnet *)ifp)->if_capenable ^= togglecap; ifp->if_capenable ^= togglecap;
return (0); return (0);
} }
int int
if_getcapenable(const if_t ifp) if_getcapenable(const if_t ifp)
{ {
return ((struct ifnet *)ifp)->if_capenable; return (ifp->if_capenable);
} }
int int
@ -4335,13 +4327,13 @@ if_getcapenable2(const if_t ifp)
int int
if_getdunit(const if_t ifp) if_getdunit(const if_t ifp)
{ {
return ((struct ifnet *)ifp)->if_dunit; return (ifp->if_dunit);
} }
int int
if_getindex(const if_t ifp) if_getindex(const if_t ifp)
{ {
return ((struct ifnet *)ifp)->if_index; return (ifp->if_index);
} }
int int
@ -4377,7 +4369,7 @@ if_freedescr(char *descrbuf)
int int
if_getalloctype(const if_t ifp) if_getalloctype(const if_t ifp)
{ {
return ((struct ifnet *)ifp)->if_alloctype; return (ifp->if_alloctype);
} }
/* /*
@ -4395,8 +4387,8 @@ if_setdev(if_t ifp, void *dev)
int int
if_setdrvflagbits(if_t ifp, int set_flags, int clear_flags) if_setdrvflagbits(if_t ifp, int set_flags, int clear_flags)
{ {
((struct ifnet *)ifp)->if_drv_flags &= ~clear_flags; ifp->if_drv_flags &= ~clear_flags;
((struct ifnet *)ifp)->if_drv_flags |= set_flags; ifp->if_drv_flags |= set_flags;
return (0); return (0);
} }
@ -4404,20 +4396,19 @@ if_setdrvflagbits(if_t ifp, int set_flags, int clear_flags)
int int
if_getdrvflags(const if_t ifp) if_getdrvflags(const if_t ifp)
{ {
return ((struct ifnet *)ifp)->if_drv_flags; return (ifp->if_drv_flags);
} }
int int
if_setdrvflags(if_t ifp, int flags) if_setdrvflags(if_t ifp, int flags)
{ {
((struct ifnet *)ifp)->if_drv_flags = flags; ifp->if_drv_flags = flags;
return (0); return (0);
} }
int int
if_setflags(if_t ifp, int flags) if_setflags(if_t ifp, int flags)
{ {
ifp->if_flags = flags; ifp->if_flags = flags;
return (0); return (0);
} }
@ -4425,30 +4416,29 @@ if_setflags(if_t ifp, int flags)
int int
if_setflagbits(if_t ifp, int set, int clear) if_setflagbits(if_t ifp, int set, int clear)
{ {
((struct ifnet *)ifp)->if_flags &= ~clear; ifp->if_flags &= ~clear;
((struct ifnet *)ifp)->if_flags |= set; ifp->if_flags |= set;
return (0); return (0);
} }
int int
if_getflags(const if_t ifp) if_getflags(const if_t ifp)
{ {
return ((struct ifnet *)ifp)->if_flags; return (ifp->if_flags);
} }
int int
if_clearhwassist(if_t ifp) if_clearhwassist(if_t ifp)
{ {
((struct ifnet *)ifp)->if_hwassist = 0; ifp->if_hwassist = 0;
return (0); return (0);
} }
int int
if_sethwassistbits(if_t ifp, int toset, int toclear) if_sethwassistbits(if_t ifp, int toset, int toclear)
{ {
((struct ifnet *)ifp)->if_hwassist &= ~toclear; ifp->if_hwassist &= ~toclear;
((struct ifnet *)ifp)->if_hwassist |= toset; ifp->if_hwassist |= toset;
return (0); return (0);
} }
@ -4456,34 +4446,34 @@ if_sethwassistbits(if_t ifp, int toset, int toclear)
int int
if_sethwassist(if_t ifp, int hwassist_bit) if_sethwassist(if_t ifp, int hwassist_bit)
{ {
((struct ifnet *)ifp)->if_hwassist = hwassist_bit; ifp->if_hwassist = hwassist_bit;
return (0); return (0);
} }
int int
if_gethwassist(const if_t ifp) if_gethwassist(const if_t ifp)
{ {
return ((struct ifnet *)ifp)->if_hwassist; return (ifp->if_hwassist);
} }
int int
if_togglehwassist(if_t ifp, int toggle_bits) if_togglehwassist(if_t ifp, int toggle_bits)
{ {
((struct ifnet *)ifp)->if_hwassist ^= toggle_bits; ifp->if_hwassist ^= toggle_bits;
return (0); return (0);
} }
int int
if_setmtu(if_t ifp, int mtu) if_setmtu(if_t ifp, int mtu)
{ {
((struct ifnet *)ifp)->if_mtu = mtu; ifp->if_mtu = mtu;
return (0); return (0);
} }
int int
if_getmtu(const if_t ifp) if_getmtu(const if_t ifp)
{ {
return ((struct ifnet *)ifp)->if_mtu; return (ifp->if_mtu);
} }
int int
@ -4493,10 +4483,10 @@ if_getmtu_family(const if_t ifp, int family)
SLIST_FOREACH(dp, &domains, dom_next) { SLIST_FOREACH(dp, &domains, dom_next) {
if (dp->dom_family == family && dp->dom_ifmtu != NULL) if (dp->dom_family == family && dp->dom_ifmtu != NULL)
return (dp->dom_ifmtu((struct ifnet *)ifp)); return (dp->dom_ifmtu(ifp));
} }
return (((struct ifnet *)ifp)->if_mtu); return (ifp->if_mtu);
} }
/* /*
@ -4625,14 +4615,14 @@ if_foreach_addr_type(if_t ifp, int type, if_addr_cb_t cb, void *cb_arg)
int int
if_setsoftc(if_t ifp, void *softc) if_setsoftc(if_t ifp, void *softc)
{ {
((struct ifnet *)ifp)->if_softc = softc; ifp->if_softc = softc;
return (0); return (0);
} }
void * void *
if_getsoftc(const if_t ifp) if_getsoftc(const if_t ifp)
{ {
return ((struct ifnet *)ifp)->if_softc; return (ifp->if_softc);
} }
void void
@ -4652,41 +4642,39 @@ if_setvtag(struct mbuf *m, uint16_t tag)
uint16_t uint16_t
if_getvtag(struct mbuf *m) if_getvtag(struct mbuf *m)
{ {
return (m->m_pkthdr.ether_vtag); return (m->m_pkthdr.ether_vtag);
} }
int int
if_sendq_empty(if_t ifp) if_sendq_empty(if_t ifp)
{ {
return IFQ_DRV_IS_EMPTY(&((struct ifnet *)ifp)->if_snd); return (IFQ_DRV_IS_EMPTY(&ifp->if_snd));
} }
struct ifaddr * struct ifaddr *
if_getifaddr(const if_t ifp) if_getifaddr(const if_t ifp)
{ {
return ((struct ifnet *)ifp)->if_addr; return (ifp->if_addr);
} }
int int
if_getamcount(const if_t ifp) if_getamcount(const if_t ifp)
{ {
return ((struct ifnet *)ifp)->if_amcount; return (ifp->if_amcount);
} }
int int
if_setsendqready(if_t ifp) if_setsendqready(if_t ifp)
{ {
IFQ_SET_READY(&((struct ifnet *)ifp)->if_snd); IFQ_SET_READY(&ifp->if_snd);
return (0); return (0);
} }
int int
if_setsendqlen(if_t ifp, int tx_desc_count) if_setsendqlen(if_t ifp, int tx_desc_count)
{ {
IFQ_SET_MAXLEN(&((struct ifnet *)ifp)->if_snd, tx_desc_count); IFQ_SET_MAXLEN(&ifp->if_snd, tx_desc_count);
((struct ifnet *)ifp)->if_snd.ifq_drv_maxlen = tx_desc_count; ifp->if_snd.ifq_drv_maxlen = tx_desc_count;
return (0); return (0);
} }
@ -4705,29 +4693,25 @@ if_getnetmapadapter(if_t ifp)
int int
if_vlantrunkinuse(if_t ifp) if_vlantrunkinuse(if_t ifp)
{ {
return ((struct ifnet *)ifp)->if_vlantrunk != NULL?1:0; return (ifp->if_vlantrunk != NULL);
} }
int void
if_init(if_t ifp, void *ctx) if_init(if_t ifp, void *ctx)
{ {
(*((struct ifnet *)ifp)->if_init)(ctx); (*ifp->if_init)(ctx);
return (0);
} }
int void
if_input(if_t ifp, struct mbuf* sendmp) if_input(if_t ifp, struct mbuf* sendmp)
{ {
(*((struct ifnet *)ifp)->if_input)((struct ifnet *)ifp, sendmp); (*ifp->if_input)(ifp, sendmp);
return (0);
} }
int int
if_transmit(if_t ifp, struct mbuf *m) if_transmit(if_t ifp, struct mbuf *m)
{ {
(*((struct ifnet *)ifp)->if_transmit)((struct ifnet *)ifp, m); return ((*ifp->if_transmit)(ifp, m));
return (0);
} }
int int
@ -4743,29 +4727,29 @@ struct mbuf *
if_dequeue(if_t ifp) if_dequeue(if_t ifp)
{ {
struct mbuf *m; struct mbuf *m;
IFQ_DRV_DEQUEUE(&((struct ifnet *)ifp)->if_snd, m);
IFQ_DRV_DEQUEUE(&ifp->if_snd, m);
return (m); return (m);
} }
int int
if_sendq_prepend(if_t ifp, struct mbuf *m) if_sendq_prepend(if_t ifp, struct mbuf *m)
{ {
IFQ_DRV_PREPEND(&((struct ifnet *)ifp)->if_snd, m); IFQ_DRV_PREPEND(&ifp->if_snd, m);
return (0); return (0);
} }
int int
if_setifheaderlen(if_t ifp, int len) if_setifheaderlen(if_t ifp, int len)
{ {
((struct ifnet *)ifp)->if_hdrlen = len; ifp->if_hdrlen = len;
return (0); return (0);
} }
caddr_t caddr_t
if_getlladdr(const if_t ifp) if_getlladdr(const if_t ifp)
{ {
return (IF_LLADDR((struct ifnet *)ifp)); return (IF_LLADDR(ifp));
} }
void * void *
@ -4775,83 +4759,72 @@ if_gethandle(u_char type)
} }
void void
if_bpfmtap(if_t ifh, struct mbuf *m) if_bpfmtap(if_t ifp, struct mbuf *m)
{ {
struct ifnet *ifp = (struct ifnet *)ifh;
BPF_MTAP(ifp, m); BPF_MTAP(ifp, m);
} }
void void
if_etherbpfmtap(if_t ifh, struct mbuf *m) if_etherbpfmtap(if_t ifp, struct mbuf *m)
{ {
struct ifnet *ifp = (struct ifnet *)ifh;
ETHER_BPF_MTAP(ifp, m); ETHER_BPF_MTAP(ifp, m);
} }
void void
if_vlancap(if_t ifh) if_vlancap(if_t ifp)
{ {
struct ifnet *ifp = (struct ifnet *)ifh;
VLAN_CAPABILITIES(ifp); VLAN_CAPABILITIES(ifp);
} }
int int
if_sethwtsomax(if_t ifp, u_int if_hw_tsomax) if_sethwtsomax(if_t ifp, u_int if_hw_tsomax)
{ {
ifp->if_hw_tsomax = if_hw_tsomax;
((struct ifnet *)ifp)->if_hw_tsomax = if_hw_tsomax;
return (0); return (0);
} }
int int
if_sethwtsomaxsegcount(if_t ifp, u_int if_hw_tsomaxsegcount) if_sethwtsomaxsegcount(if_t ifp, u_int if_hw_tsomaxsegcount)
{ {
ifp->if_hw_tsomaxsegcount = if_hw_tsomaxsegcount;
((struct ifnet *)ifp)->if_hw_tsomaxsegcount = if_hw_tsomaxsegcount;
return (0); return (0);
} }
int int
if_sethwtsomaxsegsize(if_t ifp, u_int if_hw_tsomaxsegsize) if_sethwtsomaxsegsize(if_t ifp, u_int if_hw_tsomaxsegsize)
{ {
ifp->if_hw_tsomaxsegsize = if_hw_tsomaxsegsize;
((struct ifnet *)ifp)->if_hw_tsomaxsegsize = if_hw_tsomaxsegsize;
return (0); return (0);
} }
u_int u_int
if_gethwtsomax(const if_t ifp) if_gethwtsomax(const if_t ifp)
{ {
return (ifp->if_hw_tsomax);
return (((struct ifnet *)ifp)->if_hw_tsomax);
} }
u_int u_int
if_gethwtsomaxsegcount(const if_t ifp) if_gethwtsomaxsegcount(const if_t ifp)
{ {
return (ifp->if_hw_tsomaxsegcount);
return (((struct ifnet *)ifp)->if_hw_tsomaxsegcount);
} }
u_int u_int
if_gethwtsomaxsegsize(const if_t ifp) if_gethwtsomaxsegsize(const if_t ifp)
{ {
return (ifp->if_hw_tsomaxsegsize);
return (((struct ifnet *)ifp)->if_hw_tsomaxsegsize);
} }
void void
if_setinitfn(if_t ifp, if_init_fn_t init_fn) if_setinitfn(if_t ifp, if_init_fn_t init_fn)
{ {
((struct ifnet *)ifp)->if_init = init_fn; ifp->if_init = init_fn;
} }
void void
if_setinputfn(if_t ifp, if_input_fn_t input_fn) if_setinputfn(if_t ifp, if_input_fn_t input_fn)
{ {
((struct ifnet *)ifp)->if_input = input_fn; ifp->if_input = input_fn;
} }
if_input_fn_t if_input_fn_t
@ -4863,19 +4836,19 @@ if_getinputfn(if_t ifp)
void void
if_setioctlfn(if_t ifp, if_ioctl_fn_t ioctl_fn) if_setioctlfn(if_t ifp, if_ioctl_fn_t ioctl_fn)
{ {
((struct ifnet *)ifp)->if_ioctl = (void *)ioctl_fn; ifp->if_ioctl = ioctl_fn;
} }
void void
if_setoutputfn(if_t ifp, if_output_fn_t output_fn) if_setoutputfn(if_t ifp, if_output_fn_t output_fn)
{ {
((struct ifnet *)ifp)->if_output = output_fn; ifp->if_output = output_fn;
} }
void void
if_setstartfn(if_t ifp, if_start_fn_t start_fn) if_setstartfn(if_t ifp, if_start_fn_t start_fn)
{ {
((struct ifnet *)ifp)->if_start = (void *)start_fn; ifp->if_start = start_fn;
} }
if_start_fn_t if_start_fn_t
@ -4887,7 +4860,7 @@ if_getstartfn(if_t ifp)
void void
if_settransmitfn(if_t ifp, if_transmit_fn_t start_fn) if_settransmitfn(if_t ifp, if_transmit_fn_t start_fn)
{ {
((struct ifnet *)ifp)->if_transmit = start_fn; ifp->if_transmit = start_fn;
} }
if_transmit_fn_t if_transmit_fn_t
@ -4899,21 +4872,19 @@ if_gettransmitfn(if_t ifp)
void void
if_setqflushfn(if_t ifp, if_qflush_fn_t flush_fn) if_setqflushfn(if_t ifp, if_qflush_fn_t flush_fn)
{ {
((struct ifnet *)ifp)->if_qflush = flush_fn; ifp->if_qflush = flush_fn;
} }
void void
if_setsndtagallocfn(if_t ifp, if_snd_tag_alloc_t alloc_fn) if_setsndtagallocfn(if_t ifp, if_snd_tag_alloc_t alloc_fn)
{ {
((struct ifnet *)ifp)->if_snd_tag_alloc = alloc_fn; ifp->if_snd_tag_alloc = alloc_fn;
} }
int int
if_snd_tag_alloc(struct ifnet *ifp, union if_snd_tag_alloc_params *params, if_snd_tag_alloc(if_t ifp, union if_snd_tag_alloc_params *params,
struct m_snd_tag **mstp) struct m_snd_tag **mstp)
{ {
if (ifp->if_snd_tag_alloc == NULL) if (ifp->if_snd_tag_alloc == NULL)
return (EOPNOTSUPP); return (EOPNOTSUPP);
return (ifp->if_snd_tag_alloc(ifp, params, mstp)); return (ifp->if_snd_tag_alloc(ifp, params, mstp));
@ -4922,7 +4893,6 @@ if_snd_tag_alloc(struct ifnet *ifp, union if_snd_tag_alloc_params *params,
void void
if_setgetcounterfn(if_t ifp, if_get_counter_t fn) if_setgetcounterfn(if_t ifp, if_get_counter_t fn)
{ {
ifp->if_get_counter = fn; ifp->if_get_counter = fn;
} }
@ -5062,7 +5032,6 @@ if_getl2com(if_t ifp)
static void static void
if_show_ifnet(struct ifnet *ifp) if_show_ifnet(struct ifnet *ifp)
{ {
if (ifp == NULL) if (ifp == NULL)
return; return;
db_printf("%s:\n", ifp->if_xname); db_printf("%s:\n", ifp->if_xname);
@ -5112,7 +5081,6 @@ if_show_ifnet(struct ifnet *ifp)
DB_SHOW_COMMAND(ifnet, db_show_ifnet) DB_SHOW_COMMAND(ifnet, db_show_ifnet)
{ {
if (!have_addr) { if (!have_addr) {
db_printf("usage: show ifnet <struct ifnet *>\n"); db_printf("usage: show ifnet <struct ifnet *>\n");
return; return;

View File

@ -633,7 +633,7 @@ u_int if_gethwtsomaxsegcount(const if_t ifp);
u_int if_gethwtsomaxsegsize(const if_t ifp); u_int if_gethwtsomaxsegsize(const if_t ifp);
void if_setnetmapadapter(if_t ifp, struct netmap_adapter *na); void if_setnetmapadapter(if_t ifp, struct netmap_adapter *na);
struct netmap_adapter *if_getnetmapadapter(if_t ifp); struct netmap_adapter *if_getnetmapadapter(if_t ifp);
int if_input(if_t ifp, struct mbuf* sendmp); void if_input(if_t ifp, struct mbuf* sendmp);
int if_sendq_prepend(if_t ifp, struct mbuf *m); int if_sendq_prepend(if_t ifp, struct mbuf *m);
struct mbuf *if_dequeue(if_t ifp); struct mbuf *if_dequeue(if_t ifp);
int if_setifheaderlen(if_t ifp, int len); int if_setifheaderlen(if_t ifp, int len);
@ -648,7 +648,7 @@ void if_bpfmtap(if_t ifp, struct mbuf *m);
void if_etherbpfmtap(if_t ifp, struct mbuf *m); void if_etherbpfmtap(if_t ifp, struct mbuf *m);
void if_vlancap(if_t ifp); void if_vlancap(if_t ifp);
int if_transmit(if_t ifp, struct mbuf *m); int if_transmit(if_t ifp, struct mbuf *m);
int if_init(if_t ifp, void *ctx); void if_init(if_t ifp, void *ctx);
int if_resolvemulti(if_t ifp, struct sockaddr **, struct sockaddr *); int if_resolvemulti(if_t ifp, struct sockaddr **, struct sockaddr *);
uint64_t if_getcounter(if_t ifp, ift_counter counter); uint64_t if_getcounter(if_t ifp, ift_counter counter);
struct label *if_getmaclabel(if_t ifp); struct label *if_getmaclabel(if_t ifp);