Turn on static code analysis.
authorsfalken <sfalken@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 27 Jun 2007 22:01:04 +0000 (22:01 +0000)
committersfalken <sfalken@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 27 Jun 2007 22:01:04 +0000 (22:01 +0000)
        Reviewed by Oliver.

        Effects only folks that have Visual Studio Team Suite installed,
        or who have replaced their compiler with the version shipping in the
        Vista SDK.

        * CodeAnalysisConfig.h: Added.
        * WebKit.vcproj/WebKit.vcproj:
        * WebLocalizableStrings.cpp:
        (createWebKitBundle):

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

WebKit/win/ChangeLog
WebKit/win/CodeAnalysisConfig.h [new file with mode: 0644]
WebKit/win/WebKit.vcproj/WebKit.vcproj
WebKit/win/WebLocalizableStrings.cpp

index a3bf77b..b76278b 100644 (file)
@@ -1,3 +1,18 @@
+2007-06-27  Steve Falkenburg  <set EMAIL_ADDRESS environment variable>
+
+        Turn on static code analysis.
+
+        Reviewed by Oliver.
+        
+        Effects only folks that have Visual Studio Team Suite installed,
+        or who have replaced their compiler with the version shipping in the
+        Vista SDK.
+
+        * CodeAnalysisConfig.h: Added.
+        * WebKit.vcproj/WebKit.vcproj:
+        * WebLocalizableStrings.cpp:
+        (createWebKitBundle):
+
 2007-06-27  Steve Falkenburg  <sfalken@apple.com>
 
         Prefast: Remove variable redefinitions in inner scopes.
diff --git a/WebKit/win/CodeAnalysisConfig.h b/WebKit/win/CodeAnalysisConfig.h
new file mode 100644 (file)
index 0000000..ea91d7c
--- /dev/null
@@ -0,0 +1,36 @@
+/*
+ * Copyright (C) 2006, 2007 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.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``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 COMPUTER, INC. OR
+ * 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. 
+ */
+
+#ifndef CodeAnalysisConfig_H
+#define CodeAnalysisConfig_H
+
+// warning C6011: dereferencing NULL pointer <name>
+// warning C6031: return value ignored: <function> could return unexpected value
+// warning C6211: Leaking memory due to an exception. Consider using a local catch block to clean up memory.
+// warning C6255: _alloca indicates failure by raising a stack overflow exception. Consider using _alloca_s instead
+// warning C6387: <argument> may be <value>: this does not adhere to the specification for the function <function name>: Lines: x, y
+#pragma warning(disable: 6011 6031 6211 6255 6387)
+
+#endif
index 0ff956e..0ddcebb 100644 (file)
@@ -55,6 +55,8 @@
                                Detect64BitPortabilityProblems="true"
                                DebugInformationFormat="3"
                                DisableSpecificWarnings="4127"
+                               ForcedIncludeFiles="CodeAnalysisConfig.h"
+                               EnablePREfast="true"
                        />
                        <Tool
                                Name="VCManagedResourceCompilerTool"
                        <Tool
                                Name="VCPostBuildEventTool"
                                CommandLine="mkdir 2&gt;NUL &quot;$(WebKitOutputDir)\include\WebKit&quot;&#x0D;&#x0A;xcopy /y /d &quot;$(ProjectDir)\..\WebLocalizableStrings.h&quot; &quot;$(WebKitOutputDir)\include\WebKit&quot;&#x0D;&#x0A;xcopy /y /d &quot;$(ProjectDir)\..\WebKitGraphics.h&quot; &quot;$(WebKitOutputDir)\include\WebKit&quot;&#x0D;&#x0A;xcopy /y /d &quot;$(ProjectDir)\..\ProgIDMacros.h&quot; &quot;$(WebKitOutputDir)\include\WebKit&quot;&#x0D;&#x0A;&#x0D;&#x0A;xcopy /y /d &quot;$(WebKitOutputDir)\include\WebCore\npfunctions.h&quot; &quot;$(WebKitOutputDir)\include\WebKit&quot;&#x0D;&#x0A;xcopy /y /d &quot;$(WebKitOutputDir)\include\JavaScriptCore\npapi.h&quot; &quot;$(WebKitOutputDir)\include\WebKit&quot;&#x0D;&#x0A;xcopy /y /d &quot;$(WebKitOutputDir)\include\JavaScriptCore\npruntime.h&quot; &quot;$(WebKitOutputDir)\include\WebKit&quot;&#x0D;&#x0A;&#x0D;&#x0A;mkdir 2&gt;NUL &quot;$(OutDir)\WebKit.resources&quot;&#x0D;&#x0A;xcopy /y /d &quot;$(ProjectDir)..\$(ProjectName).resources\*&quot; &quot;$(OutDir)\$(ProjectName).resources&quot;&#x0D;&#x0A;mkdir 2&gt;NUL &quot;$(OutDir)\WebKit.resources\en.lproj&quot;&#x0D;&#x0A;xcopy /y /d &quot;$(ProjectDir)..\English.lproj\Localizable.strings&quot; &quot;$(OutDir)\WebKit.resources\en.lproj\&quot;&#x0D;&#x0A;"
-                />
+                       />
                </Configuration>
                <Configuration
                        Name="Release|Win32"
                                Detect64BitPortabilityProblems="true"
                                DebugInformationFormat="3"
                                DisableSpecificWarnings="4127"
+                               ForcedIncludeFiles="CodeAnalysisConfig.h"
+                               EnablePREfast="true"
                        />
                        <Tool
                                Name="VCManagedResourceCompilerTool"
                                Detect64BitPortabilityProblems="true"
                                DebugInformationFormat="3"
                                DisableSpecificWarnings="4127"
+                               ForcedIncludeFiles="CodeAnalysisConfig.h"
+                               EnablePREfast="true"
                        />
                        <Tool
                                Name="VCManagedResourceCompilerTool"
                                >
                        </File>
                        <File
+                               RelativePath="..\CodeAnalysisConfig.h"
+                               >
+                       </File>
+                       <File
                                RelativePath="..\DefaultDownloadDelegate.h"
                                >
                        </File>
index d2ab96a..c0a20f9 100644 (file)
@@ -49,12 +49,16 @@ static CFBundleRef createWebKitBundle()
 {
     WCHAR pathStr[MAX_PATH];
     DWORD length = ::GetModuleFileNameW(gInstance, pathStr, MAX_PATH);
-    if (!length || GetLastError() == ERROR_INSUFFICIENT_BUFFER)
+    if (!length || (length == MAX_PATH && GetLastError() == ERROR_INSUFFICIENT_BUFFER))
         return 0;
 
     bool found = false;
-    for (int i=length; i>0; i--) {
+    for (int i = length - 1; i >= 0; i--) {
+        // warning C6385: Invalid data: accessing 'pathStr', the readable size is '520' bytes, but '2000' bytes might be read
+        #pragma warning(suppress: 6385)
         if (pathStr[i] == L'\\') {
+            // warning C6386: Buffer overrun: accessing 'pathStr', the writable size is '520' bytes, but '1996' bytes might be written
+            #pragma warning(suppress: 6386)
             pathStr[i] = 0;
             found = true;
             break;
@@ -134,7 +138,7 @@ LPCTSTR WebLocalizedLPCTSTR(WebLocalizableStringsBundle* stringsBundle, LPCTSTR
     if (cfStr)
         CFRelease(cfStr);
     for (unsigned int i=1; i<str.length(); i++)
-        if (str[i] == '@' && str[i-1] == '%')
+        if (str[i] == '@' && str[i - 1] == '%')
             str.replace(i, 1, "s");
 
     LPCTSTR lpszStr = str.charactersWithNullTermination();