Skip to content

Extract shared unreachable-code diagnostic pragmas - #3650

Open
user01010111 wants to merge 1 commit into
networkupstools:masterfrom
user01010111:refactor/unreachable-code-pragmas
Open

user01010111 wants to merge 1 commit into
networkupstools:masterfrom
user01010111:refactor/unreachable-code-pragmas

Conversation

@user01010111

Copy link
Copy Markdown
Contributor

Replace 17 repeated GCC/Clang unreachable-code pragma pairs in 16 internal source files with two private headers that can be included repeatedly. The original capability guards, diagnostic order and enclosed code are preserved. The headers are distributed with the source, and the developer guide describes their use.

Refs: #3595

This continues the pragma extraction work. Mixed-warning regions, variants with different push/pop guards and public headers remain local.

Validation:

  • GCC 16.2.1 with hard warnings and Clang 22.1.8 with medium warnings, both with Werror; every changed translation unit compiled with its selected region active, including USB, FreeIPMI, scanner backends and OpenSSL.
  • Exact source reconstruction, capability-state preprocessing comparisons and repeated-inclusion/restoration probes in C and C++. GCC accepts the unreachable-code warning option without diagnosing the negative control; a live warning sentinel verifies its diagnostic stack restoration.
  • Existing test suites passed for both compilers. The changed developer document passed strict spelling and rendered successfully.
  • make distcheck-light completed archive rebuild, tests, install/uninstall and cleanup. The extracted archive passed the same source/header proof, and the new headers were not installed.

Full strict spelling checks still report the same possessives in unchanged NEWS.adoc and apcmicrolink documentation as the exact base. Test and distribution continuations used SPELLCHECK_ERROR_FATAL=no, preserving those reports. The standard distcheck-light preparation supplied placeholders for 74 missing unrelated manual pages; the changed developer guide was rendered independently. No hardware or deployed-service testing is claimed.

AI assistance: OpenAI Codex, model gpt-6-astra, reasoning level xhigh. The human contributor remains responsible for reviewing and validating the change.

Move 17 identical GCC/Clang pragma pairs into private repeat-includable
headers. Preserve the aggregate capability guard, diagnostic order and
original boundaries; distribute the headers and document their use.

Refs: networkupstools#3595
AI assistance: OpenAI Codex gpt-6-astra (xhigh reasoning).

Signed-off-by: user01010111 <lapses.50.booster@icloud.com>
@github-actions

github-actions Bot commented Sep 15, 2026

Copy link
Copy Markdown

A ZIP file with standard source tarball and another tarball with pre-built docs for commit 1cc20a5 is temporarily available: NUT-tarballs-PR-3650.zip.

@jimklimov jimklimov added this to the 2.8.6 milestone Sep 15, 2026
@jimklimov jimklimov added refactor/fightwarn PR or issue proposal to improve code maintainability without functional changes, or to fix warnings portability We want NUT to build and run everywhere possible AI For good or bad, machine tools are upon us. Humans are still the responsible ones. labels Sep 15, 2026
@AppVeyorBot

Copy link
Copy Markdown

Build nut 2.8.5.5323-master completed (commit c5cae3b0be by @)

jimklimov added a commit to com6056/nut that referenced this pull request Sep 17, 2026
…code" for strcmp(SONAME_LIBX, SOFILE_LIBX) [networkupstools#3654]

Newer builders (notably those with clang-21 and clang-22) on some agents
correctly identify that we compare identical (macro) strings and the clause
would never run. Ideally the comparison would be pre-processor equality
check for strings, but as that is missing (or not portable), we compare
to avoid work in vain at run-time - and now quiesce the compiler warnings
about that on systems that do benefit from this check.

To be revised after PR networkupstools#3650 is merged, to simplify these pragma blocks.

Signed-off-by: Jim Klimov <jimklimov+nut@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

AI For good or bad, machine tools are upon us. Humans are still the responsible ones. portability We want NUT to build and run everywhere possible refactor/fightwarn PR or issue proposal to improve code maintainability without functional changes, or to fix warnings

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants