Page MenuHomeFreeBSD

Refactor PCIOCGETCONF for improved readability.
ClosedPublic

Authored by brooks on Apr 5 2018, 6:47 PM.
Tags
None
Referenced Files
Unknown Object (File)
Sat, Oct 26, 12:45 AM
Unknown Object (File)
Oct 10 2024, 12:26 AM
Unknown Object (File)
Oct 2 2024, 9:21 PM
Unknown Object (File)
Sep 23 2024, 5:31 AM
Unknown Object (File)
Sep 21 2024, 11:18 AM
Unknown Object (File)
Sep 20 2024, 1:46 AM
Unknown Object (File)
Sep 16 2024, 6:17 PM
Unknown Object (File)
Sep 8 2024, 9:56 PM
Subscribers

Details

Summary

The code now has a single, consistant flow for all three ioctl
variants. ifdefs and for pre-FreeBSD-7 compatability are moved to
functions and macros. So the flow is alwasy the same, we impose
the cost of allocating, copying to, updating from, and freeing a
copy of struct pci_conf_io on all paths.

This change will allow PCIOCGETCONF32 support currently in
sys/compat/freebsd32/freebsd32_ioctl.c to be moved here.

Diff Detail

Lint
Lint Passed
Unit
No Test Coverage
Build Status
Buildable 16004
Build 15986: arc lint + arc unit

Event Timeline

  • Correct a leftover from a botched substitution.
  • tab's after #define
  • Be a little more consistant with #ifdefs

I think this is ready for review now.

This revision is now accepted and ready to land.Apr 6 2018, 12:00 PM

One other possibility is to define a helper struct that contains the structure sizes and has function pointer callbacks (kevent and aio took this approach), but this is probably fine.

sys/dev/pci/pci_user.c
418

While I appreciate the desire to reduce duplication, this feels a bit squishy to me, especially given it's only used twice. I think the expanded version in the two places might be less total lines than this set of helper macros. I don't think we use this pattern anywhere else in the tree.

As far as the ops structures, I found the structure in aio frustrating when I needed to change its interface due to having to (e.g.) add N new functions and add the right ones to N+2 or so ops struct instances.

sys/dev/pci/pci_user.c
418

If makes more sense as the number of entries grows. I've got a patch which adds another case for PCIOCGETCONF32 (moving it out of sys/compat/freebsd32). On CheriBSD I've got yet another PCIOCGETCONF_C. I don't feel strongly about this case, but the virtue of this is that pci_ioctl() now contains no references to compat defines.

sys/dev/pci/pci_user.c
418

I suppose static analysis expands macros so wouldn't be confused, but I wonder if things like clang-format or auto-indenting in emacs/vim handles this syntax ok? Maybe the trailing colon is good enough for that to not break?

  • Expand CASE_PCIOCGETCONF inplace and remove the defintion.
This revision now requires review to proceed.Apr 8 2018, 4:30 PM
This revision is now accepted and ready to land.Apr 9 2018, 10:27 PM
This revision was automatically updated to reflect the committed changes.