Skip to content

libnvme: add check-public-headers test and fix missing prototypes#3298

Merged
igaw merged 2 commits intolinux-nvme:masterfrom
martin-belanger:check-public-headers
Apr 22, 2026
Merged

libnvme: add check-public-headers test and fix missing prototypes#3298
igaw merged 2 commits intolinux-nvme:masterfrom
martin-belanger:check-public-headers

Conversation

@martin-belanger
Copy link
Copy Markdown

A few public function prototypes were missing from the installed public headers.

A symbol that appears in a version script but has no prototype in any installed header is technically callable by external code, but callers have no declaration to include — they must write their own prototype or fall back to dlsym().

This series fixes three such symbols and adds a test to prevent regressions.

Patch 1 — add missing prototypes for exported symbols

Three __public symbols were listed in version scripts (*.ld) but had no prototype in any installed header:

  • libnvme_mi_submit_entry() — weak tracing hook in mi.c
  • libnvme_mi_submit_exit() — weak tracing hook in mi.c
  • libnvmf_context_set_fabrics_config() — setter in fabrics.c whose
    getter libnvmf_context_get_fabrics_config() was already declared

Prototypes added to mi.h and fabrics.h respectively.

Patch 2 — add check-public-headers test

Adds tools/check-public-headers.py, a companion to the existing check-public-symbols.py. It reads all *.ld version scripts, extracts their global: symbols, then scans each installed header for a matching prototype. Conditional headers (MI, fabrics) are silently skipped when absent, matching the build's own conditionality.

The script is registered as a meson test alongside check-public-symbols so it runs automatically under meson test.

Three __public symbols were listed in the version scripts but had no
prototype in any installed header:

  libnvme_mi_submit_entry()  -- weak tracing hook in mi.c
  libnvme_mi_submit_exit()   -- weak tracing hook in mi.c
  libnvmf_context_set_fabrics_config() -- setter in fabrics.c whose
    getter libnvmf_context_get_fabrics_config() was already declared

Without a prototype in an installed header, callers have no declaration
to include and must either write their own or resort to dlsym().

Signed-off-by: Martin Belanger <Martin.Belanger@dell.com>
Assisted-by: Claude Sonnet 4.6 <noreply@anthropic.com>
Comment thread libnvme/tools/check-public-headers.py Outdated
Comment thread libnvme/src/nvme/fabrics.h
Comment thread libnvme/src/nvme/mi.h
Add tools/check-public-headers.py, a companion to the existing
check-public-symbols.py, that verifies every symbol exported in a
version script has a prototype declared in one of the installed
headers.

The check reads all *.ld files, extracts their global: symbols, then
scans each installed header for a matching identifier followed by '('.
Conditional headers (MI, fabrics) are silently skipped when absent,
matching the same build conditionality as install_headers().

Register the script as a meson test alongside check-public-symbols so
it runs automatically under 'meson test'.

Signed-off-by: Martin Belanger <Martin.Belanger@dell.com>
Assisted-by: Claude Sonnet 4.6 <noreply@anthropic.com>
@martin-belanger
Copy link
Copy Markdown
Author

@igaw - I changed the script to take the list of headers and *.ld as input parameters as per your suggestion.

If you don't mind, I would like to address the other review comments as separate PRs. In other words, would it be possible to merge this PR, and I will work on fixes and submit another PR for your other comments (although for the MI I would prefer if someone else could handle it).

@igaw igaw merged commit bed896f into linux-nvme:master Apr 22, 2026
28 of 29 checks passed
@martin-belanger martin-belanger deleted the check-public-headers branch April 22, 2026 15:00
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