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