Bug 1393538 Clean up unused variables in toolkit/ draft
authorTom Ritter <tom@mozilla.com>
Thu, 24 Aug 2017 15:07:59 -0500
changeset 652423 ee27a007160f42012ef8f6234abbecc79347dac6
parent 652421 32c9c0bc8e654f064f5b67912f8794a719b98c46
child 652442 f3547d98fb4355796f7662610e1fd9c5b191d9b1
push id76051
push userbmo:tom@mozilla.com
push dateThu, 24 Aug 2017 20:09:06 +0000
bugs1393538
milestone57.0a1
Bug 1393538 Clean up unused variables in toolkit/ MozReview-Commit-ID: I6r50dqJJHJ
mfbt/Assertions.h
toolkit/components/filewatcher/NativeFileWatcherWin.cpp
toolkit/xre/nsAppRunner.cpp
toolkit/xre/nsNativeAppSupportWin.cpp
old mode 100644
new mode 100755
--- a/mfbt/Assertions.h
+++ b/mfbt/Assertions.h
@@ -61,16 +61,22 @@ TerminateProcess(void* hProcess, unsigne
 MOZ_END_EXTERN_C
 #else
 #  include <signal.h>
 #endif
 #ifdef ANDROID
 #  include <android/log.h>
 #endif
 
+#if defined(__GNUC__)
+#  define MOZ_UNUSED_ATTRIBUTE __attribute__((unused))
+#else
+#  define MOZ_UNUSED_ATTRIBUTE /* nothing */
+#endif
+
 /*
  * MOZ_STATIC_ASSERT may be used to assert a condition *at compile time* in C.
  * In C++11, static_assert is provided by the compiler to the same effect.
  * This can be useful when you make certain assumptions about what must hold for
  * optimal, or even correct, behavior.  For example, you might assert that the
  * size of a struct is a multiple of the target architecture's word size:
  *
  *   struct S { ... };
@@ -85,21 +91,16 @@ MOZ_END_EXTERN_C
  * typedef could be used.
  */
 #ifndef __cplusplus
    /*
     * Some of the definitions below create an otherwise-unused typedef.  This
     * triggers compiler warnings with some versions of gcc, so mark the typedefs
     * as permissibly-unused to disable the warnings.
     */
-#  if defined(__GNUC__)
-#    define MOZ_STATIC_ASSERT_UNUSED_ATTRIBUTE __attribute__((unused))
-#  else
-#    define MOZ_STATIC_ASSERT_UNUSED_ATTRIBUTE /* nothing */
-#  endif
 #  define MOZ_STATIC_ASSERT_GLUE1(x, y)          x##y
 #  define MOZ_STATIC_ASSERT_GLUE(x, y)           MOZ_STATIC_ASSERT_GLUE1(x, y)
 #  if defined(__SUNPRO_CC)
      /*
       * The Sun Studio C++ compiler is buggy when declaring, inside a function,
       * another extern'd function with an array argument whose length contains a
       * sizeof, triggering the error message "sizeof expression not accepted as
       * size of array parameter".  This bug (6688515, not public yet) would hit
@@ -122,20 +123,20 @@ MOZ_END_EXTERN_C
       * we include the line number in the function name to do the best we can to
       * avoid conflicts.  These should be rare: a conflict would require use of
       * MOZ_STATIC_ASSERT on the same line in separate files in the same
       * translation unit, *and* the uses would have to be in code with
       * different linkage, *and* the first observed use must be in C++-linkage
       * code.
       */
 #    define MOZ_STATIC_ASSERT(cond, reason) \
-       typedef int MOZ_STATIC_ASSERT_GLUE(moz_static_assert, __COUNTER__)[(cond) ? 1 : -1] MOZ_STATIC_ASSERT_UNUSED_ATTRIBUTE
+       typedef int MOZ_STATIC_ASSERT_GLUE(moz_static_assert, __COUNTER__)[(cond) ? 1 : -1] MOZ_UNUSED_ATTRIBUTE
 #  else
 #    define MOZ_STATIC_ASSERT(cond, reason) \
-       extern void MOZ_STATIC_ASSERT_GLUE(moz_static_assert, __LINE__)(int arg[(cond) ? 1 : -1]) MOZ_STATIC_ASSERT_UNUSED_ATTRIBUTE
+       extern void MOZ_STATIC_ASSERT_GLUE(moz_static_assert, __LINE__)(int arg[(cond) ? 1 : -1]) MOZ_UNUSED_ATTRIBUTE
 #  endif
 
 #define MOZ_STATIC_ASSERT_IF(cond, expr, reason)  MOZ_STATIC_ASSERT(!(cond) || (expr), reason)
 #else
 #define MOZ_STATIC_ASSERT_IF(cond, expr, reason)  static_assert(!(cond) || (expr), reason)
 #endif
 
 MOZ_BEGIN_EXTERN_C
--- a/toolkit/components/filewatcher/NativeFileWatcherWin.cpp
+++ b/toolkit/components/filewatcher/NativeFileWatcherWin.cpp
@@ -1488,17 +1488,17 @@ NativeFileWatcherService::WakeUpWorkerTh
  */
 NS_IMETHODIMP
 NativeFileWatcherService::Observe(nsISupports* aSubject, const char* aTopic,
                                   const char16_t* aData)
 {
   MOZ_ASSERT(NS_IsMainThread());
 
   if (!strcmp("xpcom-shutdown-threads", aTopic)) {
-    nsresult rv = Uninit();
+    DebugOnly<nsresult> rv = Uninit();
     MOZ_ASSERT(NS_SUCCEEDED(rv));
     return NS_OK;
   }
 
   MOZ_ASSERT(false, "NativeFileWatcherService got an unexpected topic!");
 
   return NS_ERROR_UNEXPECTED;
 }
--- a/toolkit/xre/nsAppRunner.cpp
+++ b/toolkit/xre/nsAppRunner.cpp
@@ -624,17 +624,16 @@ ProcessDDE(nsINativeAppSupport* aNative,
   // argument. The requestpending pending argument is removed to
   // differentiate it from being launched when an app restart is not
   // required.
   ArgResult ar;
   ar = CheckArgShell("requestpending");
   if (ar == ARG_FOUND) {
     aNative->Enable(); // enable win32 DDE responses
     if (aWait) {
-      nsIThread *thread = NS_GetCurrentThread();
       // This is just a guesstimate based on testing different values.
       // If count is 8 or less windows will display an error dialog.
       int32_t count = 20;
       SpinEventLoopUntil([&]() { return --count < 0; });
     }
   }
 }
 #endif
old mode 100644
new mode 100755
--- a/toolkit/xre/nsNativeAppSupportWin.cpp
+++ b/toolkit/xre/nsNativeAppSupportWin.cpp
@@ -35,16 +35,17 @@
 #include "mozilla/Services.h"
 #include "nsIFile.h"
 #include "nsIObserver.h"
 #include "nsIObserverService.h"
 #include "nsIWebNavigation.h"
 #include "nsIWindowMediator.h"
 #include "nsNativeCharsetUtils.h"
 #include "nsIAppStartup.h"
+#include "mozilla/Assertions.h"
 #include "mozilla/dom/Location.h"
 
 #include <windows.h>
 #include <shellapi.h>
 #include <ddeml.h>
 #include <stdlib.h>
 #include <stdio.h>
 #include <io.h>
@@ -105,17 +106,17 @@ struct Win32Mutex {
         printf( "CreateMutex error = 0x%08X\n", (int)GetLastError() );
 #endif
     }
     ~Win32Mutex() {
         if ( mHandle ) {
             // Make sure we release it if we own it.
             Unlock();
 
-            BOOL rc = CloseHandle( mHandle );
+            BOOL rc MOZ_UNUSED_ATTRIBUTE = CloseHandle( mHandle );
 #if MOZ_DEBUG_DDE
             if ( !rc ) {
                 printf( "CloseHandle error = 0x%08X\n", (int)GetLastError() );
             }
 #endif
         }
     }
     BOOL Lock( DWORD timeout ) {