Enable -Wcast-qual for WebInspectorUI, WebKitLegacy, WebKit projects
authorddkilzer@apple.com <ddkilzer@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 8 Jan 2018 06:00:43 +0000 (06:00 +0000)
committerddkilzer@apple.com <ddkilzer@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 8 Jan 2018 06:00:43 +0000 (06:00 +0000)
<https://webkit.org/b/181256>
<rdar://problem/36281730>

Reviewed by Darin Adler.

Source/WebInspectorUI:

* Configurations/Base.xcconfig:
(WARNING_CFLAGS): Add -Wcast-qual.

Source/WebKit:

* Configurations/Base.xcconfig:
(WARNING_CFLAGS): Add -Wcast-qual.
* NetworkProcess/cache/NetworkCacheCodersCocoa.cpp:
(WTF::Persistence::encodeCertificateChain): Include
TypeCastsCF.h from WTF, and use
checked_cf_cast<SecCertificateRef>() to fix warning.
* Platform/cocoa/WKCrashReporter.mm:
(WebKit::setCrashReportApplicationSpecificInformation):
- Move `oldMessage` check above nullptr check to fix a leak when
  passing in nullptr after previously setting the crash string.
- Change C-style cast to const_cast<char*>() to fix warning.
* PluginProcess/mac/PluginProcessShim.mm:
(WebKit::shim_shmat): Change C-style cast to
const_cast<void*>() to fix warning.
* Shared/Authentication/mac/AuthenticationManager.mac.mm:
(WebKit::leafCertificate): Include TypeCastsCF.h from
WTF, and use checked_cf_cast<SecCertificateRef>() to fix
warning.
* Shared/cf/ArgumentCodersCF.cpp:
(IPC::encode): Use static_cast<>(const_cast<void*>() to
fix warnings since the CFTypeID has already been
checked.
* Shared/mac/WebCoreArgumentCodersMac.mm:
(IPC::decodeNSError): Use an `auto` variable to hold the
CFMutableDictionaryRef, then WTFMove() to assign it back to
`userInfo`.
* UIProcess/Cocoa/WebViewImpl.mm:
(WebKit::takeWindowSnapshot): Include TypeCastsCF.h from
WTF, and use checked_cf_cast<CGImageRef>() to fix
warning.

Source/WebKitLegacy:

* PlatformMac.cmake:
* WebKitLegacy.xcodeproj/project.pbxproj:
- Rename WebNSDataExtras.m to WebNSDataExtras.mm and change file
  type to Objective-C++.

Source/WebKitLegacy/mac:

* Carbon/CarbonUtils.m:
(PoolCleaner):
- Use #pragmas to ignore -Wcast-qual warnings when using a
  C-style cast from CFTypeRef to CFRunloopRef.
* Carbon/CarbonWindowFrame.m:
(-[CarbonWindowFrame title]):
- Use #pragmas to ignore -Wcast-qual warnings when using a
  C-style cast from CFStringRef to NSString *.
* Carbon/HIViewAdapter.m:
(+[HIViewAdapter getHIViewForNSView:]):
- Use #pragmas to ignore -Wcast-qual warnings when using a
  C-style cast from CFTypeRef to HIViewRef.
* Configurations/Base.xcconfig:
(WARNING_CFLAGS): Add -Wcast-qual.
* Misc/WebElementDictionary.mm:
(-[WebElementDictionary objectForKey:]):
- Use static_cast<SEL>(const_cast<void*>()) to fix
  warning.
* Misc/WebNSDataExtras.mm: Renamed from Source/WebKitLegacy/mac/Misc/WebNSDataExtras.m.
(-[NSString _web_capitalizeRFC822HeaderFieldName]):
(-[NSData _webkit_guessedMIMETypeForXML]):
(-[NSData _webkit_guessedMIMEType]):
(-[NSData _web_isCaseInsensitiveEqualToCString:]):
(_findEOL):
(-[NSData _webkit_parseRFC822HeaderFields]):
(-[NSData _web_startsWithBlankLine]):
(-[NSData _web_locationAfterFirstBlankLine]):
- Rename WebNSDataExtras.m to WebNSDataExtras.mm and change file
  type to Objective-C++.  This fixes the warnings about
  discarding the `const` modifier when casing from CFStringRef
  to NSString * because in older clang versions, -Wcast-qual was
  completely broken when compiling C++ and Objective-C++ source
  files.  In newer clang versions, discarding the `const`
  modifier for toll-free bridged types is ignored when compiling
  Objective-C++ source.
- Update copyright and license header.
- Use reinterpret_cast<> and static_cast<> to fix warnings
  unrelated to (NSString *) C-style casts.
- Replace use of MIN() macro with std::min<> template functions.
- Fix location of `*` for local variables modified above.
* Plugins/Hosted/NetscapePluginHostManager.mm:
(WebKit::NetscapePluginHostManager::spawnPluginHost):
(WebKit::NetscapePluginHostManager::initializeVendorPort):
(WebKit::NetscapePluginHostManager::instantiatePlugin):
- Use static_cast<uint8_t*>(const_cast<void*>()) to fix
  warnings.
* Plugins/Hosted/NetscapePluginHostProxy.mm:
(WebKit::NetscapePluginHostProxy::NetscapePluginHostProxy):
- Use reinterpret_cast<mig_subsystem_t>(const_cast<struct WKWebKitPluginClient_subsystem*>())
  to fix warning.
* Plugins/Hosted/ProxyInstance.mm:
(WebKit::ProxyInstance::invoke):
- Use static_cast<char*>(const_cast<void*>()) to fix
  warning when using -[NSData bytes].
(WebKit::ProxyInstance::fieldValue const):
- Use reinterpret_cast<char*>(const_cast<unsigned char*>())
  to fix warning when using CFDataGetBytePtr().
* Plugins/Hosted/WebTextInputWindowController.m:
(-[WebTextInputPanel _interpretKeyEvent:string:]):
- Use #pragma to ignore -Wcast-qual warning since there
  is not a good way to avoid this warning in Objective-C.
* Plugins/WebNetscapePluginStream.mm:
(WebNetscapePluginStream::deliverData):
- Use const_cast<void*>() to fix warning when using
  -[NSData bytes].
* Plugins/WebNetscapePluginView.mm:
(-[WebNetscapePluginView _createPlugin]):
- Change C-style cast to const_cast<char*>() to fix
  warning.
* WebCoreSupport/WebChromeClient.mm:
(WebChromeClient::wrapCryptoKey const):
(WebChromeClient::unwrapCryptoKey const):
- Change C-style cast to
  static_cast<uint8_t*>(const_cast<void*>() to fix
  warning.
* WebView/WebPDFView.mm:
(_applicationInfoForMIMEType):
- Change local variable type from 'NSURL *' to
  'CFURLRef' to fix warning.  Cast back to 'NSURL *'
  when calling -[NSURL path].

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

29 files changed:
Source/WebInspectorUI/ChangeLog
Source/WebInspectorUI/Configurations/Base.xcconfig
Source/WebKit/ChangeLog
Source/WebKit/Configurations/Base.xcconfig
Source/WebKit/NetworkProcess/cache/NetworkCacheCodersCocoa.cpp
Source/WebKit/Platform/cocoa/WKCrashReporter.mm
Source/WebKit/PluginProcess/mac/PluginProcessShim.mm
Source/WebKit/Shared/Authentication/mac/AuthenticationManager.mac.mm
Source/WebKit/Shared/cf/ArgumentCodersCF.cpp
Source/WebKit/Shared/mac/WebCoreArgumentCodersMac.mm
Source/WebKit/UIProcess/Cocoa/WebViewImpl.mm
Source/WebKitLegacy/ChangeLog
Source/WebKitLegacy/PlatformMac.cmake
Source/WebKitLegacy/WebKitLegacy.xcodeproj/project.pbxproj
Source/WebKitLegacy/mac/Carbon/CarbonUtils.m
Source/WebKitLegacy/mac/Carbon/CarbonWindowFrame.m
Source/WebKitLegacy/mac/Carbon/HIViewAdapter.m
Source/WebKitLegacy/mac/ChangeLog
Source/WebKitLegacy/mac/Configurations/Base.xcconfig
Source/WebKitLegacy/mac/Misc/WebElementDictionary.mm
Source/WebKitLegacy/mac/Misc/WebNSDataExtras.mm [moved from Source/WebKitLegacy/mac/Misc/WebNSDataExtras.m with 82% similarity]
Source/WebKitLegacy/mac/Plugins/Hosted/NetscapePluginHostManager.mm
Source/WebKitLegacy/mac/Plugins/Hosted/NetscapePluginHostProxy.mm
Source/WebKitLegacy/mac/Plugins/Hosted/ProxyInstance.mm
Source/WebKitLegacy/mac/Plugins/Hosted/WebTextInputWindowController.m
Source/WebKitLegacy/mac/Plugins/WebNetscapePluginStream.mm
Source/WebKitLegacy/mac/Plugins/WebNetscapePluginView.mm
Source/WebKitLegacy/mac/WebCoreSupport/WebChromeClient.mm
Source/WebKitLegacy/mac/WebView/WebPDFView.mm

index 755be7f..85d1435 100644 (file)
@@ -1,3 +1,14 @@
+2018-01-07  David Kilzer  <ddkilzer@apple.com>
+
+        Enable -Wcast-qual for WebInspectorUI, WebKitLegacy, WebKit projects
+        <https://webkit.org/b/181256>
+        <rdar://problem/36281730>
+
+        Reviewed by Darin Adler.
+
+        * Configurations/Base.xcconfig:
+        (WARNING_CFLAGS): Add -Wcast-qual.
+
 2018-01-05  Joseph Pecoraro  <pecoraro@apple.com>
 
         Web Inspector: Add another Protocol Version
index 76047ca..8c6d133 100644 (file)
@@ -53,7 +53,7 @@ GCC_WARN_UNDECLARED_SELECTOR = YES;
 GCC_WARN_UNINITIALIZED_AUTOS = YES
 GCC_WARN_UNUSED_FUNCTION = YES;
 GCC_WARN_UNUSED_VARIABLE = YES
-WARNING_CFLAGS = -Wall -W -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 -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 8775a39..2ba04b2 100644 (file)
@@ -1,3 +1,42 @@
+2018-01-07  David Kilzer  <ddkilzer@apple.com>
+
+        Enable -Wcast-qual for WebInspectorUI, WebKitLegacy, WebKit projects
+        <https://webkit.org/b/181256>
+        <rdar://problem/36281730>
+
+        Reviewed by Darin Adler.
+
+        * Configurations/Base.xcconfig:
+        (WARNING_CFLAGS): Add -Wcast-qual.
+        * NetworkProcess/cache/NetworkCacheCodersCocoa.cpp:
+        (WTF::Persistence::encodeCertificateChain): Include
+        TypeCastsCF.h from WTF, and use
+        checked_cf_cast<SecCertificateRef>() to fix warning.
+        * Platform/cocoa/WKCrashReporter.mm:
+        (WebKit::setCrashReportApplicationSpecificInformation):
+        - Move `oldMessage` check above nullptr check to fix a leak when
+          passing in nullptr after previously setting the crash string.
+        - Change C-style cast to const_cast<char*>() to fix warning.
+        * PluginProcess/mac/PluginProcessShim.mm:
+        (WebKit::shim_shmat): Change C-style cast to
+        const_cast<void*>() to fix warning.
+        * Shared/Authentication/mac/AuthenticationManager.mac.mm:
+        (WebKit::leafCertificate): Include TypeCastsCF.h from
+        WTF, and use checked_cf_cast<SecCertificateRef>() to fix
+        warning.
+        * Shared/cf/ArgumentCodersCF.cpp:
+        (IPC::encode): Use static_cast<>(const_cast<void*>() to
+        fix warnings since the CFTypeID has already been
+        checked.
+        * Shared/mac/WebCoreArgumentCodersMac.mm:
+        (IPC::decodeNSError): Use an `auto` variable to hold the
+        CFMutableDictionaryRef, then WTFMove() to assign it back to
+        `userInfo`.
+        * UIProcess/Cocoa/WebViewImpl.mm:
+        (WebKit::takeWindowSnapshot): Include TypeCastsCF.h from
+        WTF, and use checked_cf_cast<CGImageRef>() to fix
+        warning.
+
 2018-01-07  Konstantin Tokarev  <annulen@yandex.ru>
 
         [cmake] Unset CMAKE_REQUIRED_LIBRARIES after check_function_exists test
index 1226718..eb7c997 100644 (file)
@@ -80,7 +80,7 @@ GCC_WARN_UNUSED_FUNCTION = YES;
 GCC_WARN_UNUSED_VARIABLE = YES;
 OTHER_MIGFLAGS = -F$(BUILT_PRODUCTS_DIR);
 PREBINDING = NO;
-WARNING_CFLAGS = -Wall -Wextra -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 -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_11 = 101100;
index c66cc3b..3a0f38a 100644 (file)
 #if PLATFORM(COCOA)
 #include <Security/SecCertificate.h>
 #include <Security/SecTrust.h>
+#include <wtf/cf/TypeCastsCF.h>
 #include <wtf/spi/cocoa/SecuritySPI.h>
 #endif
 
+WTF_DECLARE_CF_TYPE_TRAIT(SecCertificate);
+
 namespace WTF {
 namespace Persistence {
 
@@ -105,9 +108,7 @@ static void encodeCertificateChain(Encoder& encoder, CFArrayRef certificateChain
 
     for (CFIndex i = 0; i < size; ++i) {
         ASSERT(values[i]);
-        ASSERT(CFGetTypeID(values[i]) == SecCertificateGetTypeID());
-
-        auto data = adoptCF(SecCertificateCopyData((SecCertificateRef)values[i]));
+        auto data = adoptCF(SecCertificateCopyData(checked_cf_cast<SecCertificateRef>(values[i])));
         encodeCFData(encoder, data.get());
     }
 }
index f2ac34c..a4e6dee 100644 (file)
@@ -38,15 +38,14 @@ namespace WebKit {
 
 void setCrashReportApplicationSpecificInformation(CFStringRef infoString)
 {
+    if (char* oldMessage = const_cast<char*>(CRGetCrashLogMessage()))
+        free(oldMessage);
+
     if (!infoString) {
         CRSetCrashLogMessage(nullptr);
         return;
     }
 
-    char* oldMessage = (char*)CRGetCrashLogMessage();
-    if (oldMessage)
-        free(oldMessage);
-
     // We have to copy the string, because CRSetCrashLogMessage doesn't copy the data.
     char* lastInfoChars = strdup([(NSString *)infoString UTF8String]);
     CRSetCrashLogMessage(lastInfoChars);
index f635169..4036d3b 100644 (file)
@@ -240,7 +240,7 @@ static void* shim_shmat(int sharedMemoryIdentifier, const void* requestedSharedA
         }
     } else {
         descriptorPtr->mmapedSize = (descriptorPtr->requestedSize + PAGE_SIZE) & ~(PAGE_SIZE - 1);
-        mappedAddress = descriptorPtr->mmapedAddress = mmap((void*)requestedSharedAddress,
+        mappedAddress = descriptorPtr->mmapedAddress = mmap(const_cast<void*>(requestedSharedAddress),
             descriptorPtr->mmapedSize, PROT_READ | PROT_WRITE, MAP_ANON | MAP_PRIVATE, -1, 0);
         descriptorPtr->referenceCount++;
     }
index 4e8b68a..377a7f8 100644 (file)
@@ -32,6 +32,9 @@
 #include <WebCore/AuthenticationChallenge.h>
 #include <WebCore/CertificateInfo.h>
 #include <WebCore/NotImplemented.h>
+#include <wtf/cf/TypeCastsCF.h>
+
+WTF_DECLARE_CF_TYPE_TRAIT(SecCertificate);
 
 using namespace WebCore;
 
@@ -45,7 +48,7 @@ static SecCertificateRef leafCertificate(const CertificateInfo& certificateInfo)
 #endif
     ASSERT(certificateInfo.type() == CertificateInfo::Type::CertificateChain);
     ASSERT(CFArrayGetCount(certificateInfo.certificateChain()));
-    return (SecCertificateRef)CFArrayGetValueAtIndex(certificateInfo.certificateChain(), 0);
+    return checked_cf_cast<SecCertificateRef>(CFArrayGetValueAtIndex(certificateInfo.certificateChain(), 0));
 }
 
 static NSArray *chain(const CertificateInfo& certificateInfo)
index 0fdd14d..145b076 100644 (file)
@@ -175,24 +175,24 @@ void encode(Encoder& encoder, CFTypeRef typeRef)
         encode(encoder, static_cast<CFURLRef>(typeRef));
         return;
     case SecCertificate:
-        encode(encoder, (SecCertificateRef)typeRef);
+        encode(encoder, static_cast<SecCertificateRef>(const_cast<void*>(typeRef)));
         return;
     case SecIdentity:
-        encode(encoder, (SecIdentityRef)(typeRef));
+        encode(encoder, static_cast<SecIdentityRef>(const_cast<void*>(typeRef)));
         return;
 #if HAVE(SEC_KEYCHAIN)
     case SecKeychainItem:
-        encode(encoder, (SecKeychainItemRef)typeRef);
+        encode(encoder, static_cast<SecKeychainItemRef>(const_cast<void*>(typeRef)));
         return;
 #endif
 #if HAVE(SEC_ACCESS_CONTROL)
     case SecAccessControl:
-        encode(encoder, (SecAccessControlRef)typeRef);
+        encode(encoder, static_cast<SecAccessControlRef>(const_cast<void*>(typeRef)));
         return;
 #endif
 #if HAVE(SEC_TRUST_SERIALIZATION)
     case SecTrust:
-        encode(encoder, (SecTrustRef)typeRef);
+        encode(encoder, static_cast<SecTrustRef>(const_cast<void*>(typeRef)));
         return;
 #endif
     case Null:
index ec91680..7612e46 100644 (file)
@@ -400,8 +400,9 @@ static bool decodeNSError(Decoder& decoder, RetainPtr<NSError>& nsError)
         if (!decodeNSError(decoder, underlyingNSError))
             return false;
 
-        userInfo = adoptCF(CFDictionaryCreateMutableCopy(kCFAllocatorDefault, CFDictionaryGetCount(userInfo.get()) + 1, userInfo.get()));
-        CFDictionarySetValue((CFMutableDictionaryRef)userInfo.get(), NSUnderlyingErrorKey, underlyingNSError.get());
+        auto mutableUserInfo = adoptCF(CFDictionaryCreateMutableCopy(kCFAllocatorDefault, CFDictionaryGetCount(userInfo.get()) + 1, userInfo.get()));
+        CFDictionarySetValue(mutableUserInfo.get(), NSUnderlyingErrorKey, underlyingNSError.get());
+        userInfo = WTFMove(mutableUserInfo);
     }
 
     nsError = adoptNS([[NSError alloc] initWithDomain:domain code:code userInfo:(NSDictionary *)userInfo.get()]);
index 8526d67..4036e51 100644 (file)
 #import <wtf/NeverDestroyed.h>
 #import <wtf/SetForScope.h>
 #import <wtf/SoftLinking.h>
+#import <wtf/cf/TypeCastsCF.h>
 #import <wtf/text/StringConcatenate.h>
 
 #if HAVE(TOUCH_BAR) && ENABLE(WEB_PLAYBACK_CONTROLS_MANAGER)
@@ -119,6 +120,8 @@ static NSString * const WKMediaExitFullScreenItem = @"WKMediaExitFullScreenItem"
 
 SOFT_LINK_CONSTANT_MAY_FAIL(Lookup, LUNotificationPopoverWillClose, NSString *)
 
+WTF_DECLARE_CF_TYPE_TRAIT(CGImage);
+
 @interface NSApplication ()
 - (BOOL)isSpeaking;
 - (void)speakString:(NSString *)string;
@@ -3928,7 +3931,7 @@ static RetainPtr<CGImageRef> takeWindowSnapshot(CGSWindowID windowID, bool captu
     RetainPtr<CFArrayRef> windowSnapshotImages = adoptCF(CGSHWCaptureWindowList(CGSMainConnectionID(), &windowID, 1, options));
 
     if (windowSnapshotImages && CFArrayGetCount(windowSnapshotImages.get()))
-        return (CGImageRef)CFArrayGetValueAtIndex(windowSnapshotImages.get(), 0);
+        return checked_cf_cast<CGImageRef>(CFArrayGetValueAtIndex(windowSnapshotImages.get(), 0));
 
     // Fall back to the non-hardware capture path if we didn't get a snapshot
     // (which usually happens if the window is fully off-screen).
index b0e564a..90752cc 100644 (file)
@@ -1,3 +1,16 @@
+2018-01-07  David Kilzer  <ddkilzer@apple.com>
+
+        Enable -Wcast-qual for WebInspectorUI, WebKitLegacy, WebKit projects
+        <https://webkit.org/b/181256>
+        <rdar://problem/36281730>
+
+        Reviewed by Darin Adler.
+
+        * PlatformMac.cmake:
+        * WebKitLegacy.xcodeproj/project.pbxproj:
+        - Rename WebNSDataExtras.m to WebNSDataExtras.mm and change file
+          type to Objective-C++.
+
 2018-01-03  Ting-Wei Lan  <lantw44@gmail.com>
 
         Replace hard-coded paths in shebangs with #!/usr/bin/env
index 59ab346..0cbe38f 100644 (file)
@@ -191,7 +191,7 @@ list(APPEND WebKitLegacy_SOURCES
     mac/Misc/WebLocalizableStrings.mm
     mac/Misc/WebLocalizableStringsInternal.mm
     mac/Misc/WebNSControlExtras.m
-    mac/Misc/WebNSDataExtras.m
+    mac/Misc/WebNSDataExtras.mm
     mac/Misc/WebNSDictionaryExtras.m
     mac/Misc/WebNSEventExtras.m
     mac/Misc/WebNSFileManagerExtras.mm
@@ -372,7 +372,6 @@ set(C99_FILES
     mac/Misc/WebKitSystemBits.m
     mac/Misc/WebNSArrayExtras.m
     mac/Misc/WebNSControlExtras.m
-    mac/Misc/WebNSDataExtras.m
     mac/Misc/WebNSDictionaryExtras.m
     mac/Misc/WebNSEventExtras.m
     mac/Misc/WebNSImageExtras.m
index 4225cd2..53c9af2 100644 (file)
                9398110A0824BF01008DF038 /* WebDefaultUIDelegate.mm in Sources */ = {isa = PBXBuildFile; fileRef = 515E27D00458CA4B00CA2D3A /* WebDefaultUIDelegate.mm */; };
                939811120824BF01008DF038 /* WebNSURLExtras.mm in Sources */ = {isa = PBXBuildFile; fileRef = BE6DC39A04C62C4E004D0EF6 /* WebNSURLExtras.mm */; };
                939811130824BF01008DF038 /* WebHistory.mm in Sources */ = {isa = PBXBuildFile; fileRef = 65DA2608052CC18700A97B31 /* WebHistory.mm */; };
-               939811150824BF01008DF038 /* WebNSDataExtras.m in Sources */ = {isa = PBXBuildFile; fileRef = BECD142A0565830A005BB09C /* WebNSDataExtras.m */; };
+               939811150824BF01008DF038 /* WebNSDataExtras.mm in Sources */ = {isa = PBXBuildFile; fileRef = BECD142A0565830A005BB09C /* WebNSDataExtras.mm */; };
                939811160824BF01008DF038 /* WebNSEventExtras.m in Sources */ = {isa = PBXBuildFile; fileRef = BE887C00056D3A6E009BB3E7 /* WebNSEventExtras.m */; };
                939811190824BF01008DF038 /* WebNSPrintOperationExtras.m in Sources */ = {isa = PBXBuildFile; fileRef = EDD1A5C705C83987008E3150 /* WebNSPrintOperationExtras.m */; };
                9398111A0824BF01008DF038 /* WebResource.mm in Sources */ = {isa = PBXBuildFile; fileRef = 84311A1305EAAAF00088EDA4 /* WebResource.mm */; };
                BE95BEE505FD0805006E1513 /* WebDefaultEditingDelegate.m */ = {isa = PBXFileReference; fileEncoding = 30; indentWidth = 4; lastKnownFileType = sourcecode.c.objc; path = WebDefaultEditingDelegate.m; sourceTree = "<group>"; tabWidth = 8; usesTabs = 0; };
                BE95BEE605FD0805006E1513 /* WebDefaultEditingDelegate.h */ = {isa = PBXFileReference; fileEncoding = 30; indentWidth = 4; lastKnownFileType = sourcecode.c.h; path = WebDefaultEditingDelegate.h; sourceTree = "<group>"; tabWidth = 8; usesTabs = 0; };
                BECD14290565830A005BB09C /* WebNSDataExtras.h */ = {isa = PBXFileReference; fileEncoding = 4; indentWidth = 4; lastKnownFileType = sourcecode.c.h; path = WebNSDataExtras.h; sourceTree = "<group>"; tabWidth = 8; usesTabs = 0; };
-               BECD142A0565830A005BB09C /* WebNSDataExtras.m */ = {isa = PBXFileReference; fileEncoding = 4; indentWidth = 4; lastKnownFileType = sourcecode.c.objc; path = WebNSDataExtras.m; sourceTree = "<group>"; tabWidth = 8; usesTabs = 0; };
+               BECD142A0565830A005BB09C /* WebNSDataExtras.mm */ = {isa = PBXFileReference; fileEncoding = 4; indentWidth = 4; lastKnownFileType = sourcecode.c.objcpp; path = WebNSDataExtras.mm; sourceTree = "<group>"; tabWidth = 8; usesTabs = 0; };
                BEE18F990472B73200CA289C /* WebLocalizableStrings.h */ = {isa = PBXFileReference; fileEncoding = 30; indentWidth = 4; lastKnownFileType = sourcecode.c.h; path = WebLocalizableStrings.h; sourceTree = "<group>"; tabWidth = 8; usesTabs = 0; };
                C0167BF60D7F5DD00028696E /* WebScriptDebugger.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebScriptDebugger.h; sourceTree = "<group>"; };
                C0167BF70D7F5DD00028696E /* WebScriptDebugger.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WebScriptDebugger.mm; sourceTree = "<group>"; };
                                9345DDB20365FFD0008635CE /* WebNSControlExtras.h */,
                                9345DDB30365FFD0008635CE /* WebNSControlExtras.m */,
                                BECD14290565830A005BB09C /* WebNSDataExtras.h */,
-                               BECD142A0565830A005BB09C /* WebNSDataExtras.m */,
+                               BECD142A0565830A005BB09C /* WebNSDataExtras.mm */,
                                ED7F6D8A0980683500C235ED /* WebNSDataExtrasPrivate.h */,
                                65488D9F084FBCCB00831AD0 /* WebNSDictionaryExtras.h */,
                                65488DA0084FBCCB00831AD0 /* WebNSDictionaryExtras.m */,
                                312E2FE614E48182007CCA18 /* WebNotification.mm in Sources */,
                                31C11A6F1476552E0049A4CC /* WebNotificationClient.mm in Sources */,
                                939810C60824BF01008DF038 /* WebNSControlExtras.m in Sources */,
-                               939811150824BF01008DF038 /* WebNSDataExtras.m in Sources */,
+                               939811150824BF01008DF038 /* WebNSDataExtras.mm in Sources */,
                                65488DA2084FBCCB00831AD0 /* WebNSDictionaryExtras.m in Sources */,
                                939811160824BF01008DF038 /* WebNSEventExtras.m in Sources */,
                                65EEDE58084FFC9E0002DB25 /* WebNSFileManagerExtras.mm in Sources */,
index 9437c9b..af197c7 100644 (file)
@@ -87,7 +87,10 @@ static void
 PoolCleaner( EventLoopTimerRef inTimer, EventLoopIdleTimerMessage inState, void *inUserData )
 {
     if ( inState == kEventLoopIdleTimerStarted ) {
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wcast-qual"
         CFStringRef mode = CFRunLoopCopyCurrentMode( (CFRunLoopRef)GetCFRunLoopFromEventLoop( GetCurrentEventLoop() ));
+#pragma clang diagnostic pop
         EventLoopRef thisLoop = GetCurrentEventLoop ();
         if ( CFEqual( mode, kCFRunLoopDefaultMode ) && thisLoop == poolLoop) {
             unsigned currentNumPools = getNSAutoreleasePoolCount()-1;            
index 4068c0b..ac2a5f7 100644 (file)
     windowRef = [carbonWindow windowRef];
     osStatus = CopyWindowTitleAsCFString(windowRef, &windowTitle);
     if (osStatus==noErr) {
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wcast-qual"
         windowTitleAsNSString = (NSString *)windowTitle;
+#pragma clang diagnostic pop
     } else {
         NSLog(@"A Carbon window's title couldn't be gotten.");
         windowTitleAsNSString = @"";
index 3553707..f3d9965 100644 (file)
@@ -88,7 +88,10 @@ static NSView *_webkit_NSView_nextValidKeyView(id self, SEL _cmd);
 
 + (HIViewRef)getHIViewForNSView:(NSView*)inView
 {
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wcast-qual"
     return sViewMap ? (HIViewRef)CFDictionaryGetValue(sViewMap, inView) : NULL;
+#pragma clang diagnostic pop
 }
 
 + (void)unbindNSView:(NSView*)inView
index f61e99d..1506082 100644 (file)
@@ -1,3 +1,92 @@
+2018-01-07  David Kilzer  <ddkilzer@apple.com>
+
+        Enable -Wcast-qual for WebInspectorUI, WebKitLegacy, WebKit projects
+        <https://webkit.org/b/181256>
+        <rdar://problem/36281730>
+
+        Reviewed by Darin Adler.
+
+        * Carbon/CarbonUtils.m:
+        (PoolCleaner):
+        - Use #pragmas to ignore -Wcast-qual warnings when using a
+          C-style cast from CFTypeRef to CFRunloopRef.
+        * Carbon/CarbonWindowFrame.m:
+        (-[CarbonWindowFrame title]):
+        - Use #pragmas to ignore -Wcast-qual warnings when using a
+          C-style cast from CFStringRef to NSString *.
+        * Carbon/HIViewAdapter.m:
+        (+[HIViewAdapter getHIViewForNSView:]):
+        - Use #pragmas to ignore -Wcast-qual warnings when using a
+          C-style cast from CFTypeRef to HIViewRef.
+        * Configurations/Base.xcconfig:
+        (WARNING_CFLAGS): Add -Wcast-qual.
+        * Misc/WebElementDictionary.mm:
+        (-[WebElementDictionary objectForKey:]):
+        - Use static_cast<SEL>(const_cast<void*>()) to fix
+          warning.
+        * Misc/WebNSDataExtras.mm: Renamed from Source/WebKitLegacy/mac/Misc/WebNSDataExtras.m.
+        (-[NSString _web_capitalizeRFC822HeaderFieldName]):
+        (-[NSData _webkit_guessedMIMETypeForXML]):
+        (-[NSData _webkit_guessedMIMEType]):
+        (-[NSData _web_isCaseInsensitiveEqualToCString:]):
+        (_findEOL):
+        (-[NSData _webkit_parseRFC822HeaderFields]):
+        (-[NSData _web_startsWithBlankLine]):
+        (-[NSData _web_locationAfterFirstBlankLine]):
+        - Rename WebNSDataExtras.m to WebNSDataExtras.mm and change file
+          type to Objective-C++.  This fixes the warnings about
+          discarding the `const` modifier when casing from CFStringRef
+          to NSString * because in older clang versions, -Wcast-qual was
+          completely broken when compiling C++ and Objective-C++ source
+          files.  In newer clang versions, discarding the `const`
+          modifier for toll-free bridged types is ignored when compiling
+          Objective-C++ source.
+        - Update copyright and license header.
+        - Use reinterpret_cast<> and static_cast<> to fix warnings
+          unrelated to (NSString *) C-style casts.
+        - Replace use of MIN() macro with std::min<> template functions.
+        - Fix location of `*` for local variables modified above.
+        * Plugins/Hosted/NetscapePluginHostManager.mm:
+        (WebKit::NetscapePluginHostManager::spawnPluginHost):
+        (WebKit::NetscapePluginHostManager::initializeVendorPort):
+        (WebKit::NetscapePluginHostManager::instantiatePlugin):
+        - Use static_cast<uint8_t*>(const_cast<void*>()) to fix
+          warnings.
+        * Plugins/Hosted/NetscapePluginHostProxy.mm:
+        (WebKit::NetscapePluginHostProxy::NetscapePluginHostProxy):
+        - Use reinterpret_cast<mig_subsystem_t>(const_cast<struct WKWebKitPluginClient_subsystem*>())
+          to fix warning.
+        * Plugins/Hosted/ProxyInstance.mm:
+        (WebKit::ProxyInstance::invoke):
+        - Use static_cast<char*>(const_cast<void*>()) to fix
+          warning when using -[NSData bytes].
+        (WebKit::ProxyInstance::fieldValue const):
+        - Use reinterpret_cast<char*>(const_cast<unsigned char*>())
+          to fix warning when using CFDataGetBytePtr().
+        * Plugins/Hosted/WebTextInputWindowController.m:
+        (-[WebTextInputPanel _interpretKeyEvent:string:]):
+        - Use #pragma to ignore -Wcast-qual warning since there
+          is not a good way to avoid this warning in Objective-C.
+        * Plugins/WebNetscapePluginStream.mm:
+        (WebNetscapePluginStream::deliverData):
+        - Use const_cast<void*>() to fix warning when using
+          -[NSData bytes].
+        * Plugins/WebNetscapePluginView.mm:
+        (-[WebNetscapePluginView _createPlugin]):
+        - Change C-style cast to const_cast<char*>() to fix
+          warning.
+        * WebCoreSupport/WebChromeClient.mm:
+        (WebChromeClient::wrapCryptoKey const):
+        (WebChromeClient::unwrapCryptoKey const):
+        - Change C-style cast to
+          static_cast<uint8_t*>(const_cast<void*>() to fix
+          warning.
+        * WebView/WebPDFView.mm:
+        (_applicationInfoForMIMEType):
+        - Change local variable type from 'NSURL *' to
+          'CFURLRef' to fix warning.  Cast back to 'NSURL *'
+          when calling -[NSURL path].
+
 2018-01-05  Dan Bernstein  <mitz@apple.com>
 
         Fixed the build following AppKit API deprecations in a recent SDKs
index 7635031..4353ab4 100644 (file)
@@ -81,7 +81,7 @@ GCC_WARN_UNUSED_VARIABLE = YES;
 CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
 OTHER_MIGFLAGS = -F$(BUILT_PRODUCTS_DIR);
 PREBINDING = NO;
-WARNING_CFLAGS = -Wall -Wextra -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 -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_11 = 101100;
index de09aa6..5529390 100644 (file)
@@ -148,7 +148,7 @@ static void cacheValueForKey(const void *key, const void *value, void *self)
     if (value || _cacheComplete || [_nilValues containsObject:key])
         return value;
 
-    SEL selector = (SEL)CFDictionaryGetValue(lookupTable, key);
+    SEL selector = static_cast<SEL>(const_cast<void*>(CFDictionaryGetValue(lookupTable, key)));
     if (!selector)
         return nil;
     value = [self performSelector:selector];
@@ -1,29 +1,26 @@
 /*
- * Copyright (C) 2005 Apple Inc.  All rights reserved.
+ * Copyright (C) 2005-2018 Apple Inc.  All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
  * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
  *
- * 1.  Redistributions of source code must retain the above copyright
- *     notice, this list of conditions and the following disclaimer. 
- * 2.  Redistributions in binary form must reproduce the above copyright
- *     notice, this list of conditions and the following disclaimer in the
- *     documentation and/or other materials provided with the distribution. 
- * 3.  Neither the name of Apple Inc. ("Apple") nor the names of
- *     its contributors may be used to endorse or promote products derived
- *     from this software without specific prior written permission. 
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
  */
 
 #import <WebKitLegacy/WebNSDataExtras.h>
@@ -44,8 +41,8 @@
 
     CFIndex i; 
     CFIndex len = CFStringGetLength(name);
-    char *charPtr = NULL;
-    UniChar *uniCharPtr = NULL;
+    char* charPtr = nullptr;
+    UniChar* uniCharPtr = nullptr;
     Boolean useUniCharPtr = FALSE;
     Boolean shouldCapitalize = TRUE;
     Boolean somethingChanged = FALSE;
                 if (CFStringGetBytes(name, CFRangeMake(0, len), kCFStringEncodingISOLatin1, 0, FALSE, NULL, 0, NULL) == len) {
                     // Can be encoded in ISOLatin1
                     useUniCharPtr = FALSE;
-                    charPtr = CFAllocatorAllocate(NULL, len + 1, 0);
+                    charPtr = static_cast<char*>(CFAllocatorAllocate(kCFAllocatorDefault, len + 1, 0));
                     CFStringGetCString(name, charPtr, len+1, kCFStringEncodingISOLatin1);
                 } 
                 else {
                     useUniCharPtr = TRUE;
-                    uniCharPtr = CFAllocatorAllocate(NULL, len * sizeof(UniChar), 0);
+                    uniCharPtr = static_cast<UniChar*>(CFAllocatorAllocate(kCFAllocatorDefault, len * sizeof(UniChar), 0));
                     CFStringGetCharacters(name, CFRangeMake(0, len), uniCharPtr);
                 }
             }
 -(NSString *)_webkit_guessedMIMETypeForXML
 {
     NSUInteger length = [self length];
-    const UInt8 *bytes = [self bytes];
+    const UInt8* bytes = static_cast<const UInt8*>([self bytes]);
     
 #define CHANNEL_TAG_LENGTH 7
     
-    const char *p = (const char *)bytes;
-    int remaining = MIN(length, WEB_GUESS_MIME_TYPE_PEEK_LENGTH) - (CHANNEL_TAG_LENGTH - 1);
+    const char* p = reinterpret_cast<const char*>(bytes);
+    int remaining = std::min<NSUInteger>(length, WEB_GUESS_MIME_TYPE_PEEK_LENGTH) - (CHANNEL_TAG_LENGTH - 1);
     
     BOOL foundRDF = false;
     
     while (remaining > 0) {
         // Look for a "<".
-        const char *hit = memchr(p, '<', remaining);
+        const char* hit = static_cast<const char*>(memchr(p, '<', remaining));
         if (!hit) {
             break;
         }
         return MIMEType;
     
     NSUInteger length = [self length];
-    const char *bytes = [self bytes];
+    const char* bytes = static_cast<const char*>([self bytes]);
     
-    const char *p = bytes;
-    int remaining = MIN(length, WEB_GUESS_MIME_TYPE_PEEK_LENGTH) - (SCRIPT_TAG_LENGTH - 1);
+    const charp = bytes;
+    int remaining = std::min<NSUInteger>(length, WEB_GUESS_MIME_TYPE_PEEK_LENGTH) - (SCRIPT_TAG_LENGTH - 1);
     while (remaining > 0) {
         // Look for a "<".
-        const char *hit = memchr(p, '<', remaining);
+        const char* hit = static_cast<const char*>(memchr(p, '<', remaining));
         if (!hit) {
             break;
         }
     // Test for a broken server which has sent the content type as part of the content.
     // This code could be improved to look for other mime types.
     p = bytes;
-    remaining = MIN(length, WEB_GUESS_MIME_TYPE_PEEK_LENGTH) - (TEXT_HTML_LENGTH - 1);
+    remaining = std::min<NSUInteger>(length, WEB_GUESS_MIME_TYPE_PEEK_LENGTH) - (TEXT_HTML_LENGTH - 1);
     while (remaining > 0) {
         // Look for a "t" or "T".
-        const char *hit = NULL;
-        const char *lowerhit = memchr(p, 't', remaining);
-        const char *upperhit = memchr(p, 'T', remaining);
+        const char* hit = nullptr;
+        const char* lowerhit = static_cast<const char*>(memchr(p, 't', remaining));
+        const char* upperhit = static_cast<const char*>(memchr(p, 'T', remaining));
         if (!lowerhit && !upperhit) {
             break;
         }
             hit = lowerhit;
         }
         else {
-            hit = MIN(lowerhit, upperhit);
+            hit = std::min<const char*>(lowerhit, upperhit);
         }
         
         // If we found a "t/T", look for "text/html".
 {
     ASSERT(string);
     
-    const char *bytes = [self bytes];
+    const char* bytes = static_cast<const char*>([self bytes]);
     return strncasecmp(bytes, string, [self length]) == 0;
 }
 
@@ -310,7 +307,7 @@ static const UInt8 *_findEOL(const UInt8 *bytes, CFIndex len) {
 {
     NSMutableDictionary *headerFields = [NSMutableDictionary dictionary];
 
-    const UInt8 *bytes = [self bytes];
+    const UInt8* bytes = static_cast<const UInt8*>([self bytes]);
     NSUInteger length = [self length];
     NSString *lastKey = nil;
     const UInt8 *eol;
index 9ec5478..95b88f6 100644 (file)
@@ -192,7 +192,7 @@ bool NetscapePluginHostManager::spawnPluginHost(const String& pluginPath, cpu_ty
     GetCurrentProcess(&psn);
 #pragma clang diagnostic pop
 
-    kr = _WKPHCheckInWithPluginHost(pluginHostPort, (uint8_t*)[data bytes], [data length], clientPort, psn.highLongOfPSN, psn.lowLongOfPSN, renderServerPort,
+    kr = _WKPHCheckInWithPluginHost(pluginHostPort, static_cast<uint8_t*>(const_cast<void*>([data bytes])), [data length], clientPort, psn.highLongOfPSN, psn.lowLongOfPSN, renderServerPort,
                                     &pluginHostPSN.highLongOfPSN, &pluginHostPSN.lowLongOfPSN);
     
     if (kr != KERN_SUCCESS) {
@@ -219,7 +219,7 @@ bool NetscapePluginHostManager::initializeVendorPort()
     NSData *appNameData = [[[NSProcessInfo processInfo] processName] dataUsingEncoding:NSUTF8StringEncoding];
     
     // Tell the plug-in agent that we exist.
-    if (_WKPACheckInApplication(pluginAgentPort, (uint8_t*)[appNameData bytes], [appNameData length], &m_pluginVendorPort) != KERN_SUCCESS)
+    if (_WKPACheckInApplication(pluginAgentPort, static_cast<uint8_t*>(const_cast<void*>([appNameData bytes])), [appNameData length], &m_pluginVendorPort) != KERN_SUCCESS)
         return false;
 
     // FIXME: Should we add a notification for when the vendor port dies?
@@ -273,7 +273,7 @@ RefPtr<NetscapePluginInstanceProxy> NetscapePluginHostManager::instantiatePlugin
     
     RefPtr<NetscapePluginInstanceProxy> instance = NetscapePluginInstanceProxy::create(hostProxy, pluginView, fullFrame);
     uint32_t requestID = instance->nextRequestID();
-    kern_return_t kr = _WKPHInstantiatePlugin(hostProxy->port(), requestID, (uint8_t*)[data bytes], [data length], instance->pluginID());
+    kern_return_t kr = _WKPHInstantiatePlugin(hostProxy->port(), requestID, static_cast<uint8_t*>(const_cast<void*>([data bytes])), [data length], instance->pluginID());
     if (kr == MACH_SEND_INVALID_DEST) {
         // Invalidate the instance.
         instance->invalidate();
@@ -287,7 +287,7 @@ RefPtr<NetscapePluginInstanceProxy> NetscapePluginHostManager::instantiatePlugin
         // Create a new instance.
         instance = NetscapePluginInstanceProxy::create(hostProxy, pluginView, fullFrame);
         requestID = instance->nextRequestID();
-        _WKPHInstantiatePlugin(hostProxy->port(), requestID, (uint8_t*)[data bytes], [data length], instance->pluginID());
+        _WKPHInstantiatePlugin(hostProxy->port(), requestID, static_cast<uint8_t*>(const_cast<void*>([data bytes])), [data length], instance->pluginID());
     }
 
     auto reply = instance->waitForReply<NetscapePluginInstanceProxy::InstantiatePluginReply>(requestID);
index bcadde8..6d1f76a 100644 (file)
@@ -117,7 +117,7 @@ NetscapePluginHostProxy::NetscapePluginHostProxy(mach_port_t clientPort, mach_po
     
     CFRunLoopAddSource(CFRunLoopGetCurrent(), deathPortSource.get(), kCFRunLoopDefaultMode);
     
-    m_clientPortSource = adoptCF(MSHCreateMIGServerSource(nullptr, 0, (mig_subsystem_t)&WKWebKitPluginClient_subsystem, 0, m_clientPort, nullptr));
+    m_clientPortSource = adoptCF(MSHCreateMIGServerSource(nullptr, 0, reinterpret_cast<mig_subsystem_t>(const_cast<struct WKWebKitPluginClient_subsystem*>(&WKWebKitPluginClient_subsystem)), 0, m_clientPort, nullptr));
     CFRunLoopAddSource(CFRunLoopGetCurrent(), m_clientPortSource.get(), kCFRunLoopDefaultMode);
     CFRunLoopAddSource(CFRunLoopGetCurrent(), m_clientPortSource.get(), (CFStringRef)NSEventTrackingRunLoopMode);
 }
index ea8fcda..47a5b33 100644 (file)
@@ -153,8 +153,7 @@ JSValue ProxyInstance::invoke(JSC::ExecState* exec, InvokeType type, uint64_t id
     for (unsigned i = 0; i < args.size(); i++)
         m_instanceProxy->retainLocalObject(args.at(i));
 
-    if (_WKPHNPObjectInvoke(m_instanceProxy->hostProxy()->port(), m_instanceProxy->pluginID(), requestID, m_objectID,
-                            type, identifier, (char*)[arguments.get() bytes], [arguments.get() length]) != KERN_SUCCESS) {
+    if (_WKPHNPObjectInvoke(m_instanceProxy->hostProxy()->port(), m_instanceProxy->pluginID(), requestID, m_objectID, type, identifier, static_cast<char*>(const_cast<void*>([arguments.get() bytes])), [arguments.get() length]) != KERN_SUCCESS) {
         if (m_instanceProxy) {
             for (unsigned i = 0; i < args.size(); i++)
                 m_instanceProxy->releaseLocalObject(args.at(i));
@@ -173,7 +172,7 @@ JSValue ProxyInstance::invoke(JSC::ExecState* exec, InvokeType type, uint64_t id
     if (!reply || !reply->m_returnValue)
         return jsUndefined();
     
-    return m_instanceProxy->demarshalValue(exec, (char*)CFDataGetBytePtr(reply->m_result.get()), CFDataGetLength(reply->m_result.get()));
+    return m_instanceProxy->demarshalValue(exec, reinterpret_cast<char*>(const_cast<unsigned char*>(CFDataGetBytePtr(reply->m_result.get()))), CFDataGetLength(reply->m_result.get()));
 }
 
 class ProxyRuntimeMethod : public RuntimeMethod {
@@ -418,7 +417,7 @@ JSC::JSValue ProxyInstance::fieldValue(ExecState* exec, const Field* field) cons
     if (!reply || !reply->m_returnValue)
         return jsUndefined();
     
-    return m_instanceProxy->demarshalValue(exec, (char*)CFDataGetBytePtr(reply->m_result.get()), CFDataGetLength(reply->m_result.get()));
+    return m_instanceProxy->demarshalValue(exec, reinterpret_cast<char*>(const_cast<unsigned char*>(CFDataGetBytePtr(reply->m_result.get()))), CFDataGetLength(reply->m_result.get()));
 }
     
 bool ProxyInstance::setFieldValue(ExecState* exec, const Field* field, JSValue value) const
index 38e1d4b..fbd667b 100644 (file)
 
     // Let TSM know that a bottom input window would be created for marked text.
     // FIXME: Can be removed once we can rely on __NSUsesFloatingInputWindow (or a better API) being available everywhere.
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wcast-qual"
     EventRef carbonEvent = (EventRef)[event eventRef];
+#pragma clang diagnostic pop
     if (carbonEvent) {
         Boolean ignorePAH = true;
         SetEventParameter(carbonEvent, 'iPAH', typeBoolean, sizeof(ignorePAH), &ignorePAH);
index 21ff0e2..9d7372b 100644 (file)
@@ -537,7 +537,7 @@ void WebNetscapePluginStream::deliverData()
             deliveryBytes = std::min(deliveryBytes, totalBytes - totalBytesDelivered);
             NSData *subdata = [m_deliveryData.get() subdataWithRange:NSMakeRange(totalBytesDelivered, deliveryBytes)];
             PluginStopDeferrer deferrer(m_pluginView.get());
-            deliveryBytes = m_pluginFuncs->write(m_plugin, &m_stream, m_offset, [subdata length], (void *)[subdata bytes]);
+            deliveryBytes = m_pluginFuncs->write(m_plugin, &m_stream, m_offset, [subdata length], const_cast<void*>([subdata bytes]));
             if (deliveryBytes < 0) {
                 // Netscape documentation says that a negative result from NPP_Write means cancel the load.
                 cancelLoadAndDestroyStreamWithError(pluginCancelledConnectionError());
@@ -553,7 +553,7 @@ void WebNetscapePluginStream::deliverData()
     if (totalBytesDelivered > 0) {
         if (totalBytesDelivered < totalBytes) {
             NSMutableData *newDeliveryData = [[NSMutableData alloc] initWithCapacity:totalBytes - totalBytesDelivered];
-            [newDeliveryData appendBytes:(char *)[m_deliveryData.get() bytes] + totalBytesDelivered length:totalBytes - totalBytesDelivered];
+            [newDeliveryData appendBytes:static_cast<char*>(const_cast<void*>([m_deliveryData.get() bytes])) + totalBytesDelivered length:totalBytes - totalBytesDelivered];
             
             m_deliveryData = adoptNS(newDeliveryData);
         } else {
index d51654f..d9c37c7 100644 (file)
@@ -2258,7 +2258,7 @@ static inline void getNPRect(const NSRect& nr, NPRect& npr)
     _isSilverlight = [_pluginPackage.get() bundleIdentifier] == "com.microsoft.SilverlightPlugin";
 
     [[self class] setCurrentPluginView:self];
-    NPError npErr = [_pluginPackage.get() pluginFuncs]->newp((char *)[_MIMEType.get() cString], plugin, _mode, argsCount, cAttributes, cValues, NULL);
+    NPError npErr = [_pluginPackage.get() pluginFuncs]->newp(const_cast<char*>([_MIMEType.get() cString]), plugin, _mode, argsCount, cAttributes, cValues, NULL);
     [[self class] setCurrentPluginView:nil];
     LOG(Plugins, "NPP_New: %d", npErr);
     return npErr;
index 9b524cb..3626369 100644 (file)
@@ -1055,7 +1055,7 @@ bool WebChromeClient::wrapCryptoKey(const Vector<uint8_t>& key, Vector<uint8_t>&
     SEL selector = @selector(webCryptoMasterKeyForWebView:);
     if ([[m_webView UIDelegate] respondsToSelector:selector]) {
         NSData *keyData = CallUIDelegate(m_webView, selector);
-        masterKey.append((uint8_t*)[keyData bytes], [keyData length]);
+        masterKey.append(static_cast<uint8_t*>(const_cast<void*>([keyData bytes])), [keyData length]);
     } else if (!getDefaultWebCryptoMasterKey(masterKey))
         return false;
 
@@ -1068,7 +1068,7 @@ bool WebChromeClient::unwrapCryptoKey(const Vector<uint8_t>& wrappedKey, Vector<
     SEL selector = @selector(webCryptoMasterKeyForWebView:);
     if ([[m_webView UIDelegate] respondsToSelector:selector]) {
         NSData *keyData = CallUIDelegate(m_webView, selector);
-        masterKey.append((uint8_t*)[keyData bytes], [keyData length]);
+        masterKey.append(static_cast<uint8_t*>(const_cast<void*>([keyData bytes])), [keyData length]);
     } else if (!getDefaultWebCryptoMasterKey(masterKey))
         return false;
 
index b9dd49e..0b7e1f6 100644 (file)
@@ -129,17 +129,17 @@ extern "C" NSString *_NSPathForSystemFramework(NSString *framework);
 
 static void _applicationInfoForMIMEType(NSString *type, NSString **name, NSImage **image)
 {
-    NSURL *appURL = nil;
+    CFURLRef appURL = nullptr;
 
 #pragma clang diagnostic push
 #pragma clang diagnostic ignored "-Wdeprecated-declarations"
-    OSStatus error = LSCopyApplicationForMIMEType((CFStringRef)type, kLSRolesAll, (CFURLRef *)&appURL);
+    OSStatus error = LSCopyApplicationForMIMEType((CFStringRef)type, kLSRolesAll, &appURL);
 #pragma clang diagnostic pop
     if (error != noErr)
         return;
     
-    NSString *appPath = [appURL path];
-    CFRelease (appURL);
+    NSString *appPath = [(NSURL *)appURL path];
+    CFRelease(appURL);
     
     *image = [[NSWorkspace sharedWorkspace] iconForFile:appPath];  
     [*image setSize:NSMakeSize(16.f,16.f)];