Page MenuHomeFreeBSD

net: Explicitly dereference the function pointer
Needs ReviewPublic

Authored by zlei on Sep 2 2025, 5:41 PM.
Tags
None
Referenced Files
Unknown Object (File)
Wed, Oct 8, 8:57 PM
Unknown Object (File)
Sun, Oct 5, 2:25 AM
Unknown Object (File)
Thu, Oct 2, 9:26 PM
Unknown Object (File)
Wed, Oct 1, 11:12 PM
Unknown Object (File)
Mon, Sep 29, 6:55 AM
Unknown Object (File)
Fri, Sep 26, 7:18 AM
Unknown Object (File)
Thu, Sep 25, 2:37 PM
Unknown Object (File)
Thu, Sep 25, 1:07 PM

Details

Reviewers
None
Group Reviewers
network
Summary

This is most useful to make it easier to search the calling of ifnet routines by regular expression.

No functional change intended.

MFC after: 2 weeks

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Skipped
Unit
Tests Skipped

Event Timeline

zlei requested review of this revision.Sep 2 2025, 5:41 PM

I personally don't like the change. Readability is reduced. I also don't understand the motivation. If you use grep for ->if_transmit\( you will find all calls of the method and nothing extra.

I personally don't like the change. Readability is reduced. I also don't understand the motivation. If you use grep for ->if_transmit\( you will find all calls of the method and nothing extra.

I'd admit this reduce readability somewhat. The motivation to keep the style of all calls of function pointers consistent.

Yes I have ever grep as you suggested, but eventually I figured out that I missed some, for example

# grep -Er 'if_transmit)\(' sys
sys/net/if_vlan.c:	error = (p->if_transmit)(p, m);
sys/net/if_fwsubr.c:		error = (ifp->if_transmit)(ifp, m);
sys/net/if_fwsubr.c:			error = (ifp->if_transmit)(ifp, m);
sys/net/if.c:	return ((*ifp->if_transmit)(ifp, m));
sys/net/if_tuntap.c:	error = (ifp->if_transmit)(ifp, m0);
sys/net/if_ethersubr.c:	return ((ifp->if_transmit)(ifp, m));
sys/net/if_lagg.c:	return (ifp->if_transmit)(ifp, m);
sys/netgraph/ng_iface.c:		error = (ifp->if_transmit)(ifp, m);
sys/dev/netmap/netmap_kern.h:	int     (*if_transmit)(if_t, struct mbuf *);

We also have IfAPI if_transmit(), so by intuition I'd like to distinguish calls to functions and that to function pointers.