WebKit Bugzilla
New
Browse
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
RESOLVED FIXED
140003
[Cocoa] Enable the compiler to check format strings specified with UI_STRING and UI_STRING_KEY
https://bugs.webkit.org/show_bug.cgi?id=140003
Summary
[Cocoa] Enable the compiler to check format strings specified with UI_STRING ...
mitz
Reported
2014-12-29 19:24:26 PST
Enable the compiler to emit a warning for something like [NSString stringWithFormat:UI_STRING("%d files", "label next to file upload button"), @"not an int"] based on %d not matching the NSString parameter.
Attachments
Add format_arg attributes to UI_STRING and UI_STRING_KEY
(3.13 KB, patch)
2014-12-29 19:34 PST
,
mitz
darin
: review+
Details
Formatted Diff
Diff
View All
Add attachment
proposed patch, testcase, etc.
mitz
Comment 1
2014-12-29 19:34:59 PST
Created
attachment 243817
[details]
Add format_arg attributes to UI_STRING and UI_STRING_KEY
WebKit Commit Bot
Comment 2
2014-12-29 19:36:13 PST
Attachment 243817
[details]
did not pass style-queue: ERROR: Source/WebKit/mac/Misc/WebLocalizableStrings.h:47: The parameter name "bundle" adds no information, so it should be removed. [readability/parameter_name] [5] ERROR: Source/WebKit/mac/Misc/WebLocalizableStrings.h:54: The parameter name "bundle" adds no information, so it should be removed. [readability/parameter_name] [5] Total errors found: 2 in 2 files If any of these errors are false positives, please file a bug against check-webkit-style.
Darin Adler
Comment 3
2014-12-30 10:05:54 PST
Comment on
attachment 243817
[details]
Add format_arg attributes to UI_STRING and UI_STRING_KEY View in context:
https://bugs.webkit.org/attachment.cgi?id=243817&action=review
> Source/WebKit/mac/ChangeLog:9 > + that takes their "string" parameter as a "value" "parameter and has an attribute telling
Extra quote here?
Darin Adler
Comment 4
2014-12-30 10:09:07 PST
Comment on
attachment 243817
[details]
Add format_arg attributes to UI_STRING and UI_STRING_KEY View in context:
https://bugs.webkit.org/attachment.cgi?id=243817&action=review
> Source/WebKit/mac/Misc/WebLocalizableStrings.h:52 > +static inline NS_FORMAT_ARGUMENT(3) NSString *WebLocalizedStringWithValue(WebLocalizableStringsBundle *bundle, const char* key, const char* value) > +{ > + return WebLocalizedString(bundle, key); > +}
On reflection, I don’t think it’s good for WebLocalizedStringWithValue inlines to be inside extern "C"; I also don’t like the formatting with the #if right up against the functions, but blank lines between the two functions. I’d move WebLocalizedStringWithValue down below. And I’d even consider using a macro for the NS/CF_FORMAT_ARGUMENT so we don’t have to repeat the WebLocalizedStringWithValue function twice.
mitz
Comment 5
2014-12-30 10:13:09 PST
(In reply to
comment #4
)
> Comment on
attachment 243817
[details]
> Add format_arg attributes to UI_STRING and UI_STRING_KEY > > View in context: >
https://bugs.webkit.org/attachment.cgi?id=243817&action=review
> > > Source/WebKit/mac/Misc/WebLocalizableStrings.h:52 > > +static inline NS_FORMAT_ARGUMENT(3) NSString *WebLocalizedStringWithValue(WebLocalizableStringsBundle *bundle, const char* key, const char* value) > > +{ > > + return WebLocalizedString(bundle, key); > > +} > > On reflection, I don’t think it’s good for WebLocalizedStringWithValue > inlines to be inside extern "C"; I also don’t like the formatting with the > #if right up against the functions, but blank lines between the two > functions. I’d move WebLocalizedStringWithValue down below.
OK.
> And I’d even > consider using a macro for the NS/CF_FORMAT_ARGUMENT so we don’t have to > repeat the WebLocalizedStringWithValue function twice.
Wouldn’t we still need to repeat at least the function signature because of the return types being different?
Darin Adler
Comment 6
2014-12-30 10:21:07 PST
(In reply to
comment #5
)
> > And I’d even > > consider using a macro for the NS/CF_FORMAT_ARGUMENT so we don’t have to > > repeat the WebLocalizedStringWithValue function twice. > > Wouldn’t we still need to repeat at least the function signature because of > the return types being different?
Might need a typedef too, yes.
mitz
Comment 7
2014-12-30 12:43:12 PST
Committed <
http://trac.webkit.org/r177825
>.
Note
You need to
log in
before you can comment on or make changes to this bug.
Top of Page
Format For Printing
XML
Clone This Bug