Fix -Wcast-qual and -Wunused-lambda-capture warnings in WebCore with new clang compiler
authorddkilzer@apple.com <ddkilzer@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 24 Aug 2017 18:35:39 +0000 (18:35 +0000)
committerddkilzer@apple.com <ddkilzer@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 24 Aug 2017 18:35:39 +0000 (18:35 +0000)
<https://webkit.org/b/175910>
<rdar://problem/33667497>

Reviewed by Alex Christensen.

Fix -Wunused-lambda-capture warnings:

* Modules/fetch/FetchResponse.cpp:
(WebCore::FetchResponse::setBodyData): Remove unused lambda
capture of 'this'.
* style/RenderTreeUpdater.cpp:
(WebCore::RenderTreeUpdater::createRenderer): Add
UNUSED_PARAM(style) when ENABLE(CSS_REGIONS) is turned off.

Fix -Wcast-qual warnings:

* crypto/mac/CryptoKeyRSAMac.cpp:
(WebCore::CryptoKeyRSA::create): Switch from C-style cast to
reinterpret_cast with const keyword.  This better matches the
argument types used in CCRSACryptorCreateFromData().
* platform/audio/mac/FFTFrameMac.cpp:
(WebCore::FFTFrame::doFFT): Switch from C-style cast to
reinterpret_cast with const keyword.  This better matches the
argument type used in vDSP_ctoz().
* platform/graphics/FontPlatformData.h: Only define
WebCore::toCTFont() and WebCore::toNSFont() when building for
Objective-C++.
* platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm:
(WebCore::MediaPlayerPrivateAVFoundationObjC::shouldWaitForLoadingOfResource):
Switch from C-style cast to reinterpret_cast with const keyword.
This better matches the argument type used in
Uint8Array::setRange().
* platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.mm:
(WebCore::CMTimebaseEffectiveRateChangedCallback): Use
const_cast to avoid warning.
* platform/mac/SSLKeyGeneratorMac.mm:
(WebCore::signedPublicKeyAndChallengeString): Use const_cast to
avoid warning, and switch C-style cast to reinterpret_cast.
* xml/XSLTProcessorLibxslt.cpp:
(WebCore::XSLTProcessor::transformToString):
- Use const_cast to avoid warning, and switch C-style cast to
  reinterpret_cast.
- Switch C-style cast to reinterpret_cast and add const keyword.
* xml/parser/XMLDocumentParserLibxml2.cpp:
(WebCore::XMLParserContext::createMemoryParser): Use const_cast
to avoid warning, and switch C-style cast to reinterpret_cast.

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

Source/WebCore/ChangeLog
Source/WebCore/Modules/fetch/FetchResponse.cpp
Source/WebCore/crypto/mac/CryptoKeyRSAMac.cpp
Source/WebCore/platform/audio/mac/FFTFrameMac.cpp
Source/WebCore/platform/graphics/FontPlatformData.h
Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm
Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.mm
Source/WebCore/platform/mac/SSLKeyGeneratorMac.mm
Source/WebCore/style/RenderTreeUpdater.cpp
Source/WebCore/xml/XSLTProcessorLibxslt.cpp
Source/WebCore/xml/parser/XMLDocumentParserLibxml2.cpp

index 7b1cc21..5caf3f1 100644 (file)
@@ -1,3 +1,53 @@
+2017-08-24  David Kilzer  <ddkilzer@apple.com>
+
+        Fix -Wcast-qual and -Wunused-lambda-capture warnings in WebCore with new clang compiler
+        <https://webkit.org/b/175910>
+        <rdar://problem/33667497>
+
+        Reviewed by Alex Christensen.
+
+        Fix -Wunused-lambda-capture warnings:
+
+        * Modules/fetch/FetchResponse.cpp:
+        (WebCore::FetchResponse::setBodyData): Remove unused lambda
+        capture of 'this'.
+        * style/RenderTreeUpdater.cpp:
+        (WebCore::RenderTreeUpdater::createRenderer): Add
+        UNUSED_PARAM(style) when ENABLE(CSS_REGIONS) is turned off.
+
+        Fix -Wcast-qual warnings:
+
+        * crypto/mac/CryptoKeyRSAMac.cpp:
+        (WebCore::CryptoKeyRSA::create): Switch from C-style cast to
+        reinterpret_cast with const keyword.  This better matches the
+        argument types used in CCRSACryptorCreateFromData().
+        * platform/audio/mac/FFTFrameMac.cpp:
+        (WebCore::FFTFrame::doFFT): Switch from C-style cast to
+        reinterpret_cast with const keyword.  This better matches the
+        argument type used in vDSP_ctoz().
+        * platform/graphics/FontPlatformData.h: Only define
+        WebCore::toCTFont() and WebCore::toNSFont() when building for
+        Objective-C++.
+        * platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm:
+        (WebCore::MediaPlayerPrivateAVFoundationObjC::shouldWaitForLoadingOfResource):
+        Switch from C-style cast to reinterpret_cast with const keyword.
+        This better matches the argument type used in
+        Uint8Array::setRange().
+        * platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.mm:
+        (WebCore::CMTimebaseEffectiveRateChangedCallback): Use
+        const_cast to avoid warning.
+        * platform/mac/SSLKeyGeneratorMac.mm:
+        (WebCore::signedPublicKeyAndChallengeString): Use const_cast to
+        avoid warning, and switch C-style cast to reinterpret_cast.
+        * xml/XSLTProcessorLibxslt.cpp:
+        (WebCore::XSLTProcessor::transformToString):
+        - Use const_cast to avoid warning, and switch C-style cast to
+          reinterpret_cast.
+        - Switch C-style cast to reinterpret_cast and add const keyword.
+        * xml/parser/XMLDocumentParserLibxml2.cpp:
+        (WebCore::XMLParserContext::createMemoryParser): Use const_cast
+        to avoid warning, and switch C-style cast to reinterpret_cast.
+
 2017-08-22  Dave Hyatt  <hyatt@apple.com>
 
         [Repaint Outside Layout] Add a pref for repainting outside of layout
index ad6d82d..599f1d3 100644 (file)
@@ -297,7 +297,7 @@ void FetchResponse::setBodyData(ResponseData&& data)
         if (isBodyNull())
             setBody(FetchBody::loadingBody());
         body().consumer().setData(WTFMove(buffer));
-    }, [this](std::nullptr_t&) { });
+    }, [](std::nullptr_t&) { });
 }
 
 #if ENABLE(STREAMS_API)
index 821fc93..98344eb 100644 (file)
@@ -136,10 +136,10 @@ RefPtr<CryptoKeyRSA> CryptoKeyRSA::create(CryptoAlgorithmIdentifier identifier,
     // See <rdar://problem/15452324>.
     CCCryptorStatus status = CCRSACryptorCreateFromData(
         keyData.type() == CryptoKeyRSAComponents::Type::Public ? ccRSAKeyPublic : ccRSAKeyPrivate,
-        (uint8_t*)keyData.modulus().data(), keyData.modulus().size(),
-        (uint8_t*)keyData.exponent().data(), keyData.exponent().size(),
-        (uint8_t*)keyData.firstPrimeInfo().primeFactor.data(), keyData.firstPrimeInfo().primeFactor.size(),
-        (uint8_t*)keyData.secondPrimeInfo().primeFactor.data(), keyData.secondPrimeInfo().primeFactor.size(),
+        reinterpret_cast<const uint8_t*>(keyData.modulus().data()), keyData.modulus().size(),
+        reinterpret_cast<const uint8_t*>(keyData.exponent().data()), keyData.exponent().size(),
+        reinterpret_cast<const uint8_t*>(keyData.firstPrimeInfo().primeFactor.data()), keyData.firstPrimeInfo().primeFactor.size(),
+        reinterpret_cast<const uint8_t*>(keyData.secondPrimeInfo().primeFactor.data()), keyData.secondPrimeInfo().primeFactor.size(),
         &cryptor);
 
     if (status) {
index 3641ff0..6015aa5 100644 (file)
@@ -129,7 +129,7 @@ void FFTFrame::multiply(const FFTFrame& frame)
 
 void FFTFrame::doFFT(const float* data)
 {
-    vDSP_ctoz((DSPComplex*)data, 2, &m_frame, 1, m_FFTSize / 2);
+    vDSP_ctoz(reinterpret_cast<const DSPComplex*>(data), 2, &m_frame, 1, m_FFTSize / 2);
     vDSP_fft_zrip(m_FFTSetup, &m_frame, 1, m_log2FFTSize, FFT_FORWARD);
 }
 
index 45db147..a718e54 100644 (file)
@@ -275,7 +275,7 @@ private:
 #endif
 };
 
-#if USE(APPKIT)
+#if USE(APPKIT) && defined(__OBJC__)
 
 // NSFonts and CTFontRefs are toll-free-bridged.
 inline CTFontRef toCTFont(NSFont *font)
index acb1fa3..551c6f1 100644 (file)
@@ -1843,7 +1843,7 @@ bool MediaPlayerPrivateAVFoundationObjC::shouldWaitForLoadingOfResource(AVAssetR
         CString utf8EncodedKeyId = UTF8Encoding().encode(keyIDView, URLEncodedEntitiesForUnencodables);
 
         RefPtr<Uint8Array> initData = Uint8Array::create(utf8EncodedKeyId.length());
-        initData->setRange((JSC::Uint8Adaptor::Type*)utf8EncodedKeyId.data(), utf8EncodedKeyId.length(), 0);
+        initData->setRange(reinterpret_cast<const JSC::Uint8Adaptor::Type*>(utf8EncodedKeyId.data()), utf8EncodedKeyId.length(), 0);
 
         auto keyData = player()->cachedKeyForKeyId(keyID);
         if (keyData) {
index 1047934..c44f680 100644 (file)
@@ -115,7 +115,7 @@ namespace WebCore {
 
 static void CMTimebaseEffectiveRateChangedCallback(CMNotificationCenterRef, const void *listener, CFStringRef, const void *, CFTypeRef)
 {
-    MediaPlayerPrivateMediaSourceAVFObjC* player = (MediaPlayerPrivateMediaSourceAVFObjC*)listener;
+    MediaPlayerPrivateMediaSourceAVFObjC* player = (MediaPlayerPrivateMediaSourceAVFObjC*)const_cast<void*>(listener);
     callOnMainThread([weakThis = player->createWeakPtr()] {
         if (!weakThis)
             return;
index f4d3130..a82c56b 100644 (file)
@@ -184,7 +184,7 @@ static String signedPublicKeyAndChallengeString(unsigned keySize, const CString&
 
     // Length needs to account for the null terminator.
     signedPublicKeyAndChallenge.publicKeyAndChallenge.challenge.Length = challenge.length() + 1;
-    signedPublicKeyAndChallenge.publicKeyAndChallenge.challenge.Data = (uint8_t*)challenge.data();
+    signedPublicKeyAndChallenge.publicKeyAndChallenge.challenge.Data = reinterpret_cast<uint8_t*>(const_cast<char*>(challenge.data()));
 
     CSSM_DATA encodedPublicKeyAndChallenge { 0, nullptr };
     if (SecAsn1EncodeItem(coder, &signedPublicKeyAndChallenge.publicKeyAndChallenge, publicKeyAndChallengeTemplate, &encodedPublicKeyAndChallenge) != noErr)
index 3aa989e..878ba0a 100644 (file)
@@ -358,6 +358,8 @@ void RenderTreeUpdater::createRenderer(Element& element, RenderStyle&& style)
 #if ENABLE(CSS_REGIONS)
         if (element.shouldMoveToFlowThread(style))
             return RenderTreePosition::insertionPositionForFlowThread(renderTreePosition().parent().element(), element, style);
+#else
+        UNUSED_PARAM(style);
 #endif
         renderTreePosition().computeNextSibling(element);
         return renderTreePosition();
index 59dfe20..8247d20 100644 (file)
@@ -317,7 +317,7 @@ bool XSLTProcessor::transformToString(Node& sourceNode, String& mimeType, String
 
     xmlChar* origMethod = sheet->method;
     if (!origMethod && mimeType == "text/html")
-        sheet->method = (xmlChar*)"html";
+        sheet->method = reinterpret_cast<xmlChar*>(const_cast<char*>("html"));
 
     bool success = false;
     bool shouldFreeSourceDoc = false;
@@ -361,7 +361,7 @@ bool XSLTProcessor::transformToString(Node& sourceNode, String& mimeType, String
 
         if ((success = saveResultToString(resultDoc, sheet, resultString))) {
             mimeType = resultMIMEType(resultDoc, sheet);
-            resultEncoding = (char*)resultDoc->encoding;
+            resultEncoding = reinterpret_cast<const char*>(resultDoc->encoding);
         }
         xmlFreeDoc(resultDoc);
     }
index dd73c0c..4b1b3ac 100644 (file)
@@ -548,8 +548,8 @@ RefPtr<XMLParserContext> XMLParserContext::createMemoryParser(xmlSAXHandlerPtr h
     parser->sax2 = 1;
     parser->instate = XML_PARSER_CONTENT; // We are parsing a CONTENT
     parser->depth = 0;
-    parser->str_xml = xmlDictLookup(parser->dict, BAD_CAST "xml", 3);
-    parser->str_xmlns = xmlDictLookup(parser->dict, BAD_CAST "xmlns", 5);
+    parser->str_xml = xmlDictLookup(parser->dict, reinterpret_cast<xmlChar*>(const_cast<char*>("xml")), 3);
+    parser->str_xmlns = xmlDictLookup(parser->dict, reinterpret_cast<xmlChar*>(const_cast<char*>("xmlns")), 5);
     parser->str_xml_ns = xmlDictLookup(parser->dict, XML_XML_NAMESPACE, 36);
     parser->_private = userData;