Page MenuHomeFreeBSD

libsysdecode: Teach mktables to handle enums
ClosedPublic

Authored by des on Jul 1 2026, 11:12 AM.
Tags
None
Referenced Files
Unknown Object (File)
Sat, Aug 1, 8:23 AM
Unknown Object (File)
Sat, Aug 1, 7:30 AM
Unknown Object (File)
Sat, Aug 1, 7:24 AM
Unknown Object (File)
Sat, Aug 1, 5:19 AM
Unknown Object (File)
Fri, Jul 31, 6:38 AM
Unknown Object (File)
Thu, Jul 30, 11:01 AM
Unknown Object (File)
Thu, Jul 30, 6:32 AM
Unknown Object (File)
Thu, Jul 30, 2:26 AM
Subscribers

Details

Summary

While here, clean up and simplify the existing code.

MFC after: 1 week

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Skipped
Unit
Tests Skipped
Build Status
Buildable 74460
Build 71343: arc lint + arc unit

Event Timeline

des requested review of this revision.Jul 1 2026, 11:12 AM

hmm, given awk's limited regex syntax I think it would be better to process the exclusion using sed and use awk only to pick out enums.

jhb added inline comments.
lib/libsysdecode/mktables
57

Having filter be local so it doesn't get created in the global namespace is still nice.

85

s/TABLE_NAME/TABLE_START/? (Old bug I think)

102

I think the only thing here is that this doesn't permit named enums, only enum {\n... }. That's fine for now I guess, but at some point the regex might have to be relaxed to allow a valid C identifier between enum and the {.

des marked 2 inline comments as done.Jul 1 2026, 12:59 PM
des added inline comments.
lib/libsysdecode/mktables
102

yes it does, the ([[:space:]].*)? bit takes care of that, and I added support for a leading typedef after you commented. I don't want to make it more specific than that because technically there could be attributes (e.g. enum_extensibility) between the enum keyword and the identifier.

des marked 2 inline comments as done.Jul 1 2026, 1:00 PM

further simplify the original code

Thanks a lot! Didn't review the awk/sed code, since not an expert in it.

This revision is now accepted and ready to land.Jul 1 2026, 2:43 PM
jhb added inline comments.
lib/libsysdecode/mktables
102

I had misread the regex as only matching whitespace. It is pretty generic as you note, but I agree that it's probably not tenable to be more specific than just requiring at least one space before any other non-space characters.

This revision was automatically updated to reflect the committed changes.

I've merged this to stable/15 but not stable/14 since it does not have the changes to <sys/socket.h> or <sys/netpfil/pf/pf_nl.h> which necessitated the change.