Return nil instead of NO. Fixes: error: initialization of pointer of type 'ArrayNode *' to null from a constant boolean expression [-Werror,-Wbool-conversion] https://github.com/arqbackup/arq_restore/commit/0f0c956e1636ee501369cc04f59f2075b709e0e3 --- ArqRestoreCommand.m.orig +++ ArqRestoreCommand.m @@ -610,7 +610,7 @@ - (BOOL)clearCache:(NSArray *)args error:(NSError **)error { - (BackupSet *)backupSetForTarget:(Target *)theInitialTarget computerUUID:(NSString *)theComputerUUID error:(NSError **)error { NSArray *expandedTargetList = [self expandedTargetListForTarget:theInitialTarget error:error]; if (expandedTargetList == nil) { - return NO; + return nil; } for (Target *theTarget in expandedTargetList) { @@ -622,7 +622,7 @@ - (BackupSet *)backupSetForTarget:(Target *)theInitialTarget computerUUID:(NSStr } else { HSLogError(@"error getting backup sets for %@: %@", theTarget, myError); SETERRORFROMMYERROR; - return NO; + return nil; } } else { for (BackupSet *backupSet in backupSets) { --- cocoastack/crypto/SHA1Hash.m.orig +++ cocoastack/crypto/SHA1Hash.m @@ -68,7 +68,7 @@ + (NSString *)hashFile:(NSString *)path error:(NSError **)error { int errnum = errno; HSLogError(@"lstat(%@) error %d: %s", path, errnum, strerror(errnum)); SETNSERROR(@"UnixErrorDomain", errnum, @"%@: %s", path, strerror(errnum)); - return NO; + return nil; } unsigned long long length = (unsigned long long)st.st_size; FileInputStream *fis = [[FileInputStream alloc] initWithPath:path offset:0 length:length]; --- cocoastack/plist/XMLPListReader.m.orig +++ cocoastack/plist/XMLPListReader.m @@ -109,7 +109,7 @@ - (ArrayNode *)readArray:(NSXMLNode *)elem error:(NSError **)error { id node = [self makeNode:childNode error:error]; if (!node) { [nodes release]; - return NO; + return nil; } [nodes addObject:node]; } @@ -134,7 +134,7 @@ - (DictNode *)readDict:(NSXMLNode *)elem error:(NSError **)error { } else { id node = [self makeNode:childNode error:error]; if (!node) { - return NO; + return nil; } NSAssert(key != nil, @"must have key before adding value"); [dn put:node forKey:key]; --- cocoastack/remotefs/LocalItemFS.m.orig +++ cocoastack/remotefs/LocalItemFS.m @@ -161,7 +161,7 @@ - (Item *)createDirectoryWithName:(NSString *)theName inDirectoryItem:(Item *)th int errnum = errno; HSLogError(@"chown(%@) error %d: %s", thePath, errnum, strerror(errnum)); SETNSERROR(@"UnixErrorDomain", errnum, @"failed to change ownership of %@: %s", thePath, strerror(errnum)); - return NO; + return nil; } } @@ -200,14 +200,14 @@ - (Item *)createFileWithData:(NSData *)theData name:(NSString *)theName inDirect if (![self ensureTempDirExists:&myError]) { SETERRORFROMMYERROR; HSLogError(@"error ensuring temp dir %@ exists: %@", tempDir, myError); - return NO; + return nil; } NSString *tempPath = [tempDir stringByAppendingPathComponent:[NSString stringWithRandomUUID]]; if (![theData writeToFile:tempPath options:NSAtomicWrite error:&myError]) { SETERRORFROMMYERROR; HSLogError(@"error creating temp file %@: %@", tempPath, myError); - return NO; + return nil; } if (![[NSFileManager defaultManager] ensureParentPathExistsForPath:theFullPath targetUID:[[CacheOwnership sharedCacheOwnership] uid] targetGID:[[CacheOwnership sharedCacheOwnership] gid] error:error]) { @@ -217,21 +217,21 @@ - (Item *)createFileWithData:(NSData *)theData name:(NSString *)theName inDirect if (![myError isErrorWithDomain:NSCocoaErrorDomain code:NSFileWriteFileExistsError]) { SETERRORFROMMYERROR; HSLogError(@"error renaming %@ to %@: %@", tempPath, theFullPath, myError); - return NO; + return nil; } // Delete the file that's in the way. HSLogDebug(@"deleting existing file before overwriting: %@", theFullPath); if (![[NSFileManager defaultManager] removeItemAtPath:theFullPath error:&myError]) { SETERRORFROMMYERROR; HSLogError(@"error removing a file that's in the way (%@): %@", theFullPath, myError); - return NO; + return nil; } // Try again. if (![[NSFileManager defaultManager] moveItemAtPath:tempPath toPath:theFullPath error:&myError]) { if (![myError isErrorWithDomain:NSCocoaErrorDomain code:NSFileWriteFileExistsError]) { SETERRORFROMMYERROR; HSLogError(@"error renaming %@ to %@: %@", tempPath, theFullPath, myError); - return NO; + return nil; } } } @@ -246,7 +246,7 @@ - (Item *)createFileWithData:(NSData *)theData name:(NSString *)theName inDirect int errnum = errno; HSLogError(@"chown(%@) error %d: %s", theFullPath, errnum, strerror(errnum)); SETNSERROR(@"UnixErrorDomain", errnum, @"failed to change ownership of %@: %s", theFullPath, strerror(errnum)); - return NO; + return nil; } } Item *item = [[[Item alloc] init] autorelease]; --- cocoastack/s3/S3Lister.m.orig +++ cocoastack/s3/S3Lister.m @@ -237,14 +237,14 @@ - (NSArray *)parseXMLResponse:(NSData *)response foundPrefixes:(NSArray **)found if (!xmlDoc) { HSLogDebug(@"list Objects XML data: %@", [[[NSString alloc] initWithData:response encoding:NSUTF8StringEncoding] autorelease]); SETNSERROR([S3Service errorDomain], [myError code], @"error parsing List Objects XML response: %@", myError); - return NO; + return nil; } NSXMLElement *rootElement = [xmlDoc rootElement]; NSArray *isTruncatedNodes = [rootElement nodesForXPath:@"//ListBucketResult/IsTruncated" error:&myError]; if (isTruncatedNodes == nil) { HSLogError(@"nodesForXPath: %@", myError); SETERRORFROMMYERROR; - return NO; + return nil; } if ([isTruncatedNodes count] == 0) { isTruncated = NO; @@ -256,7 +256,7 @@ - (NSArray *)parseXMLResponse:(NSData *)response foundPrefixes:(NSArray **)found if (error != NULL) { HSLogError(@"error getting //ListBucketResult/CommonPrefixes/Prefix nodes: %@", *error); } - return NO; + return nil; } NSMutableArray *theFoundPrefixes = [NSMutableArray array]; for (NSXMLNode *prefixNode in prefixNodes) { --- cocoastack/shared/LZ4Compressor.m.orig +++ cocoastack/shared/LZ4Compressor.m @@ -67,7 +67,7 @@ - (NSData *)lz4Inflate:(NSData *)data error:(NSError **)error { - (NSData *)lockedLZ4Deflate:(NSData *)data error:(NSError **)error { if ([data length] > (NSUInteger)INT_MAX) { SETNSERROR([self errorDomain], -1, @"length larger than INT_MAX"); - return NO; + return nil; } int originalSize = (int)[data length]; @@ -83,7 +83,7 @@ - (NSData *)lockedLZ4Deflate:(NSData *)data error:(NSError **)error { if (compressed == 0) { SETNSERROR([self errorDomain], -1, @"LZ4_compress_default failed"); free(outBuf); - return NO; + return nil; } uint32_t nboSize = OSSwapHostToBigInt32(originalSize); memcpy(outBuf, &nboSize, 4); --- glacierrestore/GlacierPackIndex.m.orig +++ glacierrestore/GlacierPackIndex.m @@ -327,7 +327,7 @@ - (PackIndexEntry *)doEntryForSHA1:(NSString *)sha1 error:(NSError **)error { close(fd); if (endIndex == 0) { SETNSERROR(@"PacksErrorDomain", ERROR_NOT_FOUND, @"sha1 %@ not found in pack", sha1); - return NO; + return nil; } fd = open([localPath fileSystemRepresentation], O_RDONLY); if (fd == -1) { @@ -352,7 +352,7 @@ - (PackIndexEntry *)findEntryForSHA1:(NSString *)sha1 fd:(int)fd betweenStartInd int errnum = errno; HSLogError(@"mmap(%@) error %d: %s", localPath, errnum, strerror(errnum)); SETNSERROR(@"UnixErrorDomain", errnum, @"error mapping %@ to memory: %s", localPath, strerror(errnum)); - return NO; + return nil; } int64_t left = startIndex; int64_t right = endIndex - 1; --- glacierrestore/GlacierPackSet.m.orig +++ glacierrestore/GlacierPackSet.m @@ -102,7 +102,7 @@ - (GlacierPackIndex *)glacierPackIndexForObjectSHA1:(NSString *)theObjectSHA1 ta } - (PackIndexEntry *)packIndexEntryForObjectSHA1:(NSString *)theSHA1 targetConnectionDelegate:(id )theTCD error:(NSError **)error { if (!loadedPIEs && ![self loadPackIndexEntriesWithTargetConnectionDelegate:theTCD error:error]) { - return NO; + return nil; } PackIndexEntry *ret = [packIndexEntriesByObjectSHA1 objectForKey:theSHA1]; if (ret == nil) { --- glacierrestore/GlacierRestorer.m.orig +++ glacierrestore/GlacierRestorer.m @@ -922,12 +922,12 @@ - (NSString *)completedJobIdForArchiveId:(NSString *)theArchiveId error:(NSError if ([[NSFileManager defaultManager] fileExistsAtPath:statusPath]) { NSDictionary *attribs = [[NSFileManager defaultManager] attributesOfItemAtPath:statusPath error:error]; if (attribs == nil) { - return NO; + return nil; } if ([[attribs objectForKey:NSFileSize] unsignedLongLongValue] > 0) { NSData *jobIdData = [NSData dataWithContentsOfFile:statusPath options:NSUncachedRead error:error]; if (jobIdData == nil) { - return NO; + return nil; } ret = [[[NSString alloc] initWithData:jobIdData encoding:NSUTF8StringEncoding] autorelease]; } --- repo/ObjectEncryptorV1.m.orig +++ repo/ObjectEncryptorV1.m @@ -141,7 +141,7 @@ - (NSString *)sha1HashForV2Data:(NSData *)theData { } - (NSData *)v2EncryptedObjectFromData:(NSData *)theData masterIV:(NSData *)theMasterIV dataIVAndSymmetricKey:(NSData *)theDataIVAndSymmetricKey error:(NSError **)error { SETNSERROR(@"ObjectEncryptorV1", -1, @"writeV2EncryptedObjectFromData not supported"); - return NO; + return nil; } // //- (NSString *)sha1HashForData:(NSData *)theData error:(NSError **)error { --- repo/ObjectEncryptorV2.m.orig +++ repo/ObjectEncryptorV2.m @@ -137,7 +137,7 @@ - (BOOL)ensureDatFileExistsAtTargetWithEncryptionPassword:(NSString *)theEncrypt } - (NSData *)encryptV1Data:(NSData *)theData error:(NSError **)error { SETNSERROR(@"ObjectEncryptorV2ErrorDomain", -1, @"encryptV1Data not supported"); - return NO; + return nil; } - (NSString *)sha1HashForV2Data:(NSData *)theData { // Calculate SHA1 hash of computerUUID+plaintext. @@ -157,7 +157,7 @@ - (NSData *)v2EncryptedObjectFromData:(NSData *)theData masterIV:(NSData *)theMa if (theDataIVAndSymmetricKey != nil) { if ([theDataIVAndSymmetricKey length] < DATA_IV_AND_SYMMETRIC_KEY_LEN) { SETNSERROR([ObjectEncryptor errorDomain], -1, @"given dataIVAndSymmetricKey is less than %d bytes", DATA_IV_AND_SYMMETRIC_KEY_LEN); - return NO; + return nil; } memcpy(dataIVAndSymmetricKey, [theDataIVAndSymmetricKey bytes], DATA_IV_AND_SYMMETRIC_KEY_LEN); memcpy(mySymmetricKey, [theDataIVAndSymmetricKey bytes] + IV_LEN, SYMMETRIC_KEY_LEN); @@ -202,7 +202,7 @@ - (NSData *)v2EncryptedObjectFromData:(NSData *)theData masterIV:(NSData *)theMa if (status != kCCSuccess) { SETNSERROR([ObjectEncryptor errorDomain], -1, @"encrypt: %@", [self errorMessageForStatus:status]); free(outbuf); - return NO; + return nil; } // Reset theOutBuffer's length. @@ -213,7 +213,7 @@ - (NSData *)v2EncryptedObjectFromData:(NSData *)theData masterIV:(NSData *)theMa if ([theMasterIV length] != IV_LEN) { SETNSERROR([ObjectEncryptor errorDomain], -1, @"invalid masterIV length"); free(outbuf); - return NO; + return nil; } memcpy(masterIV, [theMasterIV bytes], IV_LEN); } else { @@ -241,12 +241,12 @@ - (NSData *)v2EncryptedObjectFromData:(NSData *)theData masterIV:(NSData *)theMa if (status != kCCSuccess) { SETNSERROR([ObjectEncryptor errorDomain], -1, @"encrypt: %@", [self errorMessageForStatus:status]); free(outbuf); - return NO; + return nil; } if (encryptedMetadataActualLen != ENCRYPTED_DATA_IV_AND_SYMMETRIC_KEY_LEN) { SETNSERROR([ObjectEncryptor errorDomain], -1, @"unexpected encrypted metadata length"); free(outbuf); - return NO; + return nil; } // Calculate HMACSHA256 of (master IV + encryptedMetadata + ciphertext) using second half of master key. --- repo/PackSet.m.orig +++ repo/PackSet.m @@ -301,7 +301,7 @@ - (BOOL)restorePackForBlobWithSHA1:(NSString *)theSHA1 forDays:(NSUInteger)theDa - (NSNumber *)isObjectDownloadableForSHA1:(NSString *)theSHA1 error:(NSError **)error { PackIndexEntry *pie = [self packIndexEntryForSHA1:theSHA1 error:error]; if (pie == nil) { - return NO; + return nil; } return [fark isPackDownloadableWithId:[pie packId] storageType:storageType error:error]; } --- repo/PackSetDB.m.orig +++ repo/PackSetDB.m @@ -387,7 +387,7 @@ - (FMDatabaseQueue *)initDB:(NSError **)error { FlockFile *ff = [[[FlockFile alloc] initWithPath:lockFilePath] autorelease]; __block FMDatabaseQueue *ret = nil; if (![ff lockAndExecute:^void() { ret = [self lockedInitDB:error]; } error:error]) { - ret = NO; + ret = nil; } return ret; }