Enable -Wconditional-uninitialized in WebInspectorUI, WebKitLegacy, WebKit projects
authorddkilzer@apple.com <ddkilzer@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 16 Jan 2020 16:04:54 +0000 (16:04 +0000)
committerddkilzer@apple.com <ddkilzer@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 16 Jan 2020 16:04:54 +0000 (16:04 +0000)
<https://webkit.org/b/206270>
<rdar://problem/58589767>

Reviewed by Tim Horton.

* Configurations/Base.xcconfig:
(WARNING_CFLAGS): Add -Wconditional-uninitialized switch.
Source/WebKit:

* UIProcess/Automation/WebAutomationSession.cpp:
(WebKit::WebAutomationSession::performInteractionSequence):
Initialize `x`, `y` stack variables since the compiler can't
reason about the behavior of JSON::Object::getInteger().
* WebProcess/Plugins/PDF/PDFPlugin.mm:
(WebKit::getAllScriptsInPDFDocument): Initialize `length` stack
variable.  Also add check that `length` is non-zero.

Source/WebKitLegacy/mac:

* Plugins/WebNetscapePluginView.mm:
(-[WebNetscapePluginView scheduleTimerWithInterval:repeat:timerFunc:]):
Initialize `slot` stack variable.
* WebView/WebPDFDocumentExtras.mm:
(allScriptsInPDFDocument): Initialize `length` stack variable.
Also add check that `length` is non-zero.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@254683 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebInspectorUI/ChangeLog
Source/WebInspectorUI/Configurations/Base.xcconfig
Source/WebKit/ChangeLog
Source/WebKit/Configurations/Base.xcconfig
Source/WebKit/UIProcess/Automation/WebAutomationSession.cpp
Source/WebKit/WebProcess/Plugins/PDF/PDFPlugin.mm
Source/WebKitLegacy/mac/ChangeLog
Source/WebKitLegacy/mac/Configurations/Base.xcconfig
Source/WebKitLegacy/mac/Plugins/WebNetscapePluginView.mm
Source/WebKitLegacy/mac/WebView/WebPDFDocumentExtras.mm

index 894c849..449aa32 100644 (file)
@@ -1,3 +1,14 @@
+2020-01-16  David Kilzer  <ddkilzer@apple.com>
+
+        Enable -Wconditional-uninitialized in WebInspectorUI, WebKitLegacy, WebKit projects
+        <https://webkit.org/b/206270>
+        <rdar://problem/58589767>
+
+        Reviewed by Tim Horton.
+
+        * Configurations/Base.xcconfig:
+        (WARNING_CFLAGS): Add -Wconditional-uninitialized switch.
+
 2020-01-15  Devin Rousso  <drousso@apple.com>
 
         Web Inspector: collapsing a virtualized folder in a `WI.TreeOutline` doesn't updated the DOM
index 289837a..790407e 100644 (file)
@@ -64,7 +64,7 @@ CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
 GCC_WARN_UNINITIALIZED_AUTOS = YES
 GCC_WARN_UNUSED_FUNCTION = YES;
 GCC_WARN_UNUSED_VARIABLE = YES
-WARNING_CFLAGS = -Wall -W -Wcast-qual -Wchar-subscripts -Wformat-security -Wmissing-format-attribute -Wpointer-arith -Wwrite-strings -Wno-unused-parameter -Wexit-time-destructors;
+WARNING_CFLAGS = -Wall -W -Wcast-qual -Wchar-subscripts -Wconditional-uninitialized -Wformat-security -Wmissing-format-attribute -Wpointer-arith -Wwrite-strings -Wno-unused-parameter -Wexit-time-destructors;
 
 ENGINEERING_BUILD_DEFINES = $(ENGINEERING_BUILD_DEFINES_$(ENGINEERING_BUILD));
 ENGINEERING_BUILD_DEFINES_1 = ENGINEERING_BUILD=1;
