Fix several dozen warnings. Fix several things to actually respect the 10.9 minimum of the beta.

This commit is contained in:
Gwynne Raskind committed 2020-07-25 02:19:50 -05:00
1 parent e7f8161ae4
commit a95f1592cd
18 files changed
+58 -81

No files matched your search

+3 -3
View File
@@ -30,7 +30,7 @@ static void printUsage(NSString *programName)
fprintf(stderr, "%s version [<patch-file>]\n", [programName UTF8String]);
}
static BOOL runCreateCommand(NSString *programName, NSArray *args)
static BOOL runCreateCommand(NSString *programName, NSArray<NSString *> *args)
{
if (args.count < 3 || args.count > 5) {
printUsage(programName);
@@ -62,7 +62,7 @@ static BOOL runCreateCommand(NSString *programName, NSArray *args)
BOOL verbose = (verboseIndex != NSNotFound);
NSString *versionField = (versionIndex != NSNotFound) ? args[versionIndex] : nil;
NSArray *versionComponents = nil;
NSArray<NSString *> *versionComponents = nil;
if (versionField) {
versionComponents = [versionField componentsSeparatedByString:@"="];
if (versionComponents.count != 2) {
@@ -218,7 +218,7 @@ static BOOL runVersionCommand(NSString *programName, NSArray *args)
int main(int __unused argc, char __unused *argv[])
{
@autoreleasepool {
NSArray *args = [[NSProcessInfo processInfo] arguments];
NSArray<NSString *> *args = [[NSProcessInfo processInfo] arguments];
NSString *programName = [args[0] lastPathComponent];
if (args.count < 2) {
+1 -4
View File
@@ -88,11 +88,8 @@ GCC_WARN_UNUSED_LABEL = YES
GCC_WARN_UNUSED_PARAMETER = YES
GCC_WARN_UNUSED_VARIABLE = YES
// Fixes a strange issue where the compiler thinks references to some enums are ambiguous
CLANG_ENABLE_MODULES[sdk=macosx10.8] = NO
// These should be removed once the conversion to ARC is complete
WARNING_CFLAGS_EXTRA = -Wno-custom-atomic-properties -Wno-implicit-atomic-properties
// Turn on all warnings, then disable a few which are almost impossible to avoid
WARNING_CFLAGS = -Wall -Weverything -Wno-unused-macros -Wno-gnu-statement-expression -Wno-arc-repeated-use-of-weak -Wno-auto-import -Wno-gnu-zero-variadic-macro-arguments $(WARNING_CFLAGS_EXTRA)
WARNING_CFLAGS = -Wall -Weverything -Wno-unused-macros -Wno-gnu-statement-expression -Wno-arc-repeated-use-of-weak -Wno-auto-import -Wno-gnu-zero-variadic-macro-arguments -Wno-format-non-iso $(WARNING_CFLAGS_EXTRA)
+3 -3
View File
@@ -11,7 +11,7 @@
</sparkle:releaseNotesLink>
<pubDate>Wed, 09 Jan 2006 19:20:11 +0000</pubDate>
<enclosure url="http://you.com/app/Your%20Great%20App%202.0.zip" sparkle:version="2.0" length="1623481" type="application/octet-stream" sparkle:dsaSignature="BAFJW4B6B1K1JyW30nbkBwainOzrN6EQuAh" />
<sparkle:minimumSystemVersion>10.7</sparkle:minimumSystemVersion>
<sparkle:minimumSystemVersion>10.9</sparkle:minimumSystemVersion>
</item>
<item>
@@ -21,7 +21,7 @@
</sparkle:releaseNotesLink>
<pubDate>Wed, 01 Jan 2006 12:20:11 +0000</pubDate>
<enclosure url="http://you.com/app/Your%20Great%20App%201.5.zip" sparkle:version="1.5" length="1472893" type="application/octet-stream" sparkle:dsaSignature="234818feCa1JyW30nbkBwainOzrN6EQuAh" />
<sparkle:minimumSystemVersion>10.7</sparkle:minimumSystemVersion>
<sparkle:minimumSystemVersion>10.9</sparkle:minimumSystemVersion>
</item>
<!-- Now here's an example of a version with a weird internal version number (like an SVN revision) but a human-readable external one. -->
@@ -32,7 +32,7 @@
</sparkle:releaseNotesLink>
<pubDate>Wed, 25 Dec 2005 12:20:11 +0000</pubDate>
<enclosure url="http://you.com/app/Your%20Great%20App%201.4.zip" sparkle:version="241" sparkle:shortVersionString="1.4" sparkle:dsaSignature="MC0CFBfeCa1JyW30nbkBwainOzrN6EQuAh=" length="1472349" type="application/octet-stream" />
<sparkle:minimumSystemVersion>10.7</sparkle:minimumSystemVersion>
<sparkle:minimumSystemVersion>10.9</sparkle:minimumSystemVersion>
</item>
</channel>
</rss>
+1 -1
View File
@@ -18,7 +18,7 @@ Pod::Spec.new do |s|
'Andy Matuschak' => 'andy@andymatuschak.org',
}
s.platform = :osx, '10.7'
s.platform = :osx, '10.9'
s.source = { :http => "https://github.com/sparkle-project/Sparkle/releases/download/#{s.version}/Sparkle-#{s.version}.tar.bz2" }
s.source_files = 'Sparkle.framework/Versions/A/Headers/*.h'
+4 -4
View File
@@ -131,7 +131,7 @@
- (void)didFinishLoadingAppcast:(SUAppcast *)appcast
{
if (!self.aborted) {
if ([self.updaterDelegate respondsToSelector:@selector(updater:didFinishLoadingAppcast:)]) {
if ([self.updaterDelegate respondsToSelector:@selector((updater:didFinishLoadingAppcast:))]) {
[self.updaterDelegate updater:self.updater didFinishLoadingAppcast:appcast];
}
@@ -146,7 +146,7 @@
object:self.updater
userInfo:@{ SUUpdaterAppcastItemNotificationKey: updateItem }];
if ([self.updaterDelegate respondsToSelector:@selector(updater:didFindValidUpdate:)]) {
if ([self.updaterDelegate respondsToSelector:@selector((updater:didFindValidUpdate:))]) {
[self.updaterDelegate updater:self.updater didFindValidUpdate:updateItem];
}
@@ -157,7 +157,7 @@
- (void)didNotFindUpdate
{
if (!self.aborted) {
if ([self.updaterDelegate respondsToSelector:@selector(updaterDidNotFindUpdate:)]) {
if ([self.updaterDelegate respondsToSelector:@selector((updaterDidNotFindUpdate:))]) {
[self.updaterDelegate updaterDidNotFindUpdate:self.updater];
}
[[NSNotificationCenter defaultCenter] postNotificationName:SUUpdaterDidNotFindUpdateNotification object:self.updater];
@@ -189,7 +189,7 @@
}
// Notify host app that updater has aborted
if ([self.updaterDelegate respondsToSelector:@selector(updater:didAbortWithError:)]) {
if ([self.updaterDelegate respondsToSelector:@selector((updater:didAbortWithError:))]) {
[self.updaterDelegate updater:self.updater didAbortWithError:(NSError * _Nonnull)error];
}
}
+4 -4
View File
@@ -168,7 +168,7 @@
{
self.downloadDriver = [[SPUDownloadDriver alloc] initWithUpdateItem:updateItem host:self.host userAgent:self.userAgent inBackground:background delegate:self];
if ([self.updaterDelegate respondsToSelector:@selector(updater:willDownloadUpdate:withRequest:)]) {
if ([self.updaterDelegate respondsToSelector:@selector((updater:willDownloadUpdate:withRequest:))]) {
[self.updaterDelegate updater:self.updater
willDownloadUpdate:updateItem
withRequest:self.downloadDriver.request];
@@ -240,7 +240,7 @@
- (void)downloadDriverDidFailToDownloadUpdateWithError:(NSError *)error
{
if ([self.updaterDelegate respondsToSelector:@selector(updater:failedToDownloadUpdate:error:)]) {
if ([self.updaterDelegate respondsToSelector:@selector((updater:failedToDownloadUpdate:error:))]) {
NSError *errorToReport = [error.userInfo objectForKey:NSUnderlyingErrorKey];
if (errorToReport == nil) {
errorToReport = error;
@@ -290,13 +290,13 @@
- (void)installerWillFinishInstallationAndRelaunch:(BOOL)relaunch
{
if ([self.updaterDelegate respondsToSelector:@selector(updater:willInstallUpdate:)]) {
if ([self.updaterDelegate respondsToSelector:@selector((updater:willInstallUpdate:))]) {
[self.updaterDelegate updater:self.updater willInstallUpdate:self.updateItem];
}
if (relaunch) {
[[NSNotificationCenter defaultCenter] postNotificationName:SUUpdaterWillRestartNotification object:self];
if ([self.updaterDelegate respondsToSelector:@selector(updaterWillRelaunchApplication:)]) {
if ([self.updaterDelegate respondsToSelector:@selector((updaterWillRelaunchApplication:))]) {
[self.updaterDelegate updaterWillRelaunchApplication:self.updater];
}
}
+1 -1
View File
@@ -446,7 +446,7 @@
- (BOOL)mayUpdateAndRestart
{
return (!self.updaterDelegate || ![self.updaterDelegate respondsToSelector:@selector(updaterShouldRelaunchApplication:)] || [self.updaterDelegate updaterShouldRelaunchApplication:self.updater]);
return (!self.updaterDelegate || ![self.updaterDelegate respondsToSelector:@selector((updaterShouldRelaunchApplication:))] || [self.updaterDelegate updaterShouldRelaunchApplication:self.updater]);
}
// Only implemented due to backwards compability reasons; see -installWithToolAndRelaunch:displayingUserInterface: below
+1 -1
View File
@@ -189,7 +189,7 @@
break;
case SPUDownloadUpdateCanceled:
dispatch_async(dispatch_get_main_queue(), ^{
if ([self.updaterDelegate respondsToSelector:@selector(userDidCancelDownload:)]) {
if ([self.updaterDelegate respondsToSelector:@selector((userDidCancelDownload:))]) {
[self.updaterDelegate userDidCancelDownload:self.updater];
}
+7 -7
View File
@@ -267,7 +267,7 @@ NSString *const SUUpdaterAppcastNotificationKey = @"SUUpdaterAppCastNotification
shouldPrompt = NO;
}
// Does the delegate want to take care of the logic for when we should ask permission to update?
else if ([self.delegate respondsToSelector:@selector(updaterShouldPromptForPermissionToCheckForUpdates:)]) {
else if ([self.delegate respondsToSelector:@selector((updaterShouldPromptForPermissionToCheckForUpdates:))]) {
shouldPrompt = [self.delegate updaterShouldPromptForPermissionToCheckForUpdates:self];
}
// Has the user been asked already? And don't ask if the host has a default value set in its Info.plist.
@@ -283,7 +283,7 @@ NSString *const SUUpdaterAppcastNotificationKey = @"SUUpdaterAppCastNotification
if (shouldPrompt) {
NSArray<NSDictionary<NSString *, NSString *> *> *profileInfo = [SUSystemProfiler systemProfileArrayForHost:self.host];
// Always say we're sending the system profile here so that the delegate displays the parameters it would send.
if ([self.delegate respondsToSelector:@selector(feedParametersForUpdater:sendingSystemProfile:)]) {
if ([self.delegate respondsToSelector:@selector((feedParametersForUpdater:sendingSystemProfile:))]) {
NSArray *feedParameters = [self.delegate feedParametersForUpdater:self sendingSystemProfile:YES];
if (feedParameters != nil) {
profileInfo = [profileInfo arrayByAddingObjectsFromArray:feedParameters];
@@ -329,9 +329,9 @@ NSString *const SUUpdaterAppcastNotificationKey = @"SUUpdaterAppCastNotification
- (void)updateLastUpdateCheckDate
{
[self willChangeValueForKey:NSStringFromSelector(@selector(lastUpdateCheckDate))];
[self willChangeValueForKey:NSStringFromSelector(@selector((lastUpdateCheckDate)))];
[self.host setObject:[NSDate date] forUserDefaultsKey:SULastCheckTimeKey];
[self didChangeValueForKey:NSStringFromSelector(@selector(lastUpdateCheckDate))];
[self didChangeValueForKey:NSStringFromSelector(@selector((lastUpdateCheckDate)))];
}
- (void)scheduleNextUpdateCheck
@@ -512,7 +512,7 @@ NSString *const SUUpdaterAppcastNotificationKey = @"SUUpdaterAppCastNotification
[self updateLastUpdateCheckDate];
if( [self.delegate respondsToSelector: @selector(updaterMayCheckForUpdates:)] && ![self.delegate updaterMayCheckForUpdates:self] )
if( [self.delegate respondsToSelector: @selector((updaterMayCheckForUpdates:))] && ![self.delegate updaterMayCheckForUpdates:self] )
{
[self scheduleNextUpdateCheck];
return;
@@ -643,7 +643,7 @@ NSString *const SUUpdaterAppcastNotificationKey = @"SUUpdaterAppCastNotification
// A value in the user defaults overrides one in the Info.plist (so preferences panels can be created wherein users choose between beta / release feeds).
NSString *appcastString = [self.host objectForKey:SUFeedURLKey];
if ([self.delegate respondsToSelector:@selector(feedURLStringForUpdater:)]) {
if ([self.delegate respondsToSelector:@selector((feedURLStringForUpdater:))]) {
NSString *delegateAppcastString = [self.delegate feedURLStringForUpdater:self];
if (delegateAppcastString != nil) {
appcastString = delegateAppcastString;
@@ -740,7 +740,7 @@ static NSString *escapeURLComponent(NSString *str) {
sendingSystemProfile &= (-[lastSubmitDate timeIntervalSinceNow] >= oneWeek);
NSArray<NSDictionary<NSString *, NSString *> *> *parameters = @[];
if ([self.delegate respondsToSelector:@selector(feedParametersForUpdater:sendingSystemProfile:)]) {
if ([self.delegate respondsToSelector:@selector((feedParametersForUpdater:sendingSystemProfile:))]) {
NSArray *feedParameters = [self.delegate feedParametersForUpdater:self sendingSystemProfile:sendingSystemProfile];
if (feedParameters != nil) {
parameters = [parameters arrayByAddingObjectsFromArray:feedParameters];
+2 -2
View File
@@ -78,7 +78,7 @@
SUAppcastItem *nonDeltaUpdateItem = nil;
// Now we have to find the best valid update in the appcast.
if ([self.updaterDelegate respondsToSelector:@selector(bestValidUpdateInAppcast:forUpdater:)])
if ([self.updaterDelegate respondsToSelector:@selector((bestValidUpdateInAppcast:forUpdater:))])
{
item = [self.updaterDelegate bestValidUpdateInAppcast:ac forUpdater:(id _Nonnull)self.updater];
}
@@ -157,7 +157,7 @@
id<SUVersionComparison> comparator = nil;
// Give the delegate a chance to provide a custom version comparator
if ([self.updaterDelegate respondsToSelector:@selector(versionComparatorForUpdater:)]) {
if ([self.updaterDelegate respondsToSelector:@selector((versionComparatorForUpdater:))]) {
comparator = [self.updaterDelegate versionComparatorForUpdater:(id _Nonnull)self.updater];
}
+1 -1
View File
@@ -158,7 +158,7 @@ static BOOL SUMakeRefFromURL(NSURL *url, FSRef *ref, NSError **error) {
// Even if we fail removing the quarantine from the root item or any single item in the directory, we will continue trying to remove the quarantine.
// This is because often it may not be a fatal error from the caller to not remove the quarantine of an item
NSDictionary *rootAttributes = [_fileManager attributesOfItemAtPath:rootURLPath error:nil];
NSString *rootType = [rootAttributes objectForKey:NSFileType]; // 10.7 can't subscript this
NSString *rootType = rootAttributes[NSFileType];
if ([rootType isEqualToString:NSFileTypeDirectory]) {
// The NSDirectoryEnumerator will avoid recursing into any contained
+1 -1
View File
@@ -244,7 +244,7 @@
}
else
{
value = (BOOL)CFBooleanGetValue((CFBooleanRef)plr);
value = CFBooleanGetValue((CFBooleanRef)plr) ? YES : NO;
CFRelease(plr);
}
return value;
+1 -1
View File
@@ -140,7 +140,7 @@ static NSString * const UPDATED_VERSION = @"2.0";
ed25519_sign(signature, archive.bytes, archive.length, public_key, self_sign_demo_only_insecure_hack);
NSString *signatureString = [[NSData dataWithBytes:signature length:64] base64Encoding];
NSString *signatureString = [[NSData dataWithBytes:signature length:64] base64EncodedStringWithOptions:0];
// Obtain the file attributes to get the file size of our update later
NSError *fileAttributesError = nil;
+2 -2
View File
@@ -53,7 +53,7 @@ class ArchiveItem: CustomStringConvertible {
self.version = version
self._shortVersion = shortVersion
self.feedURL = feedURL
self.minimumSystemVersion = minimumSystemVersion ?? "10.7"
self.minimumSystemVersion = minimumSystemVersion ?? "10.9"
self.archivePath = archivePath
self.appPath = appPath
self.supportsDSA = supportsDSA
@@ -86,7 +86,7 @@ class ArchiveItem: CustomStringConvertible {
guard let infoPlist = NSDictionary(contentsOf: appPath.appendingPathComponent("Contents/Info.plist")) else {
throw makeError(code: .unarchivingError, "No plist \(appPath.path)")
}
guard let version = infoPlist[kCFBundleVersionKey] as? String else {
guard let version = infoPlist[kCFBundleVersionKey!] as? String else {
throw makeError(code: .unarchivingError, "No Version \(kCFBundleVersionKey as String? ?? "missing kCFBundleVersionKey") \(appPath)")
}
let shortVersion = infoPlist["CFBundleShortVersionString"] as? String
+6 -13
View File
@@ -98,17 +98,10 @@ func dsaSignature(path: URL, privateDSAKey: SecKey) throws -> String {
func edSignature(path: URL, publicEdKey: Data, privateEdKey: Data) throws -> String {
assert(publicEdKey.count == 32)
assert(privateEdKey.count == 64)
let data = try Data.init(contentsOf: path, options: .mappedIfSafe)
let len = data.count
var output = Data(count: 64)
output.withUnsafeMutableBytes({ (output: UnsafeMutablePointer<UInt8>) in
data.withUnsafeBytes({ (data: UnsafePointer<UInt8>) in
publicEdKey.withUnsafeBytes({ (publicEdKey: UnsafePointer<UInt8>) in
privateEdKey.withUnsafeBytes({ (privateEdKey: UnsafePointer<UInt8>) in
ed25519_sign(output, data, len, publicEdKey, privateEdKey)
})
})
})
})
return output.base64EncodedString()
let data = Array(try Data.init(contentsOf: path, options: .mappedIfSafe))
var output = Array<UInt8>(repeating: 0, count: 64)
let pubkey = Array(publicEdKey), privkey = Array(privateEdKey)
ed25519_sign(&output, data, data.count, pubkey, privkey)
return Data(output).base64EncodedString()
}
+2 -2
View File
@@ -59,8 +59,8 @@ func loadPrivateKeys(_ privateDSAKey: SecKey?, _ privateEdString: String?) -> Pr
kSecAttrService as String: "https://sparkle-project.org",
kSecAttrAccount as String: "ed25519",
kSecAttrProtocol as String: kSecAttrProtocolSSH,
kSecReturnData as String: kCFBooleanTrue,
] as CFDictionary, &item)
kSecReturnData as String: kCFBooleanTrue!,
] as CFDictionary, &item)
if res == errSecSuccess, let encoded = item as? Data, let data = Data(base64Encoded: encoded) {
keys = data
} else {
+11 -18
View File
@@ -17,7 +17,7 @@ func findPublicKey() -> Data? {
kSecAttrAccount as String: "ed25519",
kSecAttrProtocol as String: kSecAttrProtocolSSH,
// kSecAttrSynchronizableAny as String: kCFBooleanTrue,
kSecReturnData as String: kCFBooleanTrue,
kSecReturnData as String: kCFBooleanTrue!,
] as CFDictionary, &item)
if res == errSecSuccess, let encoded = item as? Data, let keys = Data(base64Encoded: encoded) {
@@ -39,24 +39,17 @@ func findPublicKey() -> Data? {
}
func generateKeyPair(makeSyncable: Bool) -> Data {
var seed = Data(count: 32)
var publicEdKey = Data(count: 32)
var privateEdKey = Data(count: 64)
var seed = Array<UInt8>(repeating: 0, count: 32)
var publicEdKey = Array<UInt8>(repeating: 0, count: 32)
var privateEdKey = Array<UInt8>(repeating: 0, count: 64)
if !seed.withUnsafeMutableBytes({ 0 == ed25519_create_seed($0) }) {
guard ed25519_create_seed(&seed) == 0 else {
print("\nERROR: Unable to initialize random seed")
exit(1)
}
ed25519_create_keypair(&publicEdKey, &privateEdKey, seed)
seed.withUnsafeBytes { seed in
publicEdKey.withUnsafeMutableBytes { publicEdKey in
privateEdKey.withUnsafeMutableBytes { privateEdKey in
ed25519_create_keypair(publicEdKey, privateEdKey, seed)
}
}
}
let bothKeys = privateEdKey + publicEdKey; // public key can't be derived from the private one
let bothKeys = Data(privateEdKey) + Data(publicEdKey); // public key can't be derived from the private one
let query = [
// macOS doesn't support ed25519 keys, so we're forced to save the key as a "password"
// and add some made-up service data for it to prevent it clashing with other passwords.
@@ -65,10 +58,10 @@ func generateKeyPair(makeSyncable: Bool) -> Data {
kSecAttrAccount as String: "ed25519",
kSecValueData as String: bothKeys.base64EncodedData() as CFData, // it's base64-encoded, because user may request to show it
kSecAttrIsSensitive as String: kCFBooleanTrue,
kSecAttrIsPermanent as String: kCFBooleanTrue,
kSecAttrIsSensitive as String: kCFBooleanTrue!,
kSecAttrIsPermanent as String: kCFBooleanTrue!,
kSecAttrLabel as String: "Private key for signing Sparkle updates",
kSecAttrComment as String: "Public key (SUPublicEDKey value) for this key is:\n\n\(publicEdKey.base64EncodedString())",
kSecAttrComment as String: "Public key (SUPublicEDKey value) for this key is:\n\n\(Data(publicEdKey).base64EncodedString())",
kSecAttrDescription as String: "private key",
// kSecAttrSynchronizable as String: (makeSyncable ? kCFBooleanTrue : kCFBooleanFalse)!,
@@ -78,7 +71,7 @@ func generateKeyPair(makeSyncable: Bool) -> Data {
if res == errSecSuccess {
// print("OK! A new key has been generated and saved in the Keychain.")
return publicEdKey
return Data(publicEdKey)
} else if res == errSecDuplicateItem {
print("\nERROR: You already have a previously generated key in the Keychain")
} else if res == errSecAuthFailed {
+7 -13
View File
@@ -16,7 +16,7 @@ func findKeys() -> (Data, Data) {
kSecAttrService as String: "https://sparkle-project.org",
kSecAttrAccount as String: "ed25519",
kSecAttrProtocol as String: kSecAttrProtocolSSH,
kSecReturnData as String: kCFBooleanTrue,
kSecReturnData as String: kCFBooleanTrue!,
] as CFDictionary, &item)
if res == errSecSuccess, let encoded = item as? Data, let keys = Data(base64Encoded: encoded) {
return (keys[0..<64], keys[64..<(64+32)])
@@ -38,18 +38,12 @@ func findKeys() -> (Data, Data) {
func edSignature(data: Data, publicEdKey: Data, privateEdKey: Data) -> String {
assert(publicEdKey.count == 32)
assert(privateEdKey.count == 64)
let len = data.count
var output = Data(count: 64)
output.withUnsafeMutableBytes({ (output: UnsafeMutablePointer<UInt8>) in
data.withUnsafeBytes({ (data: UnsafePointer<UInt8>) in
publicEdKey.withUnsafeBytes({ (publicEdKey: UnsafePointer<UInt8>) in
privateEdKey.withUnsafeBytes({ (privateEdKey: UnsafePointer<UInt8>) in
ed25519_sign(output, data, len, publicEdKey, privateEdKey)
})
})
})
})
return output.base64EncodedString()
let data = Array(data)
var output = Array<UInt8>(repeating: 0, count: 64)
let pubkey = Array(publicEdKey), privkey = Array(privateEdKey)
ed25519_sign(&output, data, data.count, pubkey, privkey)
return Data(output).base64EncodedString()
}
let args = CommandLine.arguments