NSLocalizedString compatibility (10.8 SDK and clang trunk -Wformat-extra-args)

Apparently, as of the 10.8 SDK, Apple has quietly decided that the first
argument to NSLocalizedString is supposed to be usable as-is as a format
string, instead of simply being the key to obtain a usable format string.
The recent clang trunk enforces this, resulting in build breaks like

crash_report_sender.m:560:14: error: data argument not used by format string [-Werror,-Wformat-extra-args]
             displayName];
             ^

Breaking the result of NSLocalizedString into a temporary NSString* is enough
to suppress the warning.

BUG=chromium:314109
R=thakis@chromium.org

Review URL: https://breakpad.appspot.com/674003

git-svn-id: http://google-breakpad.googlecode.com/svn/trunk@1230 4c0a9323-5329-0410-9bdc-e9ce6186880e
This commit is contained in:
mark@chromium.org 2013-11-05 16:53:55 +00:00
parent bf139abc7d
commit 4b6e0bb952

View File

@ -555,13 +555,13 @@ doCommandBySelector:(SEL)commandSelector {
displayName = [[uploader_ parameters] objectForKey:@BREAKPAD_PRODUCT]; displayName = [[uploader_ parameters] objectForKey:@BREAKPAD_PRODUCT];
if ([self isOnDemand]) { if ([self isOnDemand]) {
return [NSString // Local variable to pacify clang's -Wformat-extra-args.
stringWithFormat:NSLocalizedString(@"noCrashDialogHeader", @""), NSString* format = NSLocalizedString(@"noCrashDialogHeader", @"");
displayName]; return [NSString stringWithFormat:format, displayName];
} else { } else {
return [NSString // Local variable to pacify clang's -Wformat-extra-args.
stringWithFormat:NSLocalizedString(@"crashDialogHeader", @""), NSString* format = NSLocalizedString(@"crashDialogHeader", @"");
displayName]; return [NSString stringWithFormat:format, displayName];
} }
} }
@ -576,13 +576,13 @@ doCommandBySelector:(SEL)commandSelector {
vendor = @"unknown vendor"; vendor = @"unknown vendor";
if ([self isOnDemand]) { if ([self isOnDemand]) {
return [NSString // Local variable to pacify clang's -Wformat-extra-args.
stringWithFormat:NSLocalizedString(@"noCrashDialogMsg", @""), NSString* format = NSLocalizedString(@"noCrashDialogMsg", @"");
vendor, displayName]; return [NSString stringWithFormat:format, vendor, displayName];
} else { } else {
return [NSString // Local variable to pacify clang's -Wformat-extra-args.
stringWithFormat:NSLocalizedString(@"crashDialogMsg", @""), NSString* format = NSLocalizedString(@"crashDialogMsg", @"");
vendor]; return [NSString stringWithFormat:format, vendor];
} }
} }