From 361ff4ee94e0e43b84d4ae9f35744708e19233fc Mon Sep 17 00:00:00 2001 From: Jean-Charles Bertin Date: Fri, 11 Feb 2022 19:13:39 +0100 Subject: [PATCH 1/3] Check nullability violations for Debug target. --- Configs/Module-Debug.xcconfig | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Configs/Module-Debug.xcconfig b/Configs/Module-Debug.xcconfig index dd4e5682b..e50d1b275 100644 --- a/Configs/Module-Debug.xcconfig +++ b/Configs/Module-Debug.xcconfig @@ -23,6 +23,9 @@ ENABLE_NS_ASSERTIONS = YES // When this setting is activated, the product will be built with options appropriate for running automated tests, such as making private interfaces accessible to the tests. ENABLE_TESTABILITY = YES +// Check for violations of nullability annotations in function calls, return statements, and assignments. +CLANG_UNDEFINED_BEHAVIOR_SANITIZER_NULLABILITY = YES + // Specifies the degree to which the generated code is optimized for speed and binary size. GCC_OPTIMIZATION_LEVEL = 0 From ec997e8d613a829224056f2bad8b4066a00e1c36 Mon Sep 17 00:00:00 2001 From: Jean-Charles Bertin Date: Fri, 11 Feb 2022 19:14:04 +0100 Subject: [PATCH 2/3] Minor cleanup. --- Sources/CocoaLumberjack/DDFileLogger.m | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Sources/CocoaLumberjack/DDFileLogger.m b/Sources/CocoaLumberjack/DDFileLogger.m index b18931a73..78e6238cb 100644 --- a/Sources/CocoaLumberjack/DDFileLogger.m +++ b/Sources/CocoaLumberjack/DDFileLogger.m @@ -1081,6 +1081,9 @@ - (DDLogFileInfo *)lt_currentLogFileInfo { @"Invalid log file manager! Responds neither to `-createNewLogFileWithError:` nor `-createNewLogFile`!"); currentLogFilePath = [_logFileManager createNewLogFile]; #pragma clang diagnostic pop + if (!currentLogFilePath) { + NSLogError(@"DDFileLogger: Failed to create new log file"); + } } // Use static factory method here, since it checks for nil (and is unavailable to Swift). _currentLogFileInfo = [DDLogFileInfo logFileWithPath:currentLogFilePath]; From b248832933a2b62c11e6e7951c2cb872939b567a Mon Sep 17 00:00:00 2001 From: Jean-Charles Bertin Date: Fri, 11 Feb 2022 19:14:28 +0100 Subject: [PATCH 3/3] Fixed _currentLogFileInfo usage. --- Sources/CocoaLumberjack/DDFileLogger.m | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Sources/CocoaLumberjack/DDFileLogger.m b/Sources/CocoaLumberjack/DDFileLogger.m index 78e6238cb..1a78724fd 100644 --- a/Sources/CocoaLumberjack/DDFileLogger.m +++ b/Sources/CocoaLumberjack/DDFileLogger.m @@ -1328,6 +1328,8 @@ - (void)lt_logData:(NSData *)data { } @try { + NSFileHandle *handle = [self lt_currentLogFileHandle]; + if (implementsDeprecatedWillLog) { #pragma clang diagnostic push #pragma clang diagnostic ignored "-Wdeprecated-declarations" @@ -1337,7 +1339,6 @@ - (void)lt_logData:(NSData *)data { [self willLogMessage:_currentLogFileInfo]; } - NSFileHandle *handle = [self lt_currentLogFileHandle]; if (@available(macOS 10.15, iOS 13.0, tvOS 13.0, watchOS 6.0, *)) { __autoreleasing NSError *error = nil; BOOL success = [handle seekToEndReturningOffset:nil error:&error];