Bug 1278468 - Fix -Wshadow warnings in storage/ directory. r=mak
authorChris Peterson <cpeterson@mozilla.com>
Tue, 07 Jun 2016 22:08:41 -0700
changeset 301015 d71d5a7a70d2c45f430a119c1b0edcfc8f83f664
parent 301014 4a56907aff097f0fbbd1ff0479dbb6a547ae7f5a
child 301016 44208fb75c8bebc0c7c2ba1e6dd2824b881bbb51
push id30324
push usercbook@mozilla.com
push dateWed, 08 Jun 2016 09:58:15 +0000
treeherdermozilla-central@f8ad071a6e14 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmak
bugs1278468
milestone50.0a1
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 1278468 - Fix -Wshadow warnings in storage/ directory. r=mak storage/TelemetryVFS.cpp:81:44 [-Wshadow] declaration shadows a field of '(anonymous namespace)::IOThreadAutoTimer' storage/VacuumManager.cpp:192:25 [-Wshadow] declaration shadows a local variable storage/VacuumManager.cpp:248:13 [-Wshadow] declaration shadows a local variable storage/VacuumManager.cpp:249:14 [-Wshadow] declaration shadows a local variable storage/VacuumManager.cpp:251:19 [-Wshadow] declaration shadows a local variable storage/mozStorageConnection.cpp:971:15 [-Wshadow] declaration shadows a local variable storage/mozStorageStatement.cpp:449:19 [-Wshadow] declaration shadows a local variable storage/variantToSQLiteT_impl.h:97:16 [-Wshadow] declaration shadows a local variable
storage/TelemetryVFS.cpp
storage/VacuumManager.cpp
storage/moz.build
storage/mozStorageConnection.cpp
storage/mozStorageStatement.cpp
storage/variantToSQLiteT_impl.h
--- a/storage/TelemetryVFS.cpp
+++ b/storage/TelemetryVFS.cpp
@@ -73,20 +73,20 @@ public:
    * @param id takes a telemetry histogram id. The id+1 must be an
    * equivalent histogram for the main thread. Eg, MOZ_SQLITE_OPEN_MS 
    * is followed by MOZ_SQLITE_OPEN_MAIN_THREAD_MS.
    *
    * @param aOp optionally takes an IO operation to report through the
    * IOInterposer. Filename will be reported as NULL, and reference will be
    * either "sqlite-mainthread" or "sqlite-otherthread".
    */
-  explicit IOThreadAutoTimer(Telemetry::ID id,
+  explicit IOThreadAutoTimer(Telemetry::ID aId,
     IOInterposeObserver::Operation aOp = IOInterposeObserver::OpNone)
     : start(TimeStamp::Now()),
-      id(id),
+      id(aId),
       op(aOp)
   {
   }
 
   /**
    * This constructor is for when we want to report an operation to
    * IOInterposer but do not require a telemetry probe.
    *
--- a/storage/VacuumManager.cpp
+++ b/storage/VacuumManager.cpp
@@ -184,17 +184,17 @@ Vacuumer::execute()
   NS_ENSURE_SUCCESS(rv, false);
   if (!vacuumGranted) {
     return false;
   }
 
   // Notify a heavy IO task is about to start.
   nsCOMPtr<nsIObserverService> os = mozilla::services::GetObserverService();
   if (os) {
-    DebugOnly<nsresult> rv =
+    rv =
       os->NotifyObservers(nullptr, OBSERVER_TOPIC_HEAVY_IO,
                           OBSERVER_DATA_VACUUM_BEGIN.get());
     MOZ_ASSERT(NS_SUCCEEDED(rv), "Should be able to notify");
   }
 
   // Execute the statements separately, since the pragma may conflict with the
   // vacuum, if they are executed in the same transaction.
   nsCOMPtr<mozIStorageAsyncStatement> pageSizeStmt;
@@ -221,39 +221,39 @@ Vacuumer::execute()
 }
 
 ////////////////////////////////////////////////////////////////////////////////
 //// mozIStorageStatementCallback
 
 NS_IMETHODIMP
 Vacuumer::HandleError(mozIStorageError *aError)
 {
+  int32_t result;
+  nsresult rv;
+  nsAutoCString message;
+
 #ifdef DEBUG
-  int32_t result;
-  nsresult rv = aError->GetResult(&result);
+  rv = aError->GetResult(&result);
   NS_ENSURE_SUCCESS(rv, rv);
-  nsAutoCString message;
   rv = aError->GetMessage(message);
   NS_ENSURE_SUCCESS(rv, rv);
 
   nsAutoCString warnMsg;
   warnMsg.AppendLiteral("Unable to vacuum database: ");
   warnMsg.Append(mDBFilename);
   warnMsg.AppendLiteral(" - ");
   warnMsg.AppendInt(result);
   warnMsg.Append(' ');
   warnMsg.Append(message);
   NS_WARNING(warnMsg.get());
 #endif
 
   if (MOZ_LOG_TEST(gStorageLog, LogLevel::Error)) {
-    int32_t result;
-    nsresult rv = aError->GetResult(&result);
+    rv = aError->GetResult(&result);
     NS_ENSURE_SUCCESS(rv, rv);
-    nsAutoCString message;
     rv = aError->GetMessage(message);
     NS_ENSURE_SUCCESS(rv, rv);
     MOZ_LOG(gStorageLog, LogLevel::Error,
            ("Vacuum failed with error: %d '%s'. Database was: '%s'",
             result, message.get(), mDBFilename.get()));
   }
   return NS_OK;
 }
--- a/storage/moz.build
+++ b/storage/moz.build
@@ -108,11 +108,8 @@ if CONFIG['MOZ_MEMORY'] and (not CONFIG[
 DEFINES['SQLITE_MAX_LIKE_PATTERN_LENGTH'] = 50000
 
 LOCAL_INCLUDES += [
     '/db/sqlite3/src',
     '/dom/base',
 ]
 
 CXXFLAGS += CONFIG['SQLITE_CFLAGS']
-
-if CONFIG['GNU_CXX']:
-    CXXFLAGS += ['-Wno-error=shadow']
--- a/storage/mozStorageConnection.cpp
+++ b/storage/mozStorageConnection.cpp
@@ -957,27 +957,29 @@ Connection::internalClose(sqlite3 *aNati
               stmt));
 
 #ifdef DEBUG
       char *msg = ::PR_smprintf("SQL statement '%s' (%x) should have been finalized before closing the connection",
                                 ::sqlite3_sql(stmt),
                                 stmt);
       NS_WARNING(msg);
       ::PR_smprintf_free(msg);
+      msg = nullptr;
 #endif // DEBUG
 
       srv = ::sqlite3_finalize(stmt);
 
 #ifdef DEBUG
       if (srv != SQLITE_OK) {
-        char *msg = ::PR_smprintf("Could not finalize SQL statement '%s' (%x)",
-                                  ::sqlite3_sql(stmt),
-                                  stmt);
+        msg = ::PR_smprintf("Could not finalize SQL statement '%s' (%x)",
+                            ::sqlite3_sql(stmt),
+                            stmt);
         NS_WARNING(msg);
         ::PR_smprintf_free(msg);
+        msg = nullptr;
       }
 #endif // DEBUG
 
       // Ensure that the loop continues properly, whether closing has succeeded
       // or not.
       if (srv == SQLITE_OK) {
         stmt = nullptr;
       }
--- a/storage/mozStorageStatement.cpp
+++ b/storage/mozStorageStatement.cpp
@@ -441,19 +441,19 @@ Statement::GetParameterName(uint32_t aPa
   if (!mDBStatement)
     return NS_ERROR_NOT_INITIALIZED;
   ENSURE_INDEX_VALUE(aParamIndex, mParamCount);
 
   const char *name = ::sqlite3_bind_parameter_name(mDBStatement,
                                                    aParamIndex + 1);
   if (name == nullptr) {
     // this thing had no name, so fake one
-    nsAutoCString name(":");
-    name.AppendInt(aParamIndex);
-    _name.Assign(name);
+    nsAutoCString fakeName(":");
+    fakeName.AppendInt(aParamIndex);
+    _name.Assign(fakeName);
   }
   else {
     _name.Assign(nsDependentCString(name));
   }
 
   return NS_OK;
 }
 
--- a/storage/variantToSQLiteT_impl.h
+++ b/storage/variantToSQLiteT_impl.h
@@ -16,19 +16,19 @@ template <typename T>
 int
 variantToSQLiteT(T aObj,
                  nsIVariant *aValue)
 {
   // Allow to return nullptr not wrapped to nsIVariant for speed.
   if (!aValue)
     return sqlite3_T_null(aObj);
 
-  uint16_t type;
-  (void)aValue->GetDataType(&type);
-  switch (type) {
+  uint16_t valueType;
+  aValue->GetDataType(&valueType);
+  switch (valueType) {
     case nsIDataType::VTYPE_INT8:
     case nsIDataType::VTYPE_INT16:
     case nsIDataType::VTYPE_INT32:
     case nsIDataType::VTYPE_UINT8:
     case nsIDataType::VTYPE_UINT16:
     {
       int32_t value;
       nsresult rv = aValue->GetAsInt32(&value);
@@ -89,27 +89,27 @@ variantToSQLiteT(T aObj,
       return sqlite3_T_text16(aObj, value);
     }
     case nsIDataType::VTYPE_VOID:
     case nsIDataType::VTYPE_EMPTY:
     case nsIDataType::VTYPE_EMPTY_ARRAY:
       return sqlite3_T_null(aObj);
     case nsIDataType::VTYPE_ARRAY:
     {
-      uint16_t type;
+      uint16_t arrayType;
       nsIID iid;
       uint32_t count;
       void *data;
-      nsresult rv = aValue->GetAsArray(&type, &iid, &count, &data);
+      nsresult rv = aValue->GetAsArray(&arrayType, &iid, &count, &data);
       NS_ENSURE_SUCCESS(rv, SQLITE_MISMATCH);
 
       // Check to make sure it's a supported type.
-      NS_ASSERTION(type == nsIDataType::VTYPE_UINT8,
+      NS_ASSERTION(arrayType == nsIDataType::VTYPE_UINT8,
                    "Invalid type passed!  You may leak!");
-      if (type != nsIDataType::VTYPE_UINT8) {
+      if (arrayType != nsIDataType::VTYPE_UINT8) {
         // Technically this could leak with certain data types, but somebody was
         // being stupid passing us this anyway.
         free(data);
         return SQLITE_MISMATCH;
       }
 
       // Finally do our thing.  The function should free the array accordingly!
       int rc = sqlite3_T_blob(aObj, data, count);