Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 409dd4f34def0b087ff76ad4c2979a187d627b61
      
https://github.com/WebKit/WebKit/commit/409dd4f34def0b087ff76ad4c2979a187d627b61
  Author: Alicia Boya Garcia <[email protected]>
  Date:   2026-03-23 (Mon, 23 Mar 2026)

  Changed paths:
    M Source/WTF/wtf/Assertions.h
    M Source/WebCore/platform/graphics/egl/GLContext.cpp
    M Source/WebKit/UIProcess/Extensions/WebExtensionAlarm.cpp
    M Source/WebKit/UIProcess/WebPageProxy.cpp
    M Source/WebKit/UIProcess/WebProcessCache.cpp

  Log Message:
  -----------
  [WTF][glib] Fix -Wformat errors with ENABLE_JOURNALD_LOG=OFF
https://bugs.webkit.org/show_bug.cgi?id=310378

Reviewed by Adrian Perez de Castro.

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.

* Source/WTF/wtf/Assertions.h:
(wtfCompileTimeCheckPrintfSpecifier):
* Source/WebCore/platform/graphics/egl/GLContext.cpp:
(WebCore::logGLDebugMessage):
* Source/WebKit/UIProcess/Extensions/WebExtensionAlarm.cpp:
(WebKit::WebExtensionAlarm::schedule):
* Source/WebKit/UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::validateCaptureStateUpdate):
* Source/WebKit/UIProcess/WebProcessCache.cpp:
(WebKit::WebProcessCache::addProcess):
(WebKit::WebProcessCache::takeProcess):

Canonical link: https://commits.webkit.org/309750@main



To unsubscribe from these emails, change your notification settings at 
https://github.com/WebKit/WebKit/settings/notifications

Reply via email to