CocoaLumberjack的DDAbstractDatabaseLogger
以下方法:
- (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);
}
}
触发clang静态分析器警告:
CocoaLumberjack/Lumberjack/DDAbstractDatabaseLogger.m:207:13: Null pointer passed as an argument to a 'nonnull' parameter
步骤的屏幕截图:
我查看了我的构建输出并找到了以下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>
有没有办法得到静态分析器认为会导致空指针传入的抽象值?我无法理解。