https://bz.apache.org/bugzilla/show_bug.cgi?id=70189

            Bug ID: 70189
           Summary: mod_log_json: limit Jansson diagnostic suppressions to
                    the included headers
           Product: Apache httpd-2
           Version: 2.5-HEAD
          Hardware: All
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P2
         Component: mod_log_config
          Assignee: [email protected]
          Reporter: [email protected]
  Target Milestone: ---

Created attachment 40210
  --> https://bz.apache.org/bugzilla/attachment.cgi?id=40210&action=edit
Patch -- Limit Jansson diagnostic suppressions to the included headers

`modules/loggers/mod_log_json.c` pushes compiler diagnostic state before
including the Jansson headers, but never restores it. As a result, the warning
suppressions intended for Jansson remain active for the rest of the source
file.

The current compiler-selection order also checks `__GNUC__` before
`__clang__`. Because Clang defines GNU-compatibility macros, Clang enters the
GCC branch and the explicit Clang branch is unreachable. In the tested Clang
18 configuration, the relevant predefined macros are:

```text
__GNUC__=4
__GNUC_MINOR__=2
__clang__=1
```

Consequently, current Clang builds receive both `-Wunused-function` and
`-Wunreachable-code` suppression through the GCC-compatible pragmas, and both
suppressions continue beyond the Jansson includes.

I checked current trunk at
`95372b469f99d154225ab4bded61428968d5e672`. A controlled unused static
function placed after the Jansson includes produces no diagnostic in the
current source. After restoring diagnostic state immediately after
`<jansson.h>`, Clang reports the expected `-Wunused-function` warning. This
confirms the scope leak independently of whether current module code happens
to trigger it.

The attached patch checks Clang before GNU C, preserves the two suppressions
around the Jansson headers, and pops the matching diagnostic state immediately
after those headers.

Validation:

- built the module from matched original and patched trees on Ubuntu 24.04;
- tested Clang 18.1.3 and GCC 13.3;
- both original and patched module builds succeeded;
- the existing warning sets were unchanged for both compilers; and
- the controlled post-include sentinel was hidden before the patch and
  reported after it.

I have not found a current build failure caused by the leaked state, so I am
reporting this as a diagnostic-scope maintenance issue rather than a runtime or
user-visible bug. Is limiting the suppression to the Jansson headers the
preferred behavior? If so, is preserving both current Clang suppressions inside
that region preferable, or should the Clang path retain only the originally
written `-Wunused-function` suppression?

FYI: the block was introduced in commit
`bd5718d7e19a7d237759a39a36d2c79813a2a934` with the message "mod_log_json:
fixing compilation errors in maintainer mode."

-- 
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to