index 16aa382..be6367f 100644 (file)
@@ -1,3 +1,21 @@
+2020-01-16  David Kilzer  <ddkilzer@apple.com>
+
+        Enable -Wconditional-uninitialized in WebInspectorUI, WebKitLegacy, WebKit projects
+        <https://webkit.org/b/206270>
+        <rdar://problem/58589767>
+
+        Reviewed by Tim Horton.
+
+        * Configurations/Base.xcconfig:
+        (WARNING_CFLAGS): Add -Wconditional-uninitialized switch.
+        * UIProcess/Automation/WebAutomationSession.cpp:
+        (WebKit::WebAutomationSession::performInteractionSequence):
+        Initialize `x`, `y` stack variables since the compiler can't
+        reason about the behavior of JSON::Object::getInteger().
+        * WebProcess/Plugins/PDF/PDFPlugin.mm:
+        (WebKit::getAllScriptsInPDFDocument): Initialize `length` stack
+        variable.  Also add check that `length` is non-zero.
+
 2020-01-16  Carlos Garcia Campos  <cgarcia@igalia.com>
 
         [GTK][WPE] Web process crash when IM tries to delete surrounding text
index f48bae1..417cebf 100644 (file)
@@ -86,7 +86,7 @@ GCC_WARN_UNUSED_FUNCTION = YES;
 GCC_WARN_UNUSED_VARIABLE = YES;
 OTHER_MIGFLAGS = -F$(BUILT_PRODUCTS_DIR);
 PREBINDING = NO;
-WARNING_CFLAGS = -Wall -Wextra -Wcast-qual -Wchar-subscripts -Wextra-tokens -Wformat-security -Winit-self -Wmissing-format-attribute -Wmissing-noreturn -Wno-unused-parameter -Wpacked -Wpointer-arith -Wredundant-decls -Wundef -Wwrite-strings -Wexit-time-destructors -Wglobal-constructors -Wtautological-compare -Wimplicit-fallthrough;
+WARNING_CFLAGS = -Wall -Wextra -Wcast-qual -Wchar-subscripts -Wconditional-uninitialized -Wextra-tokens -Wformat-security -Winit-self -Wmissing-format-attribute -Wmissing-noreturn -Wno-unused-parameter -Wpacked -Wpointer-arith -Wredundant-decls -Wundef -Wwrite-strings -Wexit-time-destructors -Wglobal-constructors -Wtautological-compare -Wimplicit-fallthrough;
 
 TARGET_MAC_OS_X_VERSION_MAJOR = $(TARGET_MAC_OS_X_VERSION_MAJOR$(MACOSX_DEPLOYMENT_TARGET:suffix:identifier));
 TARGET_MAC_OS_X_VERSION_MAJOR_13 = 101300;
