Page MenuHomeFreeBSD

kobj: convert KOBJOPLOOKUP() to returning pointer to function
Needs ReviewPublic

Authored by ehem_freebsd_m5p.com on Fri, Jan 10, 12:56 AM.

Details

Reviewers
imp
jhb
Summary

This makes KOBJOPLOOKUP() rather more suitable for purposes outside
the macros generated by makeobjops.awk. Of note other callers can
lookup the function on their parent class and call that explicitly.

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Passed
Unit
No Test Coverage
Build Status
Buildable 61649
Build 58533: arc lint + arc unit

Event Timeline

The change seems fine at a glance, but I'm not very familiar with this code.

For the commit description: I'm not convinced the conversion to compound expressions is the interesting point. IMO that's just the implementation. It's changing the API from assigning to a tkobjop_t _m internally to returning an <OP>_t that's interesting.

kevans added inline comments.
sys/sys/kobj.h
223

IIRC we need to spell it __extension__ ({ to avoid breaking... something.

sys/sys/kobj.h
223

Eh, we don't include that in other places (at least it's not something I'm aware of)

sys/sys/kobj.h
223

49 uses in sys/; I suspect it's only a requirement for the userland warning set, but it'd be nice to be consistent.

ehem_freebsd_m5p.com retitled this revision from kobj: convert KOBJOPLOOKUP() to compound statement expression to kobj: convert KOBJOPLOOKUP() to returning pointer to function.Fri, Jan 10, 5:11 PM

Updating as per current comments, add extension, minor title adjustment. Remove a now unnecessary cast from makeobjsops.awk's output.

One more comment and possible adjustment. I don't like the KOBJOPLOOKUP name. I think the original author was thinking (KOBJOP)(LOOKUP), but I believe the more common parsing is (KOBJ)(OP)(LOOKUP). KOBJLOOKUPOP or KOBJLOOKUP seem better since the is it is looking up an OP (function pointer) on a KOBJ, not looking up a KOBJOP in some global table.

I didn't find any uses of KOBJOPLOOKUP other than those generated by makeobjsop.awk, but there could be some outside the FreeBSD repository. I'm also unsure whether KOBJOPLOOKUP() is meant strictly for makeobjsops.awk files, versus simply being an undocumented useful macro.