Permalink
Browse files

Fixes for bugs found by the Clang static analyzer.

  • Loading branch information...
1 parent 3c96294 commit ad27dbfe6d50f448ba5bdfd93a6d840d60c1ca0e @AlanQuatermain committed Jul 2, 2009
@@ -512,7 +512,7 @@ - (void) _postEventToDelegate: (NSStreamEvent) event
[_delegate stream: self handleEvent: event];
}
-- (NSInteger) write: (uint8_t *) buffer maxLength: (NSUInteger) len
+- (NSInteger) write: (uint8_t const *) buffer maxLength: (NSUInteger) len
{
if ( _status != NSStreamStatusOpen )
return ( 0 );
@@ -316,9 +316,11 @@ - (id) propertyForKey: (NSString *) key
return ( [_compressedDataStream propertyForKey: key] );
}
-- (void) setProperty: (id) property forKey: (NSString *) key
+- (BOOL) setProperty: (id) property forKey: (NSString *) key
{
- [_compressedDataStream setProperty: property forKey: key];
+ if ( [_compressedDataStream setProperty: property forKey: key] == NO )
+ return ( [super setProperty: property forKey: key] );
+ return ( YES );
}
@end
@@ -297,9 +297,11 @@ - (id) propertyForKey: (NSString *) key
return ( [_outputStream propertyForKey: key] );
}
-- (void) setProperty: (id) property forKey: (NSString *) key
+- (BOOL) setProperty: (id) property forKey: (NSString *) key
{
- [_outputStream setProperty: property forKey: key];
+ if ( [_outputStream setProperty: property forKey: key] == NO )
+ return ( [super setProperty: property forKey: key] );
+ return ( YES );
}
@end
@@ -0,0 +1,9 @@
+h2. Contacts has moved!
+
+The AddressBook Objective-C wrappers for iPhone are now "in their own project":http://github.com/alanQuatermain/iPhoneContacts. The reason for this is twofold:
+
+1. The AQToolkit is based around hybrid code which can be used on both the Mac and iPhone. This wrapper API, by its very design, works only on the iPhone --- it uses the iPhone-only AddressBook framework, which has C APIs in the same header files used for the ObjC versions on the Mac. This makes it difficult to build AQToolkit as a complete library (my testing stuff is actually based around 10.5 and 10.6 builds, not iPhone).
+
+2. The classes in this API are useful enough on their own, and involve enough classes, that it seems a good idea to separate it out from everything else in this generic toolkit project.
+
+If you want the latest code (this move coincides with a minor update to the code itself) then you can "find it here":http://github.com/alanQuatermain/iPhoneContacts.
@@ -142,7 +142,10 @@ + (NSError *) errorFromCFStreamError: (CFStreamError) streamError
}
}
- return ( [NSError errorWithDomain: domain code: code userInfo: userInfo] );
+ NSError * result = [NSError errorWithDomain: domain code: code userInfo: userInfo];
+ [userInfo release];
+
+ return ( result );
}
@end
@@ -0,0 +1 @@
+build
@@ -217,7 +217,7 @@ @implementation FSEventManager (Internal)
- (BOOL) setupFSEventListener
{
- int clonefd;
+ int clonefd = -1;
struct fsevent_clone_args clone_args;
int8_t event_list[] = {
FSE_REPORT, // create file
@@ -342,6 +342,8 @@ - (void) waitForEvents
FSEvent * event = [[FSEvent alloc] init];
event.eventCode = pEvt->type & FSE_TYPE_MASK;
event.processID = pEvt->pid;
+
+ BOOL isVnode = NO;
// read arguments
kfs_event_arg_t *pArg = pEvt->args;
@@ -356,7 +358,6 @@ - (void) waitForEvents
int argOffset = sizeof(pArg->type) + sizeof(pArg->len) + pArg->len;
offset += argOffset;
- BOOL isVnode = NO;
int argType = (pArg->type > FSE_MAX_ARGS) ? 0 : pArg->type;
switch ( argType )
@@ -132,11 +132,6 @@ - (void) terminate
[self autorelease];
}
-- (void) _terminate
-{
- [self _cancelTransfers];
-}
-
- (void) _addHelper: (AQLowMemoryDownloadHelper *) helper
{
@synchronized(_downloadHelpers)
@@ -164,6 +159,11 @@ - (void) _cancelTransfers
}
}
+- (void) _terminate
+{
+ [self _cancelTransfers];
+}
+
- (void) main
{
NSAutoreleasePool * rootPool = [[NSAutoreleasePool alloc] init];
@@ -124,6 +124,7 @@ + (void) handleAsyncRequest: (NSURLRequest *) request
obj.asyncDelegate = delegate;
[obj _performAsynchronousRequest: request];
+ [obj release];
}
- (id) init
@@ -919,10 +919,6 @@ - (BOOL) parseAsynchronouslyUsingRunLoop: (NSRunLoop *) runloop
if ( _stream == nil )
return ( NO );
- xmlSAXHandlerPtr saxHandler = NULL;
- if ( self.delegate != nil )
- saxHandler = _internal->saxHandler;
-
// see if bytes are already available on the stream
// if there are, we'll grab the first 4 bytes and use those to compute the encoding
// otherwise, we'll just go with no initial data
@@ -1242,11 +1238,10 @@ - (void) _setupExpectedLength
return;
}
- CFNumberRef num = (CFNumberRef) [_stream propertyForKey: (NSString *)kCFStreamPropertyFTPResourceSize];
+ NSNumber * num = [_stream propertyForKey: (NSString *)kCFStreamPropertyFTPResourceSize];
if ( num != NULL )
{
- _internal->expectedDataLength = [(NSNumber *)num floatValue];
- CFRelease( num );
+ _internal->expectedDataLength = [num floatValue];
return;
}

0 comments on commit ad27dbf

Please sign in to comment.