index 399b4ab..c7dafc6 100644 (file)
@@ -1932,7 +1932,7 @@ void WebAutomationSession::performInteractionSequence(const String& handle, cons
 
             RefPtr<JSON::Object> locationObject;
             if (stateObject->getObject("location"_s, locationObject)) {
-                int x, y;
+                int x = 0, y = 0;
                 if (locationObject->getInteger("x"_s, x) && locationObject->getInteger("y"_s, y))
                     sourceState.location = WebCore::IntPoint(x, y);
             }
index 5baea3d..6772aeb 100644 (file)
@@ -532,8 +532,8 @@ static void getAllScriptsInPDFDocument(CGPDFDocumentRef pdfDocument, Vector<Reta
         if (!CGPDFDictionaryGetName(javaScriptAction, "S", &actionType) || strcmp(actionType, "JavaScript"))
             continue;
 
-        const UInt8* bytes = 0;
-        CFIndex length;
+        const UInt8* bytes = nullptr;
+        CFIndex length = 0;
         CGPDFStreamRef stream;
         CGPDFStringRef string;
         RetainPtr<CFDataRef> data;
@@ -548,7 +548,7 @@ static void getAllScriptsInPDFDocument(CGPDFDocumentRef pdfDocument, Vector<Reta
             bytes = CGPDFStringGetBytePtr(string);
             length = CGPDFStringGetLength(string);
         }
-        if (!bytes)
+        if (!bytes || !length)
             continue;
 
         CFStringEncoding encoding = (length > 1 && bytes[0] == 0xFE && bytes[1] == 0xFF) ? kCFStringEncodingUnicode : kCFStringEncodingUTF8;
index 6bbdff8..c6ad45e 100644 (file)
@@ -1,3 +1,20 @@
+2020-01-16  David Kilzer  <ddkilzer@apple.com>
+
+        Enable -Wconditional-uninitialized in WebInspectorUI, WebKitLegacy, WebKit projects
+        <https://webkit.org/b/206270>
+        <rdar://problem/58589767>
+
+        Reviewed by Tim Horton.
+
+        * Configurations/Base.xcconfig:
+        (WARNING_CFLAGS): Add -Wconditional-uninitialized switch.
+        * Plugins/WebNetscapePluginView.mm:
+        (-[WebNetscapePluginView scheduleTimerWithInterval:repeat:timerFunc:]):
+        Initialize `slot` stack variable.
+        * WebView/WebPDFDocumentExtras.mm:
+        (allScriptsInPDFDocument): Initialize `length` stack variable.
+        Also add check that `length` is non-zero.
+
 2020-01-16  Cathie Chen  <cathiechen@igalia.com>
 
         Mapping HTML attributes width/height to the default aspect ratio of <img>
index 9a25531..acf1364 100644 (file)
@@ -88,7 +88,7 @@ CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
 OTHER_MIGFLAGS = -F$(BUILT_PRODUCTS_DIR);
 CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES;
 PREBINDING = NO;
-WARNING_CFLAGS = -Wall -Wextra -Wcast-qual -Wchar-subscripts -Wextra-tokens -Wformat-security -Winit-self -Wmissing-format-attribute -Wmissing-noreturn -Wno-unused-parameter -Wpacked -Wpointer-arith -Wredundant-decls -Wundef -Wwrite-strings -Wexit-time-destructors -Wglobal-constructors -Wtautological-compare -Wimplicit-fallthrough;
+WARNING_CFLAGS = -Wall -Wextra -Wcast-qual -Wchar-subscripts -Wconditional-uninitialized -Wextra-tokens -Wformat-security -Winit-self -Wmissing-format-attribute -Wmissing-noreturn -Wno-unused-parameter -Wpacked -Wpointer-arith -Wredundant-decls -Wundef -Wwrite-strings -Wexit-time-destructors -Wglobal-constructors -Wtautological-compare -Wimplicit-fallthrough;
 
 TARGET_MAC_OS_X_VERSION_MAJOR = $(TARGET_MAC_OS_X_VERSION_MAJOR$(MACOSX_DEPLOYMENT_TARGET:suffix:identifier));
 TARGET_MAC_OS_X_VERSION_MAJOR_13 = 101300;
index ddd9ecf..d39cfcc 100644 (file)
@@ -1656,7 +1656,7 @@ static inline void getNPRect(const NSRect& nr, NPRect& npr)
     if (!timers)
         timers = makeUnique<HashMap<uint32_t, std::unique_ptr<PluginTimer>>>();
 
-    std::unique_ptr<PluginTimer>* slot;
+    std::unique_ptr<PluginTimer>* slot = nullptr;
     uint32_t timerID;
     do
         timerID = ++currentTimerID;
index c66ec66..177ce93 100644 (file)
@@ -99,8 +99,8 @@ NSArray *allScriptsInPDFDocument(CGPDFDocumentRef pdfDocument)
         if (!CGPDFDictionaryGetName(javaScriptAction, "S", &actionType) || strcmp(actionType, "JavaScript"))
             continue;
 
-        const UInt8* bytes = 0;
-        CFIndex length;
+        const UInt8* bytes = nullptr;
+        CFIndex length = 0;
         CGPDFStreamRef stream;
         CGPDFStringRef string;
         RetainPtr<CFDataRef> data;
@@ -115,7 +115,7 @@ NSArray *allScriptsInPDFDocument(CGPDFDocumentRef pdfDocument)
             bytes = CGPDFStringGetBytePtr(string);
             length = CGPDFStringGetLength(string);
         }
-        if (!bytes)
+        if (!bytes || !length)
             continue;
 
         NSStringEncoding encoding = (length > 1 && bytes[0] == 0xFE && bytes[1] == 0xFF) ? NSUnicodeStringEncoding : NSUTF8StringEncoding;