The methods below from DDAbstractDatabaseLogger
of CocoaLumberjack :
- (void)createAndStartDeleteTimer
{
if ((deleteTimer == NULL) && (deleteInterval > 0.0) && (maxAge > 0.0))
{
deleteTimer = dispatch_source_create(DISPATCH_SOURCE_TYPE_TIMER, 0, 0, loggerQueue);
if (deleteTimer != NULL) {
dispatch_source_set_event_handler(deleteTimer, ^{ @autoreleasepool {
[self performDelete];
}});
[self updateDeleteTimer];
dispatch_resume(deleteTimer);
}
}
}
- (void)updateDeleteTimer
{
if ((deleteTimer != NULL) && (deleteInterval > 0.0) && (maxAge > 0.0))
{
uint64_t interval = (uint64_t)(deleteInterval * NSEC_PER_SEC);
dispatch_time_t startTime;
if (lastDeleteTime > 0)
startTime = dispatch_time(lastDeleteTime, interval);
else
startTime = dispatch_time(DISPATCH_TIME_NOW, interval);
dispatch_source_set_timer(deleteTimer, startTime, interval, 1.0);
}
}
Trigger a clang static analyzer warning:
CocoaLumberjack/Lumberjack/DDAbstractDatabaseLogger.m:207:13: Null pointer passed as an argument to a 'nonnull' parameter
Screenshot of the steps:
I looked in my build output and found the following plist:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>clang_version</key>
<string>Apple LLVM version 4.2 (clang-425.0.28) (based on LLVM 3.2svn)</string>
<key>files</key>
<array>
<string>CocoaLumberjack/Lumberjack/DDAbstractDatabaseLogger.m</string>
</array>
<key>diagnostics</key>
<array>
<dict>
<key>path</key>
<array>
<dict>
<key>kind</key><string>control</string>
<key>edges</key>
<array>
<dict>
<key>start</key>
<array>
<dict>
<key>line</key><integer>194</integer>
<key>col</key><integer>2</integer>
<key>file</key><integer>0</integer>
</dict>
<dict>
<key>line</key><integer>194</integer>
<key>col</key><integer>3</integer>
<key>file</key><integer>0</integer>
</dict>
</array>
<key>end</key>
<array>
<dict>
<key>line</key><integer>194</integer>
<key>col</key><integer>7</integer>
<key>file</key><integer>0</integer>
</dict>
<dict>
<key>line</key><integer>194</integer>
<key>col</key><integer>17</integer>
<key>file</key><integer>0</integer>
</dict>
</array>
</dict>
</array>
</dict>
<!-- Lots of the same style of line, col, file key-values in dicts and arrays -->
</array>
<key>description</key><string>Null pointer passed as an argument to a 'nonnull' parameter</string>
<key>category</key><string>API</string>
<key>type</key><string>Argument with 'nonnull' attribute passed null</string>
<key>issue_context_kind</key><string>Objective-C method</string>
<key>issue_context</key><string>createAndStartDeleteTimer</string>
<key>issue_hash</key><integer>14</integer>
<key>location</key>
<dict>
<key>line</key><integer>207</integer>
<key>col</key><integer>13</integer>
<key>file</key><integer>0</integer>
</dict>
</dict>
</array>
</dict>
</plist>
Is there any way to get the abstract values that the static analyzer thinks will cause a null pointer to be passed in? I can't figure it out.
可能已经晚了,但是对于可以看到的步骤,您可以运行独立的命令行scan-build实用程序,它使用相同的clang静态分析器,但向您展示了它触发警告的步骤
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.