Skip to content

chore: align includes in platform-split files with the include policy#53

Merged
sbogomolov merged 1 commit into
mainfrom
cleanup/platform-gated-includes
Jul 9, 2026
Merged

chore: align includes in platform-split files with the include policy#53
sbogomolov merged 1 commit into
mainfrom
cleanup/platform-gated-includes

Conversation

@sbogomolov

Copy link
Copy Markdown
Owner

Align includes in the platform-split files with the include policy: portable headers are included unconditionally (the IDE's unused-include hint on the platform that doesn't use them is accepted); only headers that don't exist — or differ materially — across platforms stay behind #if.

An audit of every file with platform-conditional code found two kinds of drift:

  • Portable headers gated to one platform. Moved back to the shared groups: <net/if.h> (duplicated in both branches of interface_address_test), <ifaddrs.h>, <netinet/in.h>, <sys/ioctl.h>, and the std headers in interface_address_test.
  • Dead includes — no symbol used on any platform: <unistd.h> ×3 (fd lifecycle goes through UniqueFd, never raw close()), <cerrno> in the netlink block (errno is only read inside Error::FromErrno), <utility>, a duplicate <sys/socket.h>, and <net/ethernet.h> / <sys/uio.h> in the BPF block.

Verification

  • Native (macOS) build clean, unit suite green (Debug, ASan/UBSan).
  • Docker/Linux build clean, unit suite green (Debug, ASan/UBSan).
  • The <net/ethernet.h> / <sys/uio.h> removals sit in the !linux block; verified on macOS, with the FreeBSD lane as the backstop.

Portable headers are included unconditionally; only headers that don't
exist (or differ materially) across platforms stay gated. Two kinds of
drift fixed:

- Portable headers that had crept into platform blocks move back to
  the shared groups: <net/if.h> (duplicated in both branches of
  interface_address_test), <ifaddrs.h>, <netinet/in.h>, <sys/ioctl.h>,
  and the std headers in interface_address_test.

- Dead includes dropped -- no symbol used on any platform: <unistd.h>
  three times (fd lifecycle goes through UniqueFd, never raw close()),
  <cerrno> in the netlink block (errno is only read inside
  Error::FromErrno), <utility>, a duplicate <sys/socket.h>, and
  <net/ethernet.h> / <sys/uio.h> in the BPF block.
@sbogomolov sbogomolov self-assigned this Jul 9, 2026
@sbogomolov
sbogomolov merged commit bcb0b4d into main Jul 9, 2026
17 checks passed
@sbogomolov
sbogomolov deleted the cleanup/platform-gated-includes branch July 9, 2026 20:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant