[cfe-dev] Extending printf format string checking to cover ObjC format strings in NSLog
kremenek at apple.com
Mon Jun 16 13:15:55 PDT 2008
On Jun 16, 2008, at 1:13 PM, Nikita Zhuk wrote:
> On 16.6.2008, at 21.38, Ted Kremenek wrote:
>> This functionality should eventually go in as well. The set of
>> such CF functions should be small. Other functions that use
>> Objective-C style format strings should generally be labeled with
>> the __NSString__ attribute. Unfortunately, it looks like the
>> "initWithFormat:" methods do not have this attribute:
>> Fortunately, it looks like the set of methods to hardwire support
>> for is small.
> I wasn't aware of format(__NSString__) attribute, but it would
> clearly be beneficial to recognize format NSStrings based on it.
> Actually the NSLog() function seems to be the only function or
> method in AppKit & Foundation headers which uses this attribute.
> I've found several functions and methods which use format NSStrings
> and don't use the format(__NSString__) attribute: 12 functions in
> AppKit/NSPanel.h, 4 functions in CoreFoundation/CFString.h, 4
> methods in Foundation/NSException.h and 8 methods in Foundation/
> So hardcoding both function and method names seems inevitable.
> - Nikita
Agreed. Unfortunately, this kind of redundancy is necessary. Within
Apple I can file bug reports to get the headers fixed, but clearly
that only works for code going forward.
More information about the cfe-dev