# HG changeset patch # User snej@snej.local # Date 1236749679 25200 # Node ID 5ade3e09a827a83ec6b3a6da4250fd7d16255992 # Parent d6ab9f52b4d77ab280861ecf0eb2dbf1795cd743 Fixed some problems reported by the CLANG static analyzer. diff -r d6ab9f52b4d7 -r 5ade3e09a827 DateUtils.m --- a/DateUtils.m Thu Jul 17 13:29:34 2008 -0700 +++ b/DateUtils.m Tue Mar 10 22:34:39 2009 -0700 @@ -33,13 +33,17 @@ NSTimeInterval TimeIntervalSinceBoot(void) { - // From http://developer.apple.com/qa/qa2004/qa1398.html - uint64_t abstime = mach_absolute_time(); - // Have to do some pointer fun because AbsoluteToNanoseconds + // Adapted from http://developer.apple.com/qa/qa2004/qa1398.html + // Have to do some union tricks because AbsoluteToNanoseconds // works in terms of UnsignedWide, which is a structure rather // than a proper 64-bit integer. - Nanoseconds elapsedNano = AbsoluteToNanoseconds( *(AbsoluteTime *) &abstime ); - return *(uint64_t*)&elapsedNano / 1.0e9; + union { + uint64_t asUInt64; + UnsignedWide asUWide; + } t; + t.asUInt64 = mach_absolute_time(); + t.asUWide = AbsoluteToNanoseconds(t.asUWide); + return t.asUInt64 / 1.0e9; } diff -r d6ab9f52b4d7 -r 5ade3e09a827 FileAlias.m --- a/FileAlias.m Thu Jul 17 13:29:34 2008 -0700 +++ b/FileAlias.m Tue Mar 10 22:34:39 2009 -0700 @@ -33,7 +33,7 @@ } if( ! CheckOSErr(err,error) ) { - Warn(@"FileAlias init failed with OSStatus %i",err); + Warn(@"FileAlias init failed with OSStatus %i for %@",err,targetPath); [self release]; return nil; } @@ -74,7 +74,7 @@ self = [super init]; if( self ) { - Handle handle; + Handle handle = NULL; unsigned length; const void *bytes = [arch decodeBytesForKey:@"aliasHandle" returnedLength: &length]; if( bytes ) diff -r d6ab9f52b4d7 -r 5ade3e09a827 Logging.h --- a/Logging.h Thu Jul 17 13:29:34 2008 -0700 +++ b/Logging.h Tue Mar 10 22:34:39 2009 -0700 @@ -36,9 +36,9 @@ #define Warn Warn void AlwaysLog( NSString *msg, ... ) __attribute__((format(__NSString__, 1, 2))); -BOOL _WillLogTo( NSString *domain ); BOOL EnableLog( BOOL enable ); #define EnableLogTo( DOMAIN, VALUE ) _EnableLogTo(@""#DOMAIN, VALUE) +#define WillLog() _WillLogTo(nil) #define WillLogTo( DOMAIN ) _WillLogTo(@""#DOMAIN) diff -r d6ab9f52b4d7 -r 5ade3e09a827 Logging.m --- a/Logging.m Thu Jul 17 13:29:34 2008 -0700 +++ b/Logging.m Tue Mar 10 22:34:39 2009 -0700 @@ -99,7 +99,7 @@ { if( _gShouldLog == -1 ) InitLogging(); - return _gShouldLog && [sEnabledDomains containsObject: domain]; + return _gShouldLog && (domain==nil || [sEnabledDomains containsObject: domain]); } BOOL _EnableLogTo( NSString *domain, BOOL enable ) diff -r d6ab9f52b4d7 -r 5ade3e09a827 URLUtils.m --- a/URLUtils.m Thu Jul 17 13:29:34 2008 -0700 +++ b/URLUtils.m Tue Mar 10 22:34:39 2009 -0700 @@ -75,8 +75,7 @@ // HTTP status >= 300 is considered an error: int status = self.statusCode; if( status >= 300 ) { - NSString *reason = NSLocalizedStringFromTable( @"HTTP_ERROR_MESSAGE",@"UKCrashReporter",@""); - reason = [NSHTTPURLResponse localizedStringForStatusCode: status]; + NSString *reason = [NSHTTPURLResponse localizedStringForStatusCode: status]; NSDictionary *info = $dict({NSLocalizedFailureReasonErrorKey,reason}); return [NSError errorWithDomain: MyHTTPErrorDomain code: status userInfo: info]; } else