From 6be85c4a95e4666d3d0a20b8393e8ddb6ee54f6e Mon Sep 17 00:00:00 2001 From: Kilian Hofmann Date: Sun, 6 May 2018 23:06:21 +0200 Subject: [PATCH] Error and Warning Free Pure Swift 4 --- Docsis Toolkit.xcodeproj/project.pbxproj | 6 +++- .../xcshareddata/IDEWorkspaceChecks.plist | 8 +++++ .../xcshareddata/xcschemes/All.xcscheme | 4 +-- .../xcschemes/Converter.xcscheme | 4 +-- .../xcschemes/Graphic Analysis 2.xcscheme | 4 +-- .../xcschemes/Logger4.xcscheme | 4 +-- FileOperations.swift | 32 +++++++++---------- Graphic Analysis 2/FrequencyGraph.swift | 6 ++-- Graphic Analysis 2/GraphLoadOperation.swift | 2 +- Graphic Analysis 2/Info.plist | 2 +- Graphic Analysis 2/buildnum.ver | 2 +- 11 files changed, 39 insertions(+), 35 deletions(-) create mode 100644 Docsis Toolkit.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist diff --git a/Docsis Toolkit.xcodeproj/project.pbxproj b/Docsis Toolkit.xcodeproj/project.pbxproj index f2307f7..03b135e 100644 --- a/Docsis Toolkit.xcodeproj/project.pbxproj +++ b/Docsis Toolkit.xcodeproj/project.pbxproj @@ -577,7 +577,7 @@ isa = PBXProject; attributes = { LastSwiftUpdateCheck = 0830; - LastUpgradeCheck = 0900; + LastUpgradeCheck = 0930; ORGANIZATIONNAME = "Kilian Hofmann"; TargetAttributes = { E220BF9B1EFB22D400DF5A97 = { @@ -793,6 +793,7 @@ CLANG_WARN_BOOL_CONVERSION = YES; CLANG_WARN_COMMA = YES; CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; CLANG_WARN_DOCUMENTATION_COMMENTS = YES; CLANG_WARN_EMPTY_BODY = YES; @@ -800,6 +801,7 @@ CLANG_WARN_INFINITE_RECURSION = YES; CLANG_WARN_INT_CONVERSION = YES; CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; @@ -851,6 +853,7 @@ CLANG_WARN_BOOL_CONVERSION = YES; CLANG_WARN_COMMA = YES; CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; CLANG_WARN_DOCUMENTATION_COMMENTS = YES; CLANG_WARN_EMPTY_BODY = YES; @@ -858,6 +861,7 @@ CLANG_WARN_INFINITE_RECURSION = YES; CLANG_WARN_INT_CONVERSION = YES; CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; diff --git a/Docsis Toolkit.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/Docsis Toolkit.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist new file mode 100644 index 0000000..18d9810 --- /dev/null +++ b/Docsis Toolkit.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist @@ -0,0 +1,8 @@ + + + + + IDEDidComputeMac32BitWarning + + + diff --git a/Docsis Toolkit.xcodeproj/xcshareddata/xcschemes/All.xcscheme b/Docsis Toolkit.xcodeproj/xcshareddata/xcschemes/All.xcscheme index d330ab3..c92d46e 100644 --- a/Docsis Toolkit.xcodeproj/xcshareddata/xcschemes/All.xcscheme +++ b/Docsis Toolkit.xcodeproj/xcshareddata/xcschemes/All.xcscheme @@ -1,6 +1,6 @@ @@ -74,7 +73,6 @@ buildConfiguration = "Debug" selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB" selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB" - language = "" launchStyle = "0" useCustomWorkingDirectory = "NO" ignoresPersistentStateOnLaunch = "NO" diff --git a/Docsis Toolkit.xcodeproj/xcuserdata/Kili2.xcuserdatad/xcschemes/Converter.xcscheme b/Docsis Toolkit.xcodeproj/xcuserdata/Kili2.xcuserdatad/xcschemes/Converter.xcscheme index 93f24e7..768cbd6 100644 --- a/Docsis Toolkit.xcodeproj/xcuserdata/Kili2.xcuserdatad/xcschemes/Converter.xcscheme +++ b/Docsis Toolkit.xcodeproj/xcuserdata/Kili2.xcuserdatad/xcschemes/Converter.xcscheme @@ -1,6 +1,6 @@ @@ -46,7 +45,6 @@ buildConfiguration = "Debug" selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB" selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB" - language = "" launchStyle = "0" useCustomWorkingDirectory = "NO" ignoresPersistentStateOnLaunch = "NO" diff --git a/Docsis Toolkit.xcodeproj/xcuserdata/Kili2.xcuserdatad/xcschemes/Graphic Analysis 2.xcscheme b/Docsis Toolkit.xcodeproj/xcuserdata/Kili2.xcuserdatad/xcschemes/Graphic Analysis 2.xcscheme index 0ab7997..a228886 100644 --- a/Docsis Toolkit.xcodeproj/xcuserdata/Kili2.xcuserdatad/xcschemes/Graphic Analysis 2.xcscheme +++ b/Docsis Toolkit.xcodeproj/xcuserdata/Kili2.xcuserdatad/xcschemes/Graphic Analysis 2.xcscheme @@ -1,6 +1,6 @@ @@ -46,7 +45,6 @@ buildConfiguration = "Debug" selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB" selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB" - language = "" launchStyle = "0" useCustomWorkingDirectory = "NO" ignoresPersistentStateOnLaunch = "NO" diff --git a/Docsis Toolkit.xcodeproj/xcuserdata/Kili2.xcuserdatad/xcschemes/Logger4.xcscheme b/Docsis Toolkit.xcodeproj/xcuserdata/Kili2.xcuserdatad/xcschemes/Logger4.xcscheme index 0b6f33e..4a7f3a9 100644 --- a/Docsis Toolkit.xcodeproj/xcuserdata/Kili2.xcuserdatad/xcschemes/Logger4.xcscheme +++ b/Docsis Toolkit.xcodeproj/xcuserdata/Kili2.xcuserdatad/xcschemes/Logger4.xcscheme @@ -1,6 +1,6 @@ @@ -46,7 +45,6 @@ buildConfiguration = "Debug" selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB" selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB" - language = "" launchStyle = "0" useCustomWorkingDirectory = "NO" ignoresPersistentStateOnLaunch = "NO" diff --git a/FileOperations.swift b/FileOperations.swift index c6ec9c5..f43f9d6 100644 --- a/FileOperations.swift +++ b/FileOperations.swift @@ -37,7 +37,7 @@ class FileOperations: NSObject { static func log(data: String, toLog path: String) { let dataToWrite = encodeTimeStamp(stamp: data, threshold: "") - let file: UnsafeMutableRawPointer = UnsafeMutableRawPointer.allocate(bytes: 3, alignedTo: 1) + let file: UnsafeMutableRawPointer = UnsafeMutableRawPointer.allocate(byteCount: 3, alignment: 1) file.storeBytes(of: dataToWrite, as: UInt32.self) do { let fileData: NSMutableData = try NSMutableData(contentsOf: URL(fileURLWithPath: path)) @@ -48,27 +48,27 @@ class FileOperations: NSObject { fileData.append(file, length: 3) fileData.write(to: URL(fileURLWithPath: path), atomically: true) } - file.deallocate(bytes: 3, alignedTo: 1) + file.deallocate() } static func log(data: String, toData out: inout Data) { let dataToWrite = encodeTimeStamp(stamp: data, threshold: "") - let file: UnsafeMutableRawPointer = UnsafeMutableRawPointer.allocate(bytes: 3, alignedTo: 1) + let file: UnsafeMutableRawPointer = UnsafeMutableRawPointer.allocate(byteCount: 3, alignment: 1) file.storeBytes(of: dataToWrite, as: UInt32.self) let fileData: NSMutableData = NSMutableData() fileData.append(file, length: 3) out.append(fileData as Data) - file.deallocate(bytes: 3, alignedTo: 1) + file.deallocate() } static func load(log Data: NSData) -> [String]? { var returnString: [String] = [] var i: Int = 0 while i < Data.length { - let data: UnsafeMutableRawPointer = UnsafeMutableRawPointer.allocate(bytes: 3, alignedTo: 1) + let data: UnsafeMutableRawPointer = UnsafeMutableRawPointer.allocate(byteCount: 3, alignment: 1) Data.getBytes(data, range: NSRange(location: i, length: 3)) returnString.append("\(decodeTimestamp(stamp: data.load(as: UInt32.self)).0)\n") - data.deallocate(bytes: 3, alignedTo: 1) + data.deallocate() i += 3 } if returnString.count > 0 { @@ -181,29 +181,29 @@ class FileOperations: NSObject { let decodedSize: UInt8 = data.bytes.load(fromByteOffset: variableAdjust, as: UInt8.self) variableAdjust += 1 - let retTimePtr: UnsafeMutableRawPointer = UnsafeMutableRawPointer.allocate(bytes: 3, alignedTo: 1) + let retTimePtr: UnsafeMutableRawPointer = UnsafeMutableRawPointer.allocate(byteCount: 3, alignment: 1) data.getBytes(retTimePtr, range: NSRange(location: variableAdjust, length: 3)) variableAdjust += 3 let encodedTime: UInt32 = retTimePtr.load(as: UInt32.self) - retTimePtr.deallocate(bytes: 3, alignedTo: 1) + retTimePtr.deallocate() let decodedTimeStamp = decodeTimestamp(stamp: encodedTime).0 let decodedThreshold = decodeTimestamp(stamp: encodedTime).1 - let retPwrPtr: UnsafeMutableRawPointer = UnsafeMutableRawPointer.allocate(bytes: 4, alignedTo: 1) + let retPwrPtr: UnsafeMutableRawPointer = UnsafeMutableRawPointer.allocate(byteCount: 4, alignment: 1) data.getBytes(retPwrPtr, range: NSRange(location: variableAdjust, length: 4)) var decodedPower: Any = retPwrPtr.load(as: Int32.self) - retPwrPtr.deallocate(bytes: 4, alignedTo: 1) + retPwrPtr.deallocate() if decodedPower as! Int32 == Int32.min { decodedPower = "-" } variableAdjust += 4 - let retStringPtr: UnsafeMutableRawPointer = UnsafeMutableRawPointer.allocate(bytes: Int(decodedSize), alignedTo: 1) + let retStringPtr: UnsafeMutableRawPointer = UnsafeMutableRawPointer.allocate(byteCount: Int(decodedSize), alignment: 1) data.getBytes(retStringPtr, range: NSRange(location: variableAdjust, length: Int(decodedSize))) var retString: String = String(cString: retStringPtr.assumingMemoryBound(to: UInt8.self)) - retStringPtr.deallocate(bytes: Int(decodedSize), alignedTo: 1) - retString = retString.substring(to: retString.index(retString.startIndex, offsetBy: Int(decodedSize))) + retStringPtr.deallocate() + retString = String(retString[..CFBundleShortVersionString 2.1 CFBundleVersion - 491 + 493 LSApplicationCategoryType public.app-category.utilities LSMinimumSystemVersion diff --git a/Graphic Analysis 2/buildnum.ver b/Graphic Analysis 2/buildnum.ver index 02fa561..750451b 100644 --- a/Graphic Analysis 2/buildnum.ver +++ b/Graphic Analysis 2/buildnum.ver @@ -1,2 +1,2 @@ version 2.1 -build 491 +build 493