Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 0d3626899f2589fa4ef9c162d0c78abc84503cbb
      
https://github.com/WebKit/WebKit/commit/0d3626899f2589fa4ef9c162d0c78abc84503cbb
  Author: Chris Dumez <[email protected]>
  Date:   2026-10-07 (Wed, 07 Oct 2026)

  Changed paths:
    M Source/JavaScriptCore/jit/CallFrameShuffler.cpp
    M Source/WTF/wtf/Assertions.cpp
    M Source/WTF/wtf/FormattedLogging.h
    M Source/WTF/wtf/Logger.cpp
    M Source/WTF/wtf/Logger.h
    M Source/WTF/wtf/StdLibExtras.h
    M Source/WTF/wtf/darwin/LibraryPathDiagnostics.mm
    M Source/WebCore/Scripts/generate-log-declarations.py
    M Source/WebCore/platform/NotImplemented.h
    M Source/WebCore/platform/graphics/gstreamer/GStreamerCommon.cpp
    M Source/WebCore/platform/graphics/gstreamer/GStreamerCommon.h
    M Source/WebCore/platform/graphics/gstreamer/WebKitWebSourceGStreamer.cpp
    M 
Source/WebCore/platform/graphics/gstreamer/mse/MediaSourcePrivateGStreamer.cpp
    M Source/WebCore/platform/gstreamer/GStreamerQuirks.cpp
    M Source/WebCore/platform/mediastream/gstreamer/DesktopPortal.cpp
    M 
Source/WebCore/platform/mediastream/libwebrtc/gstreamer/GStreamerVideoEncoderFactory.cpp
    M 
Source/WebCore/platform/mediastream/libwebrtc/gstreamer/RealtimeIncomingVideoSourceLibWebRTC.cpp
    M Source/WebGPU/WebGPU/Device.mm
    M Source/WebKit/Scripts/generate-derived-log-sources.py
    M Source/WebKit/Shared/LogStream.mm
    M Source/WebKit/UIProcess/API/Cocoa/WKWebView+TextExtraction.mm
    M Source/WebKit/UIProcess/API/Cocoa/WKWebsiteDataStore.mm
    M Source/WebKit/UIProcess/API/Cocoa/_WKWebsiteDataStoreConfiguration.mm
    M Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm
    M Source/WebKit/webpushd/WebPushDaemonMain.mm
    M Tools/Scripts/webkitpy/style/checkers/cpp.py
    M Tools/Scripts/webkitpy/style/checkers/cpp_unittest.py
    M Tools/TestWebKitAPI/Tests/WebKit/WKPage/cocoa/FetchLocalFile.mm
    M Tools/TestWebKitAPI/Tests/WebKit/WKWebView/SOAuthorizationTests.mm

  Log Message:
  -----------
  Add SAFE_* macros for logging functions that take printf-style arguments
https://bugs.webkit.org/show_bug.cgi?id=326656

Reviewed by Mike Wyrzykowski.

Call sites unwrapped typed strings with legacyCStringPointer() to pass them to 
C variadic logging
functions, which cannot convert them themselves without losing compile-time 
format checking. Add
SAFE_* macros that convert the arguments at the call site, like SAFE_PRINTF() 
and SAFE_DATALOGF()
do, keeping the format a literal that the compiler checks:

- wtf/StdLibExtras.h: SAFE_PRINTSTREAM_PRINTF() for PrintStream::printf(), 
SAFE_WTFLOG() and
  SAFE_WTFLOG_VERBOSE() for logging to a channel the caller was handed, 
SAFE_OS_LOG(),
  SAFE_OS_LOG_INFO(), SAFE_OS_LOG_DEBUG(), SAFE_OS_LOG_ERROR(), 
SAFE_OS_LOG_FAULT() and
  SAFE_OS_LOG_WITH_TYPE() for logging to an os_log_t, SAFE_ANDROID_LOG_PRINT(), 
and
  SAFE_SD_JOURNAL_SEND() and SAFE_SD_JOURNAL_SEND_WITH_LOCATION().
- GStreamerCommon.h: SAFE_GST_PRINTERRLN(), and SAFE_GST_DEBUG_LOG() and
  SAFE_GST_DEBUG_LOG_ID_LITERAL() for logging on behalf of another location.

Printf arguments are converted with SAFE_PRINTF_TYPE(), or 
SAFE_NSSTRING_PRINTF_TYPE() where %@ is
accepted, so a raw char* is rejected and has to be spelled 
UTF8CStringView::unsafeFromUTF8(). Fixed
string parameters, such as the file and function, are converted with 
logPrintfType(), so either a
typed string or __FILE__ can be passed. GST_CAT_LEVEL_LOG_ID() now converts its 
identifier the same
way.

Use the macros at the existing call sites, and have 
generate-derived-log-sources.py emit
SAFE_OS_LOG_WITH_TYPE(), which removes legacyCStringPointer() from every 
generated LogStream
message receiver. Also switch NSString formats that passed UTF-8 bytes to %s 
over to %@, since %s
in an NSString format is decoded in the system encoding rather than as UTF-8.

Add a safercpp/printf style check that flags calls to the wrapped functions and 
suggests the macro,
and one that flags PrintStream::printf() calls that unwrap typed strings by 
hand. Teach the
naming check that SUPPRESS_* static analyzer annotations are not types, so that
'SUPPRESS_UNRETAINED_LOCAL SAFE_OS_LOG(...)' is not taken for a declaration.

* Source/JavaScriptCore/jit/CallFrameShuffler.cpp:
* Source/WTF/wtf/Assertions.cpp:
* Source/WTF/wtf/FormattedLogging.h:
* Source/WTF/wtf/Logger.cpp:
* Source/WTF/wtf/Logger.h:
* Source/WTF/wtf/StdLibExtras.h:
* Source/WTF/wtf/darwin/LibraryPathDiagnostics.mm:
* Source/WebCore/Scripts/generate-log-declarations.py:
* Source/WebCore/platform/NotImplemented.h:
* Source/WebCore/platform/graphics/gstreamer/GStreamerCommon.cpp:
* Source/WebCore/platform/graphics/gstreamer/GStreamerCommon.h:
* Source/WebCore/platform/graphics/gstreamer/WebKitWebSourceGStreamer.cpp:
* 
Source/WebCore/platform/graphics/gstreamer/mse/MediaSourcePrivateGStreamer.cpp:
* Source/WebCore/platform/gstreamer/GStreamerQuirks.cpp:
* Source/WebCore/platform/mediastream/gstreamer/DesktopPortal.cpp:
* 
Source/WebCore/platform/mediastream/libwebrtc/gstreamer/GStreamerVideoEncoderFactory.cpp:
* 
Source/WebCore/platform/mediastream/libwebrtc/gstreamer/RealtimeIncomingVideoSourceLibWebRTC.cpp:
* Source/WebGPU/WebGPU/Device.mm:
* Source/WebKit/Scripts/generate-derived-log-sources.py:
* Source/WebKit/Shared/LogStream.mm:
* Source/WebKit/UIProcess/API/Cocoa/WKWebView+TextExtraction.mm:
* Source/WebKit/UIProcess/API/Cocoa/WKWebsiteDataStore.mm:
* Source/WebKit/UIProcess/API/Cocoa/_WKWebsiteDataStoreConfiguration.mm:
* Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm:
* Source/WebKit/webpushd/WebPushDaemonMain.mm:
* Tools/Scripts/webkitpy/style/checkers/cpp.py:
* Tools/Scripts/webkitpy/style/checkers/cpp_unittest.py:
* Tools/TestWebKitAPI/Tests/WebKit/WKPage/cocoa/FetchLocalFile.mm:
* Tools/TestWebKitAPI/Tests/WebKit/WKWebView/SOAuthorizationTests.mm:

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



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

Reply via email to