WebKit Bugzilla
New
Browse
Search+
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
RESOLVED FIXED
310378
[WTF][glib] Fix -Wformat errors with ENABLE_JOURNALD_LOG=OFF
https://bugs.webkit.org/show_bug.cgi?id=310378
Summary
[WTF][glib] Fix -Wformat errors with ENABLE_JOURNALD_LOG=OFF
Alicia Boya García
Reported
2026-03-20 12:07:37 PDT
Currently glib builds are broken if configured with -DENABLE_JOURNALD_LOG:BOOL=OFF. This patch fixes all the issues preventing it to build. Open source clang versions before 19.0 emit a -Wformat warning if you printf() a C++ scoped enum (i.e. enum class) without a cast. This is the case for the clang 18 that ships with Ubuntu 24.04 and also used by default in the WebKit container SDK. This patch fixes all the occurences of such errors that appear on an otherwise stock GTK build. The format errors weren't previously caught because format warning is currently not working when compiling with ENABLE_JOURNALD_LOG=ON, which is the default in glib: The RELEASE_LOG() macros expand into SD_JOURNAL_SEND(), and SD_JOURNAL_SEND() expands in turn into sd_journal_send_with_location(), which takes a null-terminated sequence of formatspecifiers and format arguments. AFAIK there are no compiler attributes to type check such a signature, and systemd instead tags it with _sd_printf_(4, 0), which checks the first format string for consistency but none of the arguments. To prevent this from being a problem in the future, this patch also modifies the macro definition of SD_JOURNAL_SEND() so that format specifiers are checked. Other than scoped enums, a format specifier error was also found in WebExtensionAlarm, which makes use of os_log() sensitivity modifiers for float values and are not supported in regular printf. WTF previously already had macros like PUBLIC_LOG_STRING and SENSITIVE_LOG_STRING. Rather than creating new versions for every possible datatype, this patch adds more generic modifiers that can be used with any printf data type. The existing code for PUBLIC_LOG_STRING is also refactored for clarity. (Note: About -Wformat in newer clang versions) Later versions relegate that behavior to a separate -Wformat-pedantic flag that is disabled by default. This is also the case in the clang 17.0.0 currently shipping with Xcode. Note that Xcode clang versions follow a different release schedule and are not mutually comparable with clang open source release version numbers.
Attachments
Add attachment
proposed patch, testcase, etc.
Alicia Boya García
Comment 1
2026-03-20 13:22:16 PDT
Pull request:
https://github.com/WebKit/WebKit/pull/61029
EWS
Comment 2
2026-03-23 03:36:57 PDT
Committed
309750@main
(409dd4f34def): <
https://commits.webkit.org/309750@main
> Reviewed commits have been landed. Closing PR #61029 and removing active labels.
Note
You need to
log in
before you can comment on or make changes to this bug.
Top of Page
Format For Printing
XML
Clone This Bug