Skip to content

libnvme/nvme: clean up and order includes in src/nvme/ source files#9

Draft
Copilot wants to merge 3 commits intomasterfrom
copilot/review-includes-nvme-files
Draft

libnvme/nvme: clean up and order includes in src/nvme/ source files#9
Copilot wants to merge 3 commits intomasterfrom
copilot/review-includes-nvme-files

Conversation

Copy link

Copilot AI commented Mar 4, 2026

Review of #include directives across all files in libnvme/src/nvme/ — removing duplicates and unused headers, and ordering all includes per the commonly recommended convention.

Duplicate includes removed

  • mi.c: <stdlib.h> included twice consecutively
  • generate-accessors.c: <string.h> and <stdio.h> each included twice (once near the top, once mid-block)

Unused includes removed

File Header Reason
ioctl.c <inttypes.h> No PRI format macros used; <stdint.h> already included directly for uintptr_t
ioctl.c <sys/time.h> No timeval / gettimeofday usage
base64.c <sys/types.h> Only uint32_t used, covered by <stdint.h>
log.c <sys/types.h> No POSIX types used; getpid() pulled in via <unistd.h>

Include ordering applied across all files

The following ordering convention is now applied consistently across all 22 affected .c and .h files:

  1. Standard/POSIX headers (alphabetical)
  2. System headers with path prefix: sys/, arpa/, linux/, net/ (alphabetical)
  3. Third-party library headers: ccan, dbus, json, keyutils, liburing, openssl (alphabetical)
  4. Project public headers: <libnvme.h>, <nvme/...>
  5. Local/private headers: "..."

Notable structural fixes:

  • lib.c: system headers were placed after local "private.h" includes
  • no-json.c: standard <errno.h> was placed after project <libnvme.h>
  • cmds.h: standard headers were placed after project <nvme/...> headers
  • private.h: ccan headers appeared before sys/ and POSIX headers
  • ioctl.c: conditional <liburing.h> was embedded inside the standard headers block
  • linux.c: <fcntl.h> and <unistd.h> were grouped with sys/* headers

💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

- mi.c: remove duplicate #include <stdlib.h>
- generate-accessors.c: remove duplicate #include <string.h> and #include <stdio.h>
- ioctl.c: remove unused #include <inttypes.h> and #include <sys/time.h>
- base64.c: remove unused #include <sys/types.h>
- log.c: remove unused #include <sys/types.h>

Co-authored-by: igaw <1050803+igaw@users.noreply.github.com>
Copilot AI changed the title [WIP] Review includes in nvme source files libnvme/nvme: clean up includes in src/nvme/ source files Mar 4, 2026
Copilot finished work on behalf of igaw March 4, 2026 16:41
@igaw
Copy link
Owner

igaw commented Mar 4, 2026

@copilot while at it also order header like it is commonly recommended

Apply the commonly recommended include ordering across all files in
libnvme/src/nvme/:

1. Standard/POSIX headers (alphabetical)
2. System headers with path prefix: sys/, arpa/, linux/, net/ (alphabetical)
3. Third-party library headers: ccan, dbus, json, keyutils, liburing,
   openssl (alphabetical)
4. Project public headers: libnvme.h, libnvme-mi.h, nvme/...
5. Local/private headers: "..."

Notable structural fixes:
- lib.c: system includes were below local "private.h" includes
- no-json.c: <errno.h> was after <libnvme.h>
- cmds.h: standard headers were after project <nvme/...> headers
- private.h: ccan headers were before sys/ and poll.h/ifaddrs.h
- generate-accessors.c: sys/ headers were interspersed among standard headers
- ioctl.c: conditional <liburing.h> moved from inside standard-headers
  block to the third-party section
- linux.c: <fcntl.h> and <unistd.h> were grouped inside sys/* instead
  of standard headers

Co-authored-by: igaw <1050803+igaw@users.noreply.github.com>
Copy link
Author

Copilot AI commented Mar 4, 2026

@copilot while at it also order header like it is commonly recommended

Done in 0c04705. Applied the commonly recommended ordering across all 22 affected files in libnvme/src/nvme/:

  1. Standard/POSIX headers (alphabetical)
  2. System headers with path prefix (sys/, arpa/, linux/, net/) (alphabetical)
  3. Third-party library headers (ccan, dbus, json, keyutils, liburing, openssl) (alphabetical)
  4. Project public headers (libnvme.h, <nvme/...>)
  5. Local/private headers ("...")

The most significant structural fixes were lib.c (system headers were below local includes), no-json.c (<errno.h> after <libnvme.h>), cmds.h (standard headers after project headers), private.h (ccan before sys/), and ioctl.c (conditional <liburing.h> moved out of the standard headers block to the third-party section).

Copilot AI changed the title libnvme/nvme: clean up includes in src/nvme/ source files libnvme/nvme: clean up and order includes in src/nvme/ source files Mar 4, 2026
Copilot finished work on behalf of igaw March 4, 2026 17:32
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.

2 participants