Bug 240364

Summary: -Wunused-result in WebCoreSupport/WebContextMenuClient.cpp
Product: WebKit Reporter: Michael Catanzaro <mcatanzaro>
Component: WebKit2Assignee: Michael Catanzaro <mcatanzaro>
Status: RESOLVED FIXED    
Severity: Normal CC: cdumez, kkinnunen, mcatanzaro, webkit-bug-importer
Priority: P2 Keywords: InRadar
Version: WebKit Nightly Build   
Hardware: PC   
OS: Linux   
See Also: https://bugs.webkit.org/show_bug.cgi?id=240078

Michael Catanzaro
Reported 2022-05-12 17:39:43 PDT
Looks like https://github.com/WebKit/WebKit/pull/499 "Annotate more String member functions with WARN_UNUSED_RETURN" uncovered a bug in WebContextMenuClient [242/300] Building CXX object Source/WebKit/CMakeFiles/Web...ces/WebKit/unified-sources/UnifiedSource-54928a2b-34.cpp.o In file included from /home/mcatanzaro/Projects/WebKit/WebKitBuild/GNOME-gtk3/DerivedSources/WebKit/unified-sources/UnifiedSource-54928a2b-34.cpp:3: /home/mcatanzaro/Projects/WebKit/Source/WebKit/WebProcess/WebCoreSupport/WebContextMenuClient.cpp: In member function ‘virtual void WebKit::WebContextMenuClient::searchWithGoogle(const WebCore::Frame*)’: /home/mcatanzaro/Projects/WebKit/Source/WebKit/WebProcess/WebCoreSupport/WebContextMenuClient.cpp:62:35: warning: ignoring return value of ‘WTF::String WTF::String::stripWhiteSpace() const’, declared with attribute ‘warn_unused_result’ [-Wunused-result] 62 | searchString.stripWhiteSpace(); | ^ In file included from /home/mcatanzaro/Projects/WebKit/WebKitBuild/GNOME-gtk3/WTF/Headers/wtf/text/AtomString.h:27, from /home/mcatanzaro/Projects/WebKit/WebKitBuild/GNOME-gtk3/WTF/Headers/wtf/text/StringHash.h:25, from /home/mcatanzaro/Projects/WebKit/WebKitBuild/GNOME-gtk3/WTF/Headers/wtf/text/AtomStringTable.h:27, from /home/mcatanzaro/Projects/WebKit/WebKitBuild/GNOME-gtk3/WTF/Headers/wtf/Threading.h:51, from /home/mcatanzaro/Projects/WebKit/WebKitBuild/GNOME-gtk3/WTF/Headers/wtf/WeakPtr.h:31, from /home/mcatanzaro/Projects/WebKit/WebKitBuild/GNOME-gtk3/WTF/Headers/wtf/text/TextStream.h:33, from /home/mcatanzaro/Projects/WebKit/WebKitBuild/GNOME-gtk3/WTF/Headers/wtf/ObjectIdentifier.h:32, from /home/mcatanzaro/Projects/WebKit/WebKitBuild/GNOME-gtk3/WebCore/PrivateHeaders/WebCore/FrameIdentifier.h:28, from /home/mcatanzaro/Projects/WebKit/WebKitBuild/GNOME-gtk3/WebCore/PrivateHeaders/WebCore/FrameLoaderClient.h:32, from /home/mcatanzaro/Projects/WebKit/WebKitBuild/GNOME-gtk3/WebCore/PrivateHeaders/WebCore/AccessibilityObjectInterface.h:30, from /home/mcatanzaro/Projects/WebKit/WebKitBuild/GNOME-gtk3/WebCore/PrivateHeaders/WebCore/AccessibilityObject.h:32, from /home/mcatanzaro/Projects/WebKit/WebKitBuild/GNOME-gtk3/WebCore/PrivateHeaders/WebCore/AXObjectCache.h:30, from /home/mcatanzaro/Projects/WebKit/WebKitBuild/GNOME-gtk3/WebCore/PrivateHeaders/WebCore/ChromeClient.h:24, from /home/mcatanzaro/Projects/WebKit/Source/WebKit/WebProcess/WebCoreSupport/WebChromeClient.h:29, from /home/mcatanzaro/Projects/WebKit/Source/WebKit/WebProcess/WebCoreSupport/WebChromeClient.cpp:28, from /home/mcatanzaro/Projects/WebKit/WebKitBuild/GNOME-gtk3/DerivedSources/WebKit/unified-sources/UnifiedSource-54928a2b-34.cpp:1: /home/mcatanzaro/Projects/WebKit/WebKitBuild/GNOME-gtk3/WTF/Headers/wtf/text/WTFString.h:208:50: note: declared here 208 | WTF_EXPORT_PRIVATE String WARN_UNUSED_RETURN stripWhiteSpace() const; | ^~~~~~~~~~~~~~~
Attachments
Michael Catanzaro
Comment 1 2022-05-12 17:46:35 PDT
It's guarded by a #if !PLATFORM(COCOA) condition, which is why Chris didn't notice when cooking the original change. For GTK/WPE there is no way to ever access this code as we don't expose that context menu item. It looks like we only have context menu tests for macOS and GTK, so I won't attempt to write a test.
Chris Dumez
Comment 2 2022-05-12 17:48:49 PDT
Nice :)
Michael Catanzaro
Comment 3 2022-05-12 17:51:35 PDT
EWS
Comment 4 2022-05-12 18:42:05 PDT
Committed r294137 (250507@main): <https://commits.webkit.org/250507@main> Reviewed commits have been landed. Closing PR #606 and removing active labels.
Radar WebKit Bug Importer
Comment 5 2022-05-12 18:43:14 PDT
Note You need to log in before you can comment on or make changes to this bug.