Bug 1204398 - Fix -Wshadow warnings in widget/cocoa. r=spohl
authorChris Peterson <cpeterson@mozilla.com>
Fri, 11 Sep 2015 20:32:37 -0700
changeset 299127 ab8764ec9c2e46308b17c822bb6116579738d087
parent 299126 a4d31272fc63a20c626beedd94df74f7710b1bde
child 299128 9a2e51a7ece292ceea5011159035f8f7bb443b88
push id1001
push userraliiev@mozilla.com
push dateMon, 18 Jan 2016 19:06:03 +0000
treeherdermozilla-release@8b89261f3ac4 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersspohl
bugs1204398
milestone44.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 1204398 - Fix -Wshadow warnings in widget/cocoa. r=spohl
widget/cocoa/moz.build
widget/cocoa/nsChildView.mm
widget/cocoa/nsClipboard.mm
widget/cocoa/nsDragService.mm
widget/cocoa/nsPrintOptionsX.mm
--- a/widget/cocoa/moz.build
+++ b/widget/cocoa/moz.build
@@ -72,16 +72,19 @@ SOURCES += [
 
 if not CONFIG['RELEASE_BUILD'] or CONFIG['MOZ_DEBUG']:
     SOURCES += [
         'nsSandboxViolationSink.mm',
     ]
 
 include('/ipc/chromium/chromium-config.mozbuild')
 
+if CONFIG['GNU_CXX']:
+    CXXFLAGS += ['-Wshadow']
+
 # XXX: We should fix these warnings.
 ALLOW_COMPILER_WARNINGS = True
 
 FINAL_LIBRARY = 'xul'
 LOCAL_INCLUDES += [
     '/layout/forms',
     '/layout/generic',
     '/layout/xul',
--- a/widget/cocoa/nsChildView.mm
+++ b/widget/cocoa/nsChildView.mm
@@ -6106,23 +6106,23 @@ PanGestureTypeForEvent(NSEvent* aEvent)
 
   // Transform the transferable to an NSDictionary.
   NSDictionary* pasteboardOutputDict = nsClipboard::PasteboardDictFromTransferable(event.mReply.mTransferable);
   if (!pasteboardOutputDict)
     return NO;
 
   // Declare the pasteboard types.
   unsigned int typeCount = [pasteboardOutputDict count];
-  NSMutableArray * types = [NSMutableArray arrayWithCapacity:typeCount];
-  [types addObjectsFromArray:[pasteboardOutputDict allKeys]];
-  [pboard declareTypes:types owner:nil];
+  NSMutableArray* declaredTypes = [NSMutableArray arrayWithCapacity:typeCount];
+  [declaredTypes addObjectsFromArray:[pasteboardOutputDict allKeys]];
+  [pboard declareTypes:declaredTypes owner:nil];
 
   // Write the data to the pasteboard.
   for (unsigned int i = 0; i < typeCount; i++) {
-    NSString* currentKey = [types objectAtIndex:i];
+    NSString* currentKey = [declaredTypes objectAtIndex:i];
     id currentValue = [pasteboardOutputDict valueForKey:currentKey];
 
     if (currentKey == NSStringPboardType ||
         currentKey == kCorePboardType_url ||
         currentKey == kCorePboardType_urld ||
         currentKey == kCorePboardType_urln) {
       [pboard setString:currentValue forType:currentKey];
     } else if (currentKey == NSHTMLPboardType) {
--- a/widget/cocoa/nsClipboard.mm
+++ b/widget/cocoa/nsClipboard.mm
@@ -464,21 +464,21 @@ nsClipboard::PasteboardDictFromTransfera
 
       RefPtr<SourceSurface> surface =
         image->GetFrame(imgIContainer::FRAME_CURRENT,
                         imgIContainer::FLAG_SYNC_DECODE);
       if (!surface) {
         continue;
       }
       CGImageRef imageRef = NULL;
-      nsresult rv = nsCocoaUtils::CreateCGImageFromSurface(surface, &imageRef);
+      rv = nsCocoaUtils::CreateCGImageFromSurface(surface, &imageRef);
       if (NS_FAILED(rv) || !imageRef) {
         continue;
       }
-      
+
       // Convert the CGImageRef to TIFF data.
       CFMutableDataRef tiffData = CFDataCreateMutable(kCFAllocatorDefault, 0);
       CGImageDestinationRef destRef = CGImageDestinationCreateWithData(tiffData,
                                                                        CFSTR("public.tiff"),
                                                                        1,
                                                                        NULL);
       CGImageDestinationAddImage(destRef, imageRef, NULL);
       bool successfullyConverted = CGImageDestinationFinalize(destRef);
--- a/widget/cocoa/nsDragService.mm
+++ b/widget/cocoa/nsDragService.mm
@@ -108,19 +108,19 @@ static nsresult SetUpDragClipboard(nsISu
   if (!aTransferableArray)
     return NS_ERROR_FAILURE;
 
   uint32_t count = 0;
   aTransferableArray->Count(&count);
 
   NSPasteboard* dragPBoard = [NSPasteboard pasteboardWithName:NSDragPboard];
 
-  for (uint32_t i = 0; i < count; i++) {
+  for (uint32_t j = 0; j < count; j++) {
     nsCOMPtr<nsISupports> currentTransferableSupports;
-    aTransferableArray->GetElementAt(i, getter_AddRefs(currentTransferableSupports));
+    aTransferableArray->GetElementAt(j, getter_AddRefs(currentTransferableSupports));
     if (!currentTransferableSupports)
       return NS_ERROR_FAILURE;
 
     nsCOMPtr<nsITransferable> currentTransferable(do_QueryInterface(currentTransferableSupports));
     if (!currentTransferable)
       return NS_ERROR_FAILURE;
 
     // Transform the transferable to an NSDictionary
@@ -131,18 +131,18 @@ static nsresult SetUpDragClipboard(nsISu
     // write everything out to the general pasteboard
     unsigned int typeCount = [pasteboardOutputDict count];
     NSMutableArray* types = [NSMutableArray arrayWithCapacity:typeCount + 1];
     [types addObjectsFromArray:[pasteboardOutputDict allKeys]];
     // Gecko is initiating this drag so we always want its own views to consider
     // it. Add our wildcard type to the pasteboard to accomplish this.
     [types addObject:kWildcardPboardType]; // we don't increase the count for the loop below on purpose
     [dragPBoard declareTypes:types owner:nil];
-    for (unsigned int i = 0; i < typeCount; i++) {
-      NSString* currentKey = [types objectAtIndex:i];
+    for (unsigned int k = 0; k < typeCount; k++) {
+      NSString* currentKey = [types objectAtIndex:k];
       id currentValue = [pasteboardOutputDict valueForKey:currentKey];
       if (currentKey == NSStringPboardType ||
           currentKey == kCorePboardType_url ||
           currentKey == kCorePboardType_urld ||
           currentKey == kCorePboardType_urln) {
         [dragPBoard setString:currentValue forType:currentKey];
       }
       else if (currentKey == NSHTMLPboardType) {
@@ -420,17 +420,17 @@ nsDragService::GetData(nsITransferable* 
       unsigned int dataLength = (stringLength + 1) * sizeof(char16_t); // in bytes
       char16_t* clipboardDataPtr = (char16_t*)malloc(dataLength);
       if (!clipboardDataPtr)
         return NS_ERROR_OUT_OF_MEMORY;
       [filePath getCharacters:reinterpret_cast<unichar*>(clipboardDataPtr)];
       clipboardDataPtr[stringLength] = 0; // null terminate
 
       nsCOMPtr<nsIFile> file;
-      nsresult rv = NS_NewLocalFile(nsDependentString(clipboardDataPtr), true, getter_AddRefs(file));
+      rv = NS_NewLocalFile(nsDependentString(clipboardDataPtr), true, getter_AddRefs(file));
       free(clipboardDataPtr);
       if (NS_FAILED(rv))
         continue;
 
       aTransferable->SetTransferData(flavorStr, file, dataLength);
       
       break;
     }
--- a/widget/cocoa/nsPrintOptionsX.mm
+++ b/widget/cocoa/nsPrintOptionsX.mm
@@ -31,17 +31,17 @@ nsPrintOptionsX::SerializeToPrintData(ns
 
   if (aWBP) {
     // When serializing an nsIWebBrowserPrint, we need to pass up the first
     // document name. We could pass up the entire collection of document
     // names, but the OS X printing prompt code only really cares about
     // the first one, so we just send the first to save IPC traffic.
     char16_t** docTitles;
     uint32_t titleCount;
-    nsresult rv = aWBP->EnumerateDocumentNames(&titleCount, &docTitles);
+    rv = aWBP->EnumerateDocumentNames(&titleCount, &docTitles);
     if (NS_SUCCEEDED(rv) && titleCount > 0) {
       data->printJobName().Assign(docTitles[0]);
     }
 
     for (int32_t i = titleCount - 1; i >= 0; i--) {
       free(docTitles[i]);
     }
     free(docTitles);