Bug 605179 - Fix build warnings in gfx/; r=roc a=bsmedberg
authorMs2ger <ms2ger@gmail.com>
Sun, 05 Dec 2010 18:38:12 +0000
changeset 58638 0ec22e77aefc7a690cf6a96f466f9d0056fc2f39
parent 58637 bfec67c46b7cb58ad3149016076ccecd261e01f7
child 58639 50985e5fa3e383b7e6ae5389f22f07aee1c58e9e
push id17392
push userjwatt@jwatt.org
push dateSun, 05 Dec 2010 20:44:41 +0000
treeherdermozilla-central@f6dbfac1ab22 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersroc, bsmedberg
bugs605179
milestone2.0b8pre
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 605179 - Fix build warnings in gfx/; r=roc a=bsmedberg
gfx/layers/opengl/LayerManagerOGL.cpp
gfx/qcms/iccread.c
gfx/qcms/qcms.h
gfx/qcms/qcmsint.h
gfx/qcms/qcmstypes.h
gfx/qcms/transform.c
gfx/src/thebes/nsThebesDeviceContext.cpp
gfx/thebes/GLContextProviderGLX.cpp
gfx/thebes/gfxASurface.cpp
gfx/thebes/gfxBlur.cpp
gfx/thebes/gfxFont.cpp
gfx/thebes/gfxFontUtils.cpp
gfx/thebes/gfxHarfBuzzShaper.cpp
gfx/thebes/gfxXlibNativeRenderer.cpp
--- a/gfx/layers/opengl/LayerManagerOGL.cpp
+++ b/gfx/layers/opengl/LayerManagerOGL.cpp
@@ -207,17 +207,19 @@ LayerManagerOGL::Initialize(GLContext *a
       return PR_FALSE;                                                            \
     }                                                                             \
     mPrograms.AppendElement(p);                                                   \
   } while (0)
 
 
   // NOTE: Order matters here, and should be in the same order as the
   // ProgramType enum!
+#ifdef DEBUG
   GLint programIndex = 0;
+#endif
 
   /* Layer programs */
   SHADER_PROGRAM(RGBALayerProgramType, ColorTextureLayerProgram,
                  sLayerVS, sRGBATextureLayerFS);
   SHADER_PROGRAM(BGRALayerProgramType, ColorTextureLayerProgram,
                  sLayerVS, sBGRATextureLayerFS);
   SHADER_PROGRAM(RGBXLayerProgramType, ColorTextureLayerProgram,
                  sLayerVS, sRGBXTextureLayerFS);
--- a/gfx/qcms/iccread.c
+++ b/gfx/qcms/iccread.c
@@ -1,8 +1,9 @@
+/*
 //  qcms
 //  Copyright (C) 2009 Mozilla Foundation
 //  Copyright (C) 1998-2007 Marti Maria
 //
 // Permission is hereby granted, free of charge, to any person obtaining 
 // a copy of this software and associated documentation files (the "Software"), 
 // to deal in the Software without restriction, including without limitation 
 // the rights to use, copy, modify, merge, publish, distribute, sublicense, 
@@ -14,16 +15,17 @@
 //
 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 
 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO 
 // THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 
 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 
 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 
 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 
 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+*/
 
 #include <math.h>
 #include <assert.h>
 #include <stdlib.h>
 #include <string.h>
 #include "qcmsint.h"
 
 typedef uint32_t be32;
--- a/gfx/qcms/qcms.h
+++ b/gfx/qcms/qcms.h
@@ -89,17 +89,17 @@ typedef struct _qcms_profile qcms_profil
 typedef enum {
 	QCMS_INTENT_DEFAULT = 0,
 	QCMS_INTENT_PERCEPTUAL = 0,
 	QCMS_INTENT_RELATIVE_COLORIMETRIC = 1,
 	QCMS_INTENT_SATURATION = 2,
 	QCMS_INTENT_ABSOLUTE_COLORIMETRIC = 3
 } qcms_intent;
 
-//XXX: I don't really like the _DATA_ prefix
+/* XXX: I don't really like the _DATA_ prefix */
 typedef enum {
 	QCMS_DATA_RGB_8,
 	QCMS_DATA_RGBA_8,
 	QCMS_DATA_GRAY_8,
 	QCMS_DATA_GRAYA_8
 } qcms_data_type;
 
 /* the names for the following two types are sort of ugly */
--- a/gfx/qcms/qcmsint.h
+++ b/gfx/qcms/qcmsint.h
@@ -108,17 +108,17 @@ struct tag_value {
 			uint32_t reserved;
 			struct {
 				s15Fixed16Number X;
 				s15Fixed16Number Y;
 				s15Fixed16Number Z;
 			} XYZNumber;
 		} XYZType;
 	};
-}; // I guess we need to pack this?
+}; /* I guess we need to pack this? */
 #endif
 
 #define RGB_SIGNATURE  0x52474220
 #define GRAY_SIGNATURE 0x47524159
 
 struct _qcms_profile {
 	uint32_t class;
 	uint32_t color_space;
--- a/gfx/qcms/qcmstypes.h
+++ b/gfx/qcms/qcmstypes.h
@@ -25,17 +25,17 @@ typedef PRUint64 uint64_t;
 #ifdef __OS2__
 /* OS/2's stdlib typdefs uintptr_t. So we'll just include that so we don't collide */
 #include <stdlib.h>
 #elif !defined(__intptr_t_defined) && !defined(_UINTPTR_T_DEFINED)
 typedef PRUptrdiff uintptr_t;
 #endif
 #endif
 
-#else // MOZ_QCMS
+#else /* MOZ_QCMS */
 
 #if BYTE_ORDER == LITTLE_ENDIAN
 #define IS_LITTLE_ENDIAN
 #elif BYTE_ORDER == BIG_ENDIAN
 #define IS_BIG_ENDIAN
 #endif
 
 /* all of the platforms that we use _MSC_VER on are little endian
--- a/gfx/qcms/transform.c
+++ b/gfx/qcms/transform.c
@@ -1,8 +1,9 @@
+/*
 //  qcms
 //  Copyright (C) 2009 Mozilla Corporation
 //  Copyright (C) 1998-2007 Marti Maria
 //
 // Permission is hereby granted, free of charge, to any person obtaining 
 // a copy of this software and associated documentation files (the "Software"), 
 // to deal in the Software without restriction, including without limitation 
 // the rights to use, copy, modify, merge, publish, distribute, sublicense, 
@@ -14,16 +15,17 @@
 //
 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 
 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO 
 // THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 
 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 
 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 
 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 
 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+*/
 
 #include <stdlib.h>
 #include <math.h>
 #include <assert.h>
 #include "qcmsint.h"
 
 /* for MSVC, GCC, Intel, and Sun compilers */
 #if defined(_M_IX86) || defined(__i386__) || defined(__i386) || defined(_M_AMD64) || defined(__x86_64__) || defined(__x86_64)
--- a/gfx/src/thebes/nsThebesDeviceContext.cpp
+++ b/gfx/src/thebes/nsThebesDeviceContext.cpp
@@ -1098,17 +1098,17 @@ nsThebesDeviceContext::FindScreen(nsIScr
 void
 nsThebesDeviceContext::CalcPrintingSize()
 {
     if (!mPrintingSurface)
         return;
 
     PRBool inPoints = PR_TRUE;
 
-    gfxSize size;
+    gfxSize size(0, 0);
     switch (mPrintingSurface->GetType()) {
     case gfxASurface::SurfaceTypeImage:
         inPoints = PR_FALSE;
         size = reinterpret_cast<gfxImageSurface*>(mPrintingSurface.get())->GetSize();
         break;
 
 #if defined(MOZ_PDF_PRINTING)
     case gfxASurface::SurfaceTypePDF:
--- a/gfx/thebes/GLContextProviderGLX.cpp
+++ b/gfx/thebes/GLContextProviderGLX.cpp
@@ -1,10 +1,10 @@
-/* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 4 -*-
- * ***** BEGIN LICENSE BLOCK *****
+/* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/* ***** BEGIN LICENSE BLOCK *****
  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
  *
  * The contents of this file are subject to the Mozilla Public License Version
  * 1.1 (the "License"); you may not use this file except in compliance with
  * the License. You may obtain a copy of the License at
  * http://www.mozilla.org/MPL/
  *
  * Software distributed under the License is distributed on an "AS IS" basis,
@@ -631,17 +631,17 @@ CreateOffscreenPixmapContext(const gfxIn
     if (!cfgs) {
         return nsnull;
     }
 
     NS_ASSERTION(numConfigs > 0,
                  "glXChooseFBConfig() failed to match our requested format and violated its spec (!)");
 
     ScopedXFree<XVisualInfo> vinfo;
-    int chosenIndex;
+    int chosenIndex = 0;
 
     for (int i = 0; i < numConfigs; ++i) {
         int dtype, visid;
 
         if (sGLXLibrary.xGetFBConfigAttrib(display, cfgs[i], GLX_DRAWABLE_TYPE, &dtype) != Success
             || !(dtype & GLX_PIXMAP_BIT))
         {
             continue;
--- a/gfx/thebes/gfxASurface.cpp
+++ b/gfx/thebes/gfxASurface.cpp
@@ -472,19 +472,19 @@ static const char *sSurfaceNamesForSurfa
     "gfx/surface/tee",
     "gfx/surface/xml",
     "gfx/surface/skia",
     "gfx/surface/d2d"
 };
 
 PR_STATIC_ASSERT(NS_ARRAY_LENGTH(sSurfaceNamesForSurfaceType) == gfxASurface::SurfaceTypeMax);
 #ifdef CAIRO_HAS_D2D_SURFACE
-PR_STATIC_ASSERT(CAIRO_SURFACE_TYPE_D2D == gfxASurface::SurfaceTypeD2D);
+PR_STATIC_ASSERT(PRUint32(CAIRO_SURFACE_TYPE_D2D) == PRUint32(gfxASurface::SurfaceTypeD2D));
 #endif
-PR_STATIC_ASSERT(CAIRO_SURFACE_TYPE_SKIA == gfxASurface::SurfaceTypeSkia);
+PR_STATIC_ASSERT(PRUint32(CAIRO_SURFACE_TYPE_SKIA) == PRUint32(gfxASurface::SurfaceTypeSkia));
 
 static const char *
 SurfaceMemoryReporterPathForType(gfxASurface::gfxSurfaceType aType)
 {
     if (aType < 0 ||
         aType >= gfxASurface::SurfaceTypeMax)
         return "gfx/surface/unknown";
 
--- a/gfx/thebes/gfxBlur.cpp
+++ b/gfx/thebes/gfxBlur.cpp
@@ -289,16 +289,19 @@ static void ComputeLobes(PRInt32 aRadius
         major = z + 1;
         minor = final = z;
         break;
     case 2:
         // aRadius = z*3 + 2; choose d = 2*z + 2
         major = final = z + 1;
         minor = z;
         break;
+    default:
+        NS_ERROR("Mathematical impossibility.");
+        major = minor = final = 0;
     }
     NS_ASSERTION(major + minor + final == aRadius,
                  "Lobes don't sum to the right length");
 
     aLobes[0][0] = major;
     aLobes[0][1] = minor;
     aLobes[1][0] = minor;
     aLobes[1][1] = major;
--- a/gfx/thebes/gfxFont.cpp
+++ b/gfx/thebes/gfxFont.cpp
@@ -1,10 +1,10 @@
-/* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 4 -*-
- * ***** BEGIN LICENSE BLOCK *****
+/* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/* ***** BEGIN LICENSE BLOCK *****
  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
  *
  * The contents of this file are subject to the Mozilla Public License Version
  * 1.1 (the "License"); you may not use this file except in compliance with
  * the License. You may obtain a copy of the License at
  * http://www.mozilla.org/MPL/
  *
  * Software distributed under the License is distributed on an "AS IS" basis,
--- a/gfx/thebes/gfxFontUtils.cpp
+++ b/gfx/thebes/gfxFontUtils.cpp
@@ -1,10 +1,10 @@
-/* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 4 -*-
- * ***** BEGIN LICENSE BLOCK *****
+/* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/* ***** BEGIN LICENSE BLOCK *****
  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
  *
  * The contents of this file are subject to the Mozilla Public License Version
  * 1.1 (the "License"); you may not use this file except in compliance with
  * the License. You may obtain a copy of the License at
  * http://www.mozilla.org/MPL/
  *
  * Software distributed under the License is distributed on an "AS IS" basis,
@@ -527,17 +527,17 @@ gfxFontUtils::FindPreferredSubtable(cons
 
     if (!aBuf || aBufLength < SizeOfHeader) {
         // cmap table is missing, or too small to contain header fields!
         return 0;
     }
 
     // PRUint16 version = ReadShortAt(aBuf, OffsetVersion); // Unused: self-documenting.
     PRUint16 numTables = ReadShortAt(aBuf, OffsetNumTables);
-    if (aBufLength < SizeOfHeader + numTables * SizeOfTable) {
+    if (aBufLength < PRUint32(SizeOfHeader + numTables * SizeOfTable)) {
         return 0;
     }
 
     // save the format we want here
     PRUint32 keepFormat = 0;
 
     const PRUint8 *table = aBuf + SizeOfHeader;
     for (PRUint16 i = 0; i < numTables; ++i, table += SizeOfTable) {
@@ -1079,18 +1079,19 @@ gfxFontUtils::ValidateSFNTHeaders(const 
         NS_WARNING("invalid font (SFNT version)");
         return PR_FALSE;
     }
     
     // iterate through the table headers to find the head, name and OS/2 tables
     PRBool foundHead = PR_FALSE, foundOS2 = PR_FALSE, foundName = PR_FALSE;
     PRBool foundGlyphs = PR_FALSE, foundCFF = PR_FALSE, foundKern = PR_FALSE;
     PRBool foundLoca = PR_FALSE, foundMaxp = PR_FALSE;
-    PRUint32 headOffset, headLen, nameOffset, nameLen, kernOffset, kernLen,
-             glyfLen, locaOffset, locaLen, maxpOffset, maxpLen;
+    PRUint32 headOffset = 0, headLen, nameOffset = 0, nameLen, kernOffset = 0,
+        kernLen = 0, glyfLen = 0, locaOffset = 0, locaLen = 0,
+        maxpOffset = 0, maxpLen;
     PRUint32 i, numTables;
 
     numTables = sfntHeader->numTables;
     PRUint32 headerLen = sizeof(SFNTHeader) + sizeof(TableDirEntry) * numTables;
     if (headerLen > aFontDataLength) {
         NS_WARNING("invalid font (table directory)");
         return PR_FALSE;
     }
--- a/gfx/thebes/gfxHarfBuzzShaper.cpp
+++ b/gfx/thebes/gfxHarfBuzzShaper.cpp
@@ -1,25 +1,26 @@
-/* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 4 -*-
- * ***** BEGIN LICENSE BLOCK *****
+/* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/* ***** BEGIN LICENSE BLOCK *****
  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
  *
  * The contents of this file are subject to the Mozilla Public License Version
  * 1.1 (the "License"); you may not use this file except in compliance with
  * the License. You may obtain a copy of the License at
  * http://www.mozilla.org/MPL/
  *
  * Software distributed under the License is distributed on an "AS IS" basis,
  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
  * for the specific language governing rights and limitations under the
  * License.
  *
  * The Original Code is Mozilla Corporation code.
  *
- * The Initial Developer of the Original Code is Mozilla Corporation.
+ * The Initial Developer of the Original Code is
+ * the Mozilla Foundation.
  * Portions created by the Initial Developer are Copyright (C) 2009-2010
  * the Initial Developer. All Rights Reserved.
  *
  * Contributor(s):
  *   Jonathan Kew <jfkthame@gmail.com>
  *
  * Alternatively, the contents of this file may be used under the terms of
  * either the GNU General Public License Version 2 or later (the "GPL"), or
@@ -864,18 +865,20 @@ gfxHarfBuzzShaper::InitTextRun(gfxContex
                         aRunLength, 0, aRunLength);
 
     hb_shape(font, mHBFace, buffer, features.Elements(), features.Length());
 
     if (aTextRun->IsRightToLeft()) {
         hb_buffer_reverse(buffer);
     }
 
-    nsresult rv = SetGlyphsFromRun(aContext, aTextRun, buffer,
-                                   aRunStart, aRunLength);
+#ifdef DEBUG
+    nsresult rv =
+#endif
+    SetGlyphsFromRun(aContext, aTextRun, buffer, aRunStart, aRunLength);
     NS_WARN_IF_FALSE(NS_SUCCEEDED(rv), "failed to store glyphs into textrun");
     hb_buffer_destroy(buffer);
     hb_font_destroy(font);
 
     return PR_TRUE;
 }
 
 /**
@@ -1062,30 +1065,30 @@ gfxHarfBuzzShaper::SetGlyphsFromRun(gfxC
         NS_ASSERTION(charStart != charEnd,
                      "character/glyph clump contains no characters!");
 
         // Now charStart..charEnd is a ligature clump, corresponding to glyphStart..glyphEnd;
         // Set baseCharIndex to the char we'll actually attach the glyphs to (1st of ligature),
         // and endCharIndex to the limit (position beyond the last char),
         // adjusting for the offset of the stringRange relative to the textRun.
         PRInt32 baseCharIndex, endCharIndex;
-        while (charEnd < aRunLength && charToGlyph[charEnd] == NO_GLYPH)
+        while (charEnd < PRInt32(aRunLength) && charToGlyph[charEnd] == NO_GLYPH)
             charEnd++;
         baseCharIndex = charStart;
         endCharIndex = charEnd;
 
         // Then we check if the clump falls outside our actual string range;
         // if so, just go to the next.
-        if (baseCharIndex >= aRunLength) {
+        if (baseCharIndex >= PRInt32(aRunLength)) {
             glyphStart = glyphEnd;
             charStart = charEnd;
             continue;
         }
         // Ensure we won't try to go beyond the valid length of the textRun's text
-        endCharIndex = PR_MIN(endCharIndex, aRunLength);
+        endCharIndex = NS_MIN<PRInt32>(endCharIndex, aRunLength);
 
         // Now we're ready to set the glyph info in the textRun
         PRInt32 glyphsInClump = glyphEnd - glyphStart;
 
         // Check for default-ignorable char that didn't get filtered, combined,
         // etc by the shaping process, and remove from the run.
         // (This may be done within harfbuzz eventually.)
         if (glyphsInClump == 1 && baseCharIndex + 1 == endCharIndex &&
@@ -1157,17 +1160,18 @@ gfxHarfBuzzShaper::SetGlyphsFromRun(gfxC
             aTextRun->SetGlyphs(aTextRunOffset + baseCharIndex,
                                 g, detailedGlyphs.Elements());
 
             detailedGlyphs.Clear();
         }
 
         // the rest of the chars in the group are ligature continuations,
         // no associated glyphs
-        while (++baseCharIndex != endCharIndex && baseCharIndex < aRunLength) {
+        while (++baseCharIndex != endCharIndex &&
+               baseCharIndex < PRInt32(aRunLength)) {
             gfxTextRun::CompressedGlyph g;
             g.SetComplex(inOrder &&
                          aTextRun->IsClusterStart(aTextRunOffset + baseCharIndex),
                          PR_FALSE, 0);
             aTextRun->SetGlyphs(aTextRunOffset + baseCharIndex, g, nsnull);
         }
 
         glyphStart = glyphEnd;
--- a/gfx/thebes/gfxXlibNativeRenderer.cpp
+++ b/gfx/thebes/gfxXlibNativeRenderer.cpp
@@ -202,19 +202,19 @@ gfxXlibNativeRenderer::DrawDirect(gfxCon
     /* The client won't draw outside the surface so consider this when
        analysing clip rectangles. */
     nsIntRect bounds(offset, size);
     bounds.IntersectRect(bounds,
                          nsIntRect(0, 0,
                                    cairo_xlib_surface_get_width(target),
                                    cairo_xlib_surface_get_height(target)));
 
-    PRBool needs_clip;
+    PRBool needs_clip = PR_TRUE;
     nsIntRect rectangles[MAX_STATIC_CLIP_RECTANGLES];
-    int rect_count;
+    int rect_count = 0;
 
     /* Check that the clip is rectangular and aligned on unit boundaries. */
     /* Temporarily set the matrix for _get_rectangular_clip. It's basically
        the identity matrix, but we must adjust for the fact that our
        offset-rect is in device coordinates. */
     cairo_identity_matrix (cr);
     cairo_translate (cr, -device_offset_x, -device_offset_y);
     PRBool have_rectangular_clip =