Diff
Modified: trunk/Tools/ChangeLog (174470 => 174471)
--- trunk/Tools/ChangeLog 2014-10-08 19:34:03 UTC (rev 174470)
+++ trunk/Tools/ChangeLog 2014-10-08 20:01:28 UTC (rev 174471)
@@ -1,3 +1,49 @@
+2014-10-08 Brent Fulgham <[email protected]>
+
+ [Win] Resolve various static analyzer warnings in Tools.
+ https://bugs.webkit.org/show_bug.cgi?id=137534
+
+ Reviewed by Dean Jackson.
+
+ * DumpRenderTree/cg/ImageDiffCG.cpp:
+ (main): User proper printf specifiers.
+ * DumpRenderTree/win/AccessibilityUIElementWin.cpp:
+ (AccessibilityUIElement::childrenCount): Handle possibility that
+ gcc_accChildCount returns with an error.
+ (accessibilityState): Ditto for gcc_accState.
+ * DumpRenderTree/win/DRTDesktopNotificationPresenter.cpp:
+ (DRTDesktopNotificationPresenter::showDesktopNotification): Use proper
+ check for return value from 'isHTML'. HRESULT is not a boolean and cannot
+ be treated as such.
+ * DumpRenderTree/win/DumpRenderTree.cpp:
+ (DumpRenderTreeWndProc): Avoid possible infinite loop on teardown caused
+ by comparing an unsigned value as being greater-than zero.
+ * DumpRenderTree/win/EditingDelegate.cpp:
+ (dump): Pass proper character pointer type to printf.
+ (EditingDelegate::shouldBeginEditingInDOMRange): Ditto.
+ (EditingDelegate::shouldEndEditingInDOMRange): Ditto.
+ (EditingDelegate::shouldInsertNode): Ditto.
+ (EditingDelegate::shouldInsertText): Ditto.
+ (EditingDelegate::shouldDeleteDOMRange): Ditto.
+ (EditingDelegate::shouldChangeSelectedDOMRange): Ditto.
+ (EditingDelegate::shouldApplyStyle): Ditto.
+ * DumpRenderTree/win/EventSender.cpp:
+ (beginDragWithFilesCallback): Handle possible error case for GlobalAlloc.
+ * DumpRenderTree/win/EventSender.h: Add proper declaration for HRESULT to match
+ system headers.
+ * DumpRenderTree/win/PixelDumpSupportWin.cpp: Handle possible failure
+ from CreateDIBSection.
+ * DumpRenderTree/win/UIDelegate.cpp: Ensure proper type is passed to printf.
+ * TestWebKitAPI/Tests/WTF/MediaTime.cpp: Get rid of workaround for NaN under
+ older versions of MSVC we no longer support.
+ * TestWebKitAPI/Tests/WebKit/win/WebViewDestruction.cpp: Use proper types and API
+ for 64-bit builds.
+ * TestWebKitAPI/TestsController.cpp: Use NeverDestroyed like a good citizen.
+ * TestWebKitAPI/TestsController.h: Ditto.
+ * WinLauncher/Common.cpp: Handle possible failure from GetModuleFileName.
+ * WinLauncher/WinLauncher.cpp: Make order of operations explicit to avoid
+ performing bitwise | before the comparison is done.
+
2014-10-08 Ada Chan <[email protected]>
Add a test for WKPageIsPlayingAudio().
Modified: trunk/Tools/DumpRenderTree/cg/ImageDiffCG.cpp (174470 => 174471)
--- trunk/Tools/DumpRenderTree/cg/ImageDiffCG.cpp 2014-10-08 19:34:03 UTC (rev 174470)
+++ trunk/Tools/DumpRenderTree/cg/ImageDiffCG.cpp 2014-10-08 20:01:28 UTC (rev 174471)
@@ -223,11 +223,15 @@
difference = max(difference, 0.01f); // round to 2 decimal places
}
} else {
- if (CGImageGetWidth(actualImage.get()) != CGImageGetWidth(baselineImage.get()) || CGImageGetHeight(actualImage.get()) != CGImageGetHeight(baselineImage.get()))
- fprintf(stderr, "Error: test and reference images have different sizes. Test image is %lux%lu, reference image is %lux%lu\n",
+ if (CGImageGetWidth(actualImage.get()) != CGImageGetWidth(baselineImage.get()) || CGImageGetHeight(actualImage.get()) != CGImageGetHeight(baselineImage.get())) {
+#if OS(WINDOWS)
+ fprintf(stderr, "Error: test and reference images have different sizes. Test image is %zux%zu, reference image is %Iux%Iu\n",
+#else
+ fprintf(stderr, "Error: test and reference images have different sizes. Test image is %zux%zu, reference image is %zux%zu\n",
+#endif
CGImageGetWidth(actualImage.get()), CGImageGetHeight(actualImage.get()),
CGImageGetWidth(baselineImage.get()), CGImageGetHeight(baselineImage.get()));
- else if (imageHasAlpha(actualImage.get()) != imageHasAlpha(baselineImage.get()))
+ } else if (imageHasAlpha(actualImage.get()) != imageHasAlpha(baselineImage.get()))
fprintf(stderr, "Error: test and reference images differ in alpha. Test image %s alpha, reference image %s alpha.\n",
imageHasAlpha(actualImage.get()) ? "has" : "does not have",
imageHasAlpha(baselineImage.get()) ? "has" : "does not have");
@@ -239,7 +243,11 @@
RetainPtr<CGImageDestinationRef> imageDest = adoptCF(CGImageDestinationCreateWithData(imageData.get(), kUTTypePNG, 1, 0));
CGImageDestinationAddImage(imageDest.get(), diffImage.get(), 0);
CGImageDestinationFinalize(imageDest.get());
- printf("Content-Length: %lu\n", CFDataGetLength(imageData.get()));
+#if OS(WINDOWS)
+ printf("Content-Length: %Iu\n", static_cast<size_t>(CFDataGetLength(imageData.get())));
+#else
+ printf("Content-Length: %zu\n", static_cast<size_t>(CFDataGetLength(imageData.get())));
+#endif
fwrite(CFDataGetBytePtr(imageData.get()), 1, CFDataGetLength(imageData.get()), stdout);
}
Modified: trunk/Tools/DumpRenderTree/win/AccessibilityUIElementWin.cpp (174470 => 174471)
--- trunk/Tools/DumpRenderTree/win/AccessibilityUIElementWin.cpp 2014-10-08 19:34:03 UTC (rev 174470)
+++ trunk/Tools/DumpRenderTree/win/AccessibilityUIElementWin.cpp 2014-10-08 20:01:28 UTC (rev 174471)
@@ -113,7 +113,9 @@
return 0;
long childCount;
- m_element->get_accChildCount(&childCount);
+ if (FAILED(m_element->get_accChildCount(&childCount)))
+ return 0;
+
return childCount;
}
@@ -398,7 +400,8 @@
static DWORD accessibilityState(COMPtr<IAccessible> element)
{
VARIANT state;
- element->get_accState(self(), &state);
+ if (FAILED(element->get_accState(self(), &state)))
+ return 0;
ASSERT(V_VT(&state) == VT_I4);
Modified: trunk/Tools/DumpRenderTree/win/DRTDesktopNotificationPresenter.cpp (174470 => 174471)
--- trunk/Tools/DumpRenderTree/win/DRTDesktopNotificationPresenter.cpp 2014-10-08 19:34:03 UTC (rev 174470)
+++ trunk/Tools/DumpRenderTree/win/DRTDesktopNotificationPresenter.cpp 2014-10-08 20:01:28 UTC (rev 174471)
@@ -75,7 +75,7 @@
_bstr_t title, text, url;
BOOL html;
- if (!notification->isHTML(&html) && html) {
+ if (SUCCEEDED(notification->isHTML(&html)) && html) {
notification->contentsURL(&url.GetBSTR());
printf("DESKTOP NOTIFICATION: contents at %S\n", static_cast<wchar_t*>(url));
} else {
Modified: trunk/Tools/DumpRenderTree/win/DumpRenderTree.cpp (174470 => 174471)
--- trunk/Tools/DumpRenderTree/win/DumpRenderTree.cpp 2014-10-08 19:34:03 UTC (rev 174470)
+++ trunk/Tools/DumpRenderTree/win/DumpRenderTree.cpp 2014-10-08 20:01:28 UTC (rev 174471)
@@ -241,7 +241,7 @@
{
switch (msg) {
case WM_DESTROY:
- for (unsigned i = openWindows().size() - 1; i >= 0; --i) {
+ for (long i = openWindows().size() - 1; i >= 0; --i) {
if (openWindows()[i] == hWnd) {
openWindows().remove(i);
windowToWebViewMap().remove(hWnd);
Modified: trunk/Tools/DumpRenderTree/win/EditingDelegate.cpp (174470 => 174471)
--- trunk/Tools/DumpRenderTree/win/EditingDelegate.cpp 2014-10-08 19:34:03 UTC (rev 174470)
+++ trunk/Tools/DumpRenderTree/win/EditingDelegate.cpp 2014-10-08 20:01:28 UTC (rev 174471)
@@ -114,7 +114,7 @@
return 0;
wchar_t buffer[1024];
- _snwprintf(buffer, ARRAYSIZE(buffer), L"range from %ld of %s to %ld of %s", startOffset, dumpPath(startContainer.get()), endOffset, dumpPath(endContainer.get()));
+ _snwprintf(buffer, ARRAYSIZE(buffer), L"range from %ld of %s to %ld of %s", startOffset, dumpPath(startContainer.get()).c_str(), endOffset, dumpPath(endContainer.get()).c_str());
return buffer;
}
@@ -126,7 +126,7 @@
}
if (::gTestRunner->dumpEditingCallbacks() && !done)
- _tprintf(TEXT("EDITING DELEGATE: shouldBeginEditingInDOMRange:%s\n"), dump(range));
+ _tprintf(TEXT("EDITING DELEGATE: shouldBeginEditingInDOMRange:%s\n"), dump(range).c_str());
*result = m_acceptsEditing;
return S_OK;
@@ -140,7 +140,7 @@
}
if (::gTestRunner->dumpEditingCallbacks() && !done)
- _tprintf(TEXT("EDITING DELEGATE: shouldEndEditingInDOMRange:%s\n"), dump(range));
+ _tprintf(TEXT("EDITING DELEGATE: shouldEndEditingInDOMRange:%s\n"), dump(range).c_str());
*result = m_acceptsEditing;
return S_OK;
@@ -155,7 +155,7 @@
};
if (::gTestRunner->dumpEditingCallbacks() && !done)
- _tprintf(TEXT("EDITING DELEGATE: shouldInsertNode:%s replacingDOMRange:%s givenAction:%s\n"), dumpPath(node), dump(range), insertactionstring[action]);
+ _tprintf(TEXT("EDITING DELEGATE: shouldInsertNode:%s replacingDOMRange:%s givenAction:%s\n"), dumpPath(node).c_str(), dump(range).c_str(), insertactionstring[action]);
return S_OK;
}
@@ -174,7 +174,7 @@
};
if (::gTestRunner->dumpEditingCallbacks() && !done)
- _tprintf(TEXT("EDITING DELEGATE: shouldInsertText:%s replacingDOMRange:%s givenAction:%s\n"), text ? text : TEXT(""), dump(range), insertactionstring[action]);
+ _tprintf(TEXT("EDITING DELEGATE: shouldInsertText:%s replacingDOMRange:%s givenAction:%s\n"), text ? text : TEXT(""), dump(range).c_str(), insertactionstring[action]);
*result = m_acceptsEditing;
return S_OK;
@@ -188,7 +188,7 @@
}
if (::gTestRunner->dumpEditingCallbacks() && !done)
- _tprintf(TEXT("EDITING DELEGATE: shouldDeleteDOMRange:%s\n"), dump(range));
+ _tprintf(TEXT("EDITING DELEGATE: shouldDeleteDOMRange:%s\n"), dump(range).c_str());
*result = m_acceptsEditing;
return S_OK;
@@ -212,7 +212,7 @@
};
if (::gTestRunner->dumpEditingCallbacks() && !done)
- _tprintf(TEXT("EDITING DELEGATE: shouldChangeSelectedDOMRange:%s toDOMRange:%s affinity:%s stillSelecting:%s\n"), dump(currentRange), dump(proposedRange), affinitystring[selectionAffinity], boolstring[stillSelecting]);
+ _tprintf(TEXT("EDITING DELEGATE: shouldChangeSelectedDOMRange:%s toDOMRange:%s affinity:%s stillSelecting:%s\n"), dump(currentRange).c_str(), dump(proposedRange).c_str(), affinitystring[selectionAffinity], boolstring[stillSelecting]);
*result = m_acceptsEditing;
return S_OK;
@@ -226,7 +226,7 @@
}
if (::gTestRunner->dumpEditingCallbacks() && !done)
- _tprintf(TEXT("EDITING DELEGATE: shouldApplyStyle:%s toElementsInDOMRange:%s\n"), TEXT("'style description'")/*[[style description] UTF8String]*/, dump(range));
+ _tprintf(TEXT("EDITING DELEGATE: shouldApplyStyle:%s toElementsInDOMRange:%s\n"), TEXT("'style description'")/*[[style description] UTF8String]*/, dump(range).c_str());
*result = m_acceptsEditing;
return S_OK;
Modified: trunk/Tools/DumpRenderTree/win/EventSender.cpp (174470 => 174471)
--- trunk/Tools/DumpRenderTree/win/EventSender.cpp 2014-10-08 19:34:03 UTC (rev 174470)
+++ trunk/Tools/DumpRenderTree/win/EventSender.cpp 2014-10-08 20:01:28 UTC (rev 174471)
@@ -696,6 +696,9 @@
hDropMedium.tymed = TYMED_HGLOBAL;
SIZE_T dropFilesSize = sizeof(DROPFILES) + (sizeof(WCHAR) * files.size());
hDropMedium.hGlobal = GlobalAlloc(GMEM_MOVEABLE | GMEM_DDESHARE, dropFilesSize);
+ if (!hDropMedium.hGlobal)
+ return JSValueMakeUndefined(context);
+
DROPFILES* dropFiles = reinterpret_cast<DROPFILES*>(GlobalLock(hDropMedium.hGlobal));
memset(dropFiles, 0, sizeof(DROPFILES));
dropFiles->pFiles = sizeof(DROPFILES);
@@ -710,6 +713,9 @@
hFileNameMedium.tymed = TYMED_HGLOBAL;
SIZE_T hFileNameSize = sizeof(WCHAR) * files.size();
hFileNameMedium.hGlobal = GlobalAlloc(GMEM_MOVEABLE | GMEM_DDESHARE, hFileNameSize);
+ if (!hFileNameMedium.hGlobal)
+ return JSValueMakeUndefined(context);
+
WCHAR* hFileName = static_cast<WCHAR*>(GlobalLock(hFileNameMedium.hGlobal));
for (size_t i = 0; i < files.size(); i++)
hFileName[i] = files[i];
Modified: trunk/Tools/DumpRenderTree/win/EventSender.h (174470 => 174471)
--- trunk/Tools/DumpRenderTree/win/EventSender.h 2014-10-08 19:34:03 UTC (rev 174470)
+++ trunk/Tools/DumpRenderTree/win/EventSender.h 2014-10-08 20:01:28 UTC (rev 174471)
@@ -31,7 +31,13 @@
class DraggingInfo;
-typedef long HRESULT;
+#ifdef __midl
+typedef LONG HRESULT;
+#else
+#include <sal.h>
+typedef _Return_type_success_(return >= 0) long HRESULT;
+#endif // __midl
+
typedef const struct OpaqueJSContext* JSContextRef;
typedef struct OpaqueJSValue* JSObjectRef;
Modified: trunk/Tools/DumpRenderTree/win/PixelDumpSupportWin.cpp (174470 => 174471)
--- trunk/Tools/DumpRenderTree/win/PixelDumpSupportWin.cpp 2014-10-08 19:34:03 UTC (rev 174470)
+++ trunk/Tools/DumpRenderTree/win/PixelDumpSupportWin.cpp 2014-10-08 20:01:28 UTC (rev 174471)
@@ -58,7 +58,7 @@
{
RECT frame;
if (!GetWindowRect(webViewWindow, &frame))
- return 0;
+ return nullptr;
BITMAPINFO bmp = {0};
bmp.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
@@ -69,7 +69,9 @@
bmp.bmiHeader.biCompression = BI_RGB;
void* bits = 0;
- HBITMAP bitmap = CreateDIBSection(0, &bmp, DIB_RGB_COLORS, &bits, 0, 0);
+ HBITMAP bitmap = ::CreateDIBSection(0, &bmp, DIB_RGB_COLORS, &bits, 0, 0);
+ if (!bitmap)
+ return nullptr;
auto memoryDC = adoptGDIObject(::CreateCompatibleDC(0));
::SelectObject(memoryDC.get(), bitmap);
Modified: trunk/Tools/DumpRenderTree/win/UIDelegate.cpp (174470 => 174471)
--- trunk/Tools/DumpRenderTree/win/UIDelegate.cpp 2014-10-08 19:34:03 UTC (rev 174470)
+++ trunk/Tools/DumpRenderTree/win/UIDelegate.cpp 2014-10-08 20:01:28 UTC (rev 174471)
@@ -487,7 +487,7 @@
origin->port(&port);
if (!done && gTestRunner->dumpDatabaseCallbacks())
- printf("UI DELEGATE DATABASE CALLBACK: exceededDatabaseQuotaForSecurityOrigin:{%S, %S, %i} database:%S\n", protocol, host, port, databaseIdentifier);
+ printf("UI DELEGATE DATABASE CALLBACK: exceededDatabaseQuotaForSecurityOrigin:{%s, %s, %i} database:%S\n", static_cast<const char*>(protocol), static_cast<const char*>(host), port, databaseIdentifier);
unsigned long long defaultQuota = 5 * 1024 * 1024;
double testDefaultQuota = gTestRunner->databaseDefaultQuota();
Modified: trunk/Tools/TestWebKitAPI/Tests/WTF/MediaTime.cpp (174470 => 174471)
--- trunk/Tools/TestWebKitAPI/Tests/WTF/MediaTime.cpp 2014-10-08 19:34:03 UTC (rev 174470)
+++ trunk/Tools/TestWebKitAPI/Tests/WTF/MediaTime.cpp 2014-10-08 20:01:28 UTC (rev 174471)
@@ -33,17 +33,6 @@
using namespace std;
-#if COMPILER(MSVC)
-// Work around Visual Studio 2008's lack of an INFINITY or NAN definition.
-#include <limits>
-#if !defined(INFINITY)
-#define INFINITY (numeric_limits<double>::infinity())
-#endif
-#if !defined(NAN)
-#define NAN (numeric_limits<double>::quiet_NaN())
-#endif
-#endif
-
namespace WTF {
std::ostream& operator<<(std::ostream& out, const MediaTime& val)
Modified: trunk/Tools/TestWebKitAPI/Tests/WebKit/win/WebViewDestruction.cpp (174470 => 174471)
--- trunk/Tools/TestWebKitAPI/Tests/WebKit/win/WebViewDestruction.cpp 2014-10-08 19:34:03 UTC (rev 174470)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKit/win/WebViewDestruction.cpp 2014-10-08 20:01:28 UTC (rev 174471)
@@ -89,14 +89,28 @@
EXPECT_TRUE(::IsWindow(m_viewWindow));
}
+#if defined(_M_X64) || defined(__x86_64__)
+typedef ULONGLONG __tick_count;
+static ULONGLONG currentTickCount()
+{
+ return ::GetTickCount64();
+}
+#else
+typedef DWORD __tick_count;
+static DWORD currentTickCount()
+{
+ return ::GetTickCount();
+}
+#endif
+
void WebViewDestruction::runMessagePump(DWORD timeoutMilliseconds)
{
// FIXME: We should move this functionality to PlatformUtilities at some point.
- DWORD startTickCount = ::GetTickCount();
+ __tick_count startTickCount = currentTickCount();
MSG msg;
BOOL result;
- while ((result = ::PeekMessageW(&msg, 0, 0, 0, PM_REMOVE)) && ::GetTickCount() - startTickCount <= timeoutMilliseconds) {
+ while ((result = ::PeekMessageW(&msg, 0, 0, 0, PM_REMOVE)) && currentTickCount() - startTickCount <= static_cast<__tick_count>(timeoutMilliseconds)) {
if (result == -1)
break;
::TranslateMessage(&msg);
Modified: trunk/Tools/TestWebKitAPI/TestsController.cpp (174470 => 174471)
--- trunk/Tools/TestWebKitAPI/TestsController.cpp 2014-10-08 19:34:03 UTC (rev 174470)
+++ trunk/Tools/TestWebKitAPI/TestsController.cpp 2014-10-08 20:01:28 UTC (rev 174471)
@@ -32,7 +32,7 @@
TestsController& TestsController::shared()
{
- static TestsController& shared = *new TestsController;
+ static NeverDestroyed<TestsController> shared;
return shared;
}
Modified: trunk/Tools/TestWebKitAPI/TestsController.h (174470 => 174471)
--- trunk/Tools/TestWebKitAPI/TestsController.h 2014-10-08 19:34:03 UTC (rev 174470)
+++ trunk/Tools/TestWebKitAPI/TestsController.h 2014-10-08 20:01:28 UTC (rev 174471)
@@ -26,6 +26,8 @@
#ifndef TestsController_h
#define TestsController_h
+#include <wtf/NeverDestroyed.h>
+
namespace TestWebKitAPI {
class TestsController {
@@ -37,6 +39,8 @@
private:
TestsController();
~TestsController();
+
+ friend class WTF::NeverDestroyed<TestsController>;
};
} // namespace TestWebKitAPI
Modified: trunk/Tools/WinLauncher/Common.cpp (174470 => 174471)
--- trunk/Tools/WinLauncher/Common.cpp 2014-10-08 19:34:03 UTC (rev 174470)
+++ trunk/Tools/WinLauncher/Common.cpp 2014-10-08 20:01:28 UTC (rev 174471)
@@ -150,7 +150,9 @@
return false;
wchar_t executablePath[MAX_PATH];
- ::GetModuleFileNameW(0, executablePath, MAX_PATH);
+ if (!::GetModuleFileNameW(0, executablePath, MAX_PATH))
+ return false;
+
::PathRemoveExtensionW(executablePath);
directory = _bstr_t(appDataDirectory) + L"\\" + ::PathFindFileNameW(executablePath);
Modified: trunk/Tools/WinLauncher/WinLauncher.cpp (174470 => 174471)
--- trunk/Tools/WinLauncher/WinLauncher.cpp 2014-10-08 19:34:03 UTC (rev 174470)
+++ trunk/Tools/WinLauncher/WinLauncher.cpp 2014-10-08 20:01:28 UTC (rev 174471)
@@ -215,7 +215,7 @@
if (FAILED(hr))
return;
- UINT backSetting = MF_BYCOMMAND | (backCount) ? MF_ENABLED : MF_DISABLED;
+ UINT backSetting = MF_BYCOMMAND | ((backCount) ? MF_ENABLED : MF_DISABLED);
::EnableMenuItem(menu, IDM_HISTORY_BACKWARD, backSetting);
int forwardCount = 0;
@@ -223,7 +223,7 @@
if (FAILED(hr))
return;
- UINT forwardSetting = MF_BYCOMMAND | (forwardCount) ? MF_ENABLED : MF_DISABLED;
+ UINT forwardSetting = MF_BYCOMMAND | ((forwardCount) ? MF_ENABLED : MF_DISABLED);
::EnableMenuItem(menu, IDM_HISTORY_FORWARD, forwardSetting);
IWebHistoryItemPtr currentItem;