aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--AddressBook/GTMABAddressBook.m8
-rw-r--r--Foundation/GTMAbstractDOListenerTest.m11
-rw-r--r--Foundation/GTMLightweightProxyTest.m4
-rw-r--r--Foundation/GTMLoggerTest.m13
-rw-r--r--Foundation/GTMNSAppleEventDescriptor+Handler.h11
-rw-r--r--Foundation/GTMNSDictionary+CaseInsensitive.h4
-rw-r--r--Foundation/GTMNSNumber+64Bit.h6
-rw-r--r--Foundation/GTMNSObject+KeyValueObserving.m2
-rw-r--r--Foundation/GTMNSObject+KeyValueObservingTest.m5
-rw-r--r--Foundation/GTMServiceManagement.c2
-rw-r--r--Foundation/GTMServiceManagement.h2
-rw-r--r--Foundation/GTMServiceManagementTest.m2
-rw-r--r--Foundation/GTMServiceManagementTestingHarness.c4
-rw-r--r--Foundation/GTMStackTrace.m8
-rw-r--r--Foundation/GTMTransientRootProxyTest.m9
-rw-r--r--Foundation/GTMValidatingContainers.m7
-rw-r--r--GTMDefines.h24
-rw-r--r--UnitTesting/GTMUnitTestingTest.m1
18 files changed, 85 insertions, 38 deletions
diff --git a/AddressBook/GTMABAddressBook.m b/AddressBook/GTMABAddressBook.m
index 637494b..6aa55e4 100644
--- a/AddressBook/GTMABAddressBook.m
+++ b/AddressBook/GTMABAddressBook.m
@@ -523,10 +523,10 @@ typedef struct {
#else // GTM_IPHONE_SDK
bool wasGood = YES;
if (data) {
- wasGood = [[[NSImage alloc] initWithData:data] autorelease] != nil;
+ NSImage *image = [[[NSImage alloc] initWithData:data] autorelease];
+ wasGood = image != nil;
}
- wasGood = wasGood && ABPersonSetImageData([self recordRef],
- (CFDataRef)data);
+ wasGood = wasGood && ABPersonSetImageData([self recordRef], (CFDataRef)data);
#endif // GTM_IPHONE_SDK
return wasGood ? YES : NO;
}
@@ -862,7 +862,9 @@ typedef struct {
// GTMABAddressBookTest.m
// Also, search for 6208390 below and fix the fast enumerator to actually
// be somewhat performant when this is fixed.
+#ifndef __clang_analyzer__
[value retain];
+#endif // __clang_analyzer__
}
}
return value;
diff --git a/Foundation/GTMAbstractDOListenerTest.m b/Foundation/GTMAbstractDOListenerTest.m
index 895af4a..2cb4557 100644
--- a/Foundation/GTMAbstractDOListenerTest.m
+++ b/Foundation/GTMAbstractDOListenerTest.m
@@ -98,10 +98,13 @@ enum {
@implementation TestClient
- (id)initWithName:(NSString *)name {
- serverName_ = [[NSString alloc] initWithString:name];
- if (!serverName_) {
- [self release];
- self = nil;
+ self = [super init];
+ if (self) {
+ serverName_ = [[NSString alloc] initWithString:name];
+ if (!serverName_) {
+ [self release];
+ self = nil;
+ }
}
return self;
}
diff --git a/Foundation/GTMLightweightProxyTest.m b/Foundation/GTMLightweightProxyTest.m
index 3309484..03a1979 100644
--- a/Foundation/GTMLightweightProxyTest.m
+++ b/Foundation/GTMLightweightProxyTest.m
@@ -19,6 +19,10 @@
#import "GTMSenTestCase.h"
#import "GTMLightweightProxy.h"
+@interface GTMLightweightProxy (GTMLightweightProxyTest)
+- (id)init;
+@end
+
@interface GTMLightweightProxyTest : GTMTestCase
- (BOOL)returnYes;
@end
diff --git a/Foundation/GTMLoggerTest.m b/Foundation/GTMLoggerTest.m
index de89f8d..fe76194 100644
--- a/Foundation/GTMLoggerTest.m
+++ b/Foundation/GTMLoggerTest.m
@@ -417,15 +417,10 @@
NSString * kFormatBasePattern;
#if GTM_MACOS_SDK
- if ([GTMSystemVersion isSnowLeopardOrGreater]) {
- // E.g. 2009-10-26 22:26:25.086 otest-i386[53200/0xa0438500] [lvl=1] (no func) test
- kFormatBasePattern =
- @"[0-9]{4}-[0-9]{2}-[0-9]{2} [0-9]{2}:[0-9]{2}:[0-9]{2}\\.[0-9]{3} ((otest-i386)|(otest-x86_64)|(otest-ppc))\\[[0-9]+/0x[0-9a-f]+\\] \\[lvl=[0-3]\\] \\(unknown\\) ";
- } else {
- // E.g. 2008-01-04 09:16:26.906 otest[5567/0xa07d0f60] [lvl=1] (no func) test
- kFormatBasePattern =
- @"[0-9]{4}-[0-9]{2}-[0-9]{2} [0-9]{2}:[0-9]{2}:[0-9]{2}\\.[0-9]{3} (otest)\\[[0-9]+/0x[0-9a-f]+\\] \\[lvl=[0-3]\\] \\(unknown\\) ";
- }
+ // E.g. 2008-01-04 09:16:26.906 otest[5567/0xa07d0f60] [lvl=1] (no func) test
+ // E.g. 2009-10-26 22:26:25.086 otest-i386[53200/0xa0438500] [lvl=1] (no func) test
+ kFormatBasePattern =
+ @"[0-9]{4}-[0-9]{2}-[0-9]{2} [0-9]{2}:[0-9]{2}:[0-9]{2}\\.[0-9]{3} ((otest)|(otest-i386)|(otest-x86_64)|(otest-ppc))\\[[0-9]+/0x[0-9a-f]+\\] \\[lvl=[0-3]\\] \\(unknown\\) ";
#else // GTM_MACOS_SDK
// E.g. 2008-01-04 09:16:26.906 otest[5567/0xa07d0f60] [lvl=1] (no func) test
kFormatBasePattern =
diff --git a/Foundation/GTMNSAppleEventDescriptor+Handler.h b/Foundation/GTMNSAppleEventDescriptor+Handler.h
index f2ac880..29c9c1e 100644
--- a/Foundation/GTMNSAppleEventDescriptor+Handler.h
+++ b/Foundation/GTMNSAppleEventDescriptor+Handler.h
@@ -30,11 +30,16 @@
count:(NSUInteger)count;
- (id)gtm_initWithPositionalHandler:(NSString*)handler
- parametersArray:(NSArray*)params;
+ parametersArray:(NSArray*)params
+ NS_RETURNS_RETAINED NS_CONSUMES_SELF;
+
- (id)gtm_initWithPositionalHandler:(NSString*)handler
- parametersDescriptor:(NSAppleEventDescriptor*)params;
+ parametersDescriptor:(NSAppleEventDescriptor*)params
+ NS_RETURNS_RETAINED NS_CONSUMES_SELF;
+
- (id)gtm_initWithLabeledHandler:(NSString*)handler
labels:(AEKeyword*)labels
parameters:(id*)params
- count:(NSUInteger)count;
+ count:(NSUInteger)count
+ NS_RETURNS_RETAINED NS_CONSUMES_SELF;
@end
diff --git a/Foundation/GTMNSDictionary+CaseInsensitive.h b/Foundation/GTMNSDictionary+CaseInsensitive.h
index a31e81c..890af4b 100644
--- a/Foundation/GTMNSDictionary+CaseInsensitive.h
+++ b/Foundation/GTMNSDictionary+CaseInsensitive.h
@@ -17,6 +17,7 @@
//
#import <Foundation/Foundation.h>
+#import "GTMDefines.h"
/// Utility for building case-insensitive NSDictionary objects.
@interface NSDictionary (GTMNSDictionaryCaseInsensitiveAdditions)
@@ -34,7 +35,8 @@
/// [NSDictionary gtm_dictionaryWithDictionaryCaseInsensitive:
/// [response allHeaderFields]];
/// NSString *contentType = [headers objectForKey:@"Content-Type"];
-- (id)gtm_initWithDictionaryCaseInsensitive:(NSDictionary *)dictionary;
+- (id)gtm_initWithDictionaryCaseInsensitive:(NSDictionary *)dictionary
+ NS_RETURNS_RETAINED NS_CONSUMES_SELF;
/// Returns a newly created and autoreleased NSDictionary object as above.
+ (id)gtm_dictionaryWithDictionaryCaseInsensitive:(NSDictionary *)dictionary;
diff --git a/Foundation/GTMNSNumber+64Bit.h b/Foundation/GTMNSNumber+64Bit.h
index 7ddab29..91561c8 100644
--- a/Foundation/GTMNSNumber+64Bit.h
+++ b/Foundation/GTMNSNumber+64Bit.h
@@ -30,9 +30,9 @@
+ (NSNumber *)gtm_numberWithInteger:(NSInteger)value;
+ (NSNumber *)gtm_numberWithUnsignedInteger:(NSUInteger)value;
-- (id)gtm_initWithCGFloat:(CGFloat)value;
-- (id)gtm_initWithInteger:(NSInteger)value;
-- (id)gtm_initWithUnsignedInteger:(NSUInteger)value;
+- (id)gtm_initWithCGFloat:(CGFloat)value NS_RETURNS_RETAINED NS_CONSUMES_SELF;
+- (id)gtm_initWithInteger:(NSInteger)value NS_RETURNS_RETAINED NS_CONSUMES_SELF;
+- (id)gtm_initWithUnsignedInteger:(NSUInteger)value NS_RETURNS_RETAINED NS_CONSUMES_SELF;
- (CGFloat)gtm_cgFloatValue;
- (NSInteger)gtm_integerValue;
diff --git a/Foundation/GTMNSObject+KeyValueObserving.m b/Foundation/GTMNSObject+KeyValueObserving.m
index 3fdc24e..fa07fab 100644
--- a/Foundation/GTMNSObject+KeyValueObserving.m
+++ b/Foundation/GTMNSObject+KeyValueObserving.m
@@ -568,7 +568,7 @@ GTM_METHOD_CHECK(NSObject,
@selector(_gtmCheckAddObserver:toObjectsAtIndexes:forKeyPath:options:context:));
#endif // GTM_PERFORM_KVO_CHECKS
- [pool release];
+ [pool drain];
}
- (void)_gtmDebugAddObserver:(NSObject *)observer
diff --git a/Foundation/GTMNSObject+KeyValueObservingTest.m b/Foundation/GTMNSObject+KeyValueObservingTest.m
index f37f1b4..be3041b 100644
--- a/Foundation/GTMNSObject+KeyValueObservingTest.m
+++ b/Foundation/GTMNSObject+KeyValueObservingTest.m
@@ -141,6 +141,11 @@
@implementation GTMNSObject_KeyValueObservingChecksTest
+- (void)setUp {
+ value_ = nil;
+ _value2 = nil;
+}
+
- (void)testAddingObserver {
[GTMUnitTestDevLogDebug expectPattern:@"warning:.*"];
[self addObserver:self forKeyPath:@"value_" options:0 context:NULL];
diff --git a/Foundation/GTMServiceManagement.c b/Foundation/GTMServiceManagement.c
index e7859d3..13bec32 100644
--- a/Foundation/GTMServiceManagement.c
+++ b/Foundation/GTMServiceManagement.c
@@ -596,7 +596,7 @@ exit:
return local_error == NULL;
}
-CFDictionaryRef GTMSMJobCheckIn(CFErrorRef *error) {
+CFDictionaryRef GTMSMCopyJobCheckInDictionary(CFErrorRef *error) {
CFErrorRef local_error = NULL;
CFDictionaryRef check_in_dict = NULL;
launch_data_t msg = launch_data_new_string(LAUNCH_KEY_CHECKIN);
diff --git a/Foundation/GTMServiceManagement.h b/Foundation/GTMServiceManagement.h
index 7a8e6b2..11fc4b5 100644
--- a/Foundation/GTMServiceManagement.h
+++ b/Foundation/GTMServiceManagement.h
@@ -45,7 +45,7 @@ CFDictionaryRef GTMSMJobCopyDictionary(CFStringRef jobLabel);
// Performs a check-in for the running process and returns its dictionary with
// the appropriate sockets and machports filled in.
// Caller takes ownership of the returned type.
-CFDictionaryRef GTMSMJobCheckIn(CFErrorRef *error);
+CFDictionaryRef GTMSMCopyJobCheckInDictionary(CFErrorRef *error);
// The official ServiceManagement version returns an array of job dictionaries.
// This returns a dictionary of job dictionaries where the key is the label
diff --git a/Foundation/GTMServiceManagementTest.m b/Foundation/GTMServiceManagementTest.m
index 13ac859..f23ceba 100644
--- a/Foundation/GTMServiceManagementTest.m
+++ b/Foundation/GTMServiceManagementTest.m
@@ -154,7 +154,7 @@ static NSString const *kGTMSocketName
CFErrorRef error = NULL;
// Can't check ourselves in
NSDictionary *badTest
- = GTMCFAutorelease(GTMSMJobCheckIn(&error));
+ = GTMCFAutorelease(GTMSMCopyJobCheckInDictionary(&error));
STAssertNil(badTest, nil);
STAssertNotNULL(error, nil);
CFRelease(error);
diff --git a/Foundation/GTMServiceManagementTestingHarness.c b/Foundation/GTMServiceManagementTestingHarness.c
index 2b99758..bb86071 100644
--- a/Foundation/GTMServiceManagementTestingHarness.c
+++ b/Foundation/GTMServiceManagementTestingHarness.c
@@ -21,9 +21,11 @@
int main(int argc, const char** argv) {
#if MAC_OS_X_VERSION_MIN_REQUIRED > MAC_OS_X_VERSION_10_4
CFErrorRef error = NULL;
- CFDictionaryRef dict = GTMSMJobCheckIn(&error);
+ CFDictionaryRef dict = GTMSMCopyJobCheckInDictionary(&error);
if (!dict) {
CFShow(error);
+ } else {
+ CFRelease(dict);
}
#endif // if MAC_OS_X_VERSION_MIN_REQUIRED > MAC_OS_X_VERSION_10_4
return 0;
diff --git a/Foundation/GTMStackTrace.m b/Foundation/GTMStackTrace.m
index 5e832c2..8019867 100644
--- a/Foundation/GTMStackTrace.m
+++ b/Foundation/GTMStackTrace.m
@@ -102,8 +102,8 @@ static NSUInteger GTMGetStackAddressDescriptorsForAddresses(void *pcs[],
for (NSUInteger j = 0; j < class_desc_count; ++j) {
// First check the class methods.
for (NSUInteger k = 0; k < class_descs[j].class_method_count; ++k) {
- IMP imp = method_getImplementation(class_descs[j].class_methods[k]);
- if (imp <= (IMP)currDesc->address) {
+ void *imp = (void *)method_getImplementation(class_descs[j].class_methods[k]);
+ if (imp <= currDesc->address) {
size_t diff = (size_t)currDesc->address - (size_t)imp;
if (diff < smallest_diff) {
best_method = class_descs[j].class_methods[k];
@@ -115,8 +115,8 @@ static NSUInteger GTMGetStackAddressDescriptorsForAddresses(void *pcs[],
}
// Then check the instance methods.
for (NSUInteger k = 0; k < class_descs[j].instance_method_count; ++k) {
- IMP imp = method_getImplementation(class_descs[j].instance_methods[k]);
- if (imp <= (IMP)currDesc->address) {
+ void *imp = (void *)method_getImplementation(class_descs[j].instance_methods[k]);
+ if (imp <= currDesc->address) {
size_t diff = (size_t)currDesc->address - (size_t)imp;
if (diff < smallest_diff) {
best_method = class_descs[j].instance_methods[k];
diff --git a/Foundation/GTMTransientRootProxyTest.m b/Foundation/GTMTransientRootProxyTest.m
index 081aff3..821faac 100644
--- a/Foundation/GTMTransientRootProxyTest.m
+++ b/Foundation/GTMTransientRootProxyTest.m
@@ -44,8 +44,7 @@ enum {
// The "server" we'll use to test the DO connection. This server will implement
// our test protocol, and it will run in a separate thread from the main
// unit testing thread, so the DO requests can be serviced.
-@interface DOTestServer : NSObject <DOTestProtocol> {
-}
+@interface DOTestServer : NSObject <DOTestProtocol>
- (void)runThread:(NSDictionary *)args;
@end
@@ -97,6 +96,10 @@ enum {
// === Done with auxillary data structures, now for the main test class ===
+@interface GTMTransientRootProxy (GTMTransientRootProxyTest)
+- (id)init;
+@end
+
@interface GTMTransientRootProxyTest : GTMTestCase {
@private
DOTestServer *server_;
@@ -128,7 +131,7 @@ enum {
@"Unable to start thread");
[syncLock_ unlockWithCondition:kGTMTransientThreadConditionStarted];
- GTMTransientRootProxy<DOTestProtocol> *failProxy =
+ GTMTransientRootProxy *failProxy =
[GTMTransientRootProxy rootProxyWithRegisteredName:nil
host:nil
protocol:@protocol(DOTestProtocol)
diff --git a/Foundation/GTMValidatingContainers.m b/Foundation/GTMValidatingContainers.m
index 3b31356..3dcab68 100644
--- a/Foundation/GTMValidatingContainers.m
+++ b/Foundation/GTMValidatingContainers.m
@@ -210,7 +210,7 @@ void _GTMValidateContainer(id container, id target, SEL selector) {
if ((self = [super init])) {
[self release];
}
- return [[NSMutableArray alloc] initWithCapacity:capacity];
+ return (GTMValidatingArray*)[[NSMutableArray alloc] initWithCapacity:capacity];
}
#endif // GTM_CONTAINERS_VALIDATE
@end
@@ -287,7 +287,8 @@ void _GTMValidateContainer(id container, id target, SEL selector) {
if ((self = [super init])) {
[self release];
}
- return [[NSMutableDictionary alloc] initWithCapacity:capacity];
+ return (GTMValidatingDictionary*)[[NSMutableDictionary alloc]
+ initWithCapacity:capacity];
}
#endif // GTM_CONTAINERS_VALIDATE
@@ -366,7 +367,7 @@ void _GTMValidateContainer(id container, id target, SEL selector) {
if ((self = [super init])) {
[self release];
}
- return [[NSMutableSet alloc] initWithCapacity:capacity];
+ return (GTMValidatingSet*)[[NSMutableSet alloc] initWithCapacity:capacity];
}
#endif // GTM_CONTAINERS_VALIDATE
@end
diff --git a/GTMDefines.h b/GTMDefines.h
index 97875c8..9ef6fcc 100644
--- a/GTMDefines.h
+++ b/GTMDefines.h
@@ -294,6 +294,30 @@
#endif
#endif
+#ifndef NS_CONSUMED
+ #if __has_feature(attribute_ns_consumed)
+ #define NS_CONSUMED __attribute__((ns_consumed))
+ #else
+ #define NS_CONSUMED
+ #endif
+#endif
+
+#ifndef CF_CONSUMED
+ #if __has_feature(attribute_cf_consumed)
+ #define CF_CONSUMED __attribute__((cf_consumed))
+ #else
+ #define CF_CONSUMED
+ #endif
+#endif
+
+#ifndef NS_CONSUMES_SELF
+ #if __has_feature(attribute_ns_consumes_self)
+ #define NS_CONSUMES_SELF __attribute__((ns_consumes_self))
+ #else
+ #define NS_CONSUMES_SELF
+ #endif
+#endif
+
// Defined on 10.6 and above.
#ifndef NS_FORMAT_ARGUMENT
#define NS_FORMAT_ARGUMENT(A)
diff --git a/UnitTesting/GTMUnitTestingTest.m b/UnitTesting/GTMUnitTestingTest.m
index d14795f..0f87d28 100644
--- a/UnitTesting/GTMUnitTestingTest.m
+++ b/UnitTesting/GTMUnitTestingTest.m
@@ -42,6 +42,7 @@ NSString *const kGTMWindowSaveFileName = @"GTMUnitTestingWindow";
@end
@interface GTMUnitTestingProxyTest : NSProxy
+- (id)init;
@end
@implementation GTMUnitTestingTest