Fixed some problems reported by the CLANG static analyzer.
1.1 --- a/DateUtils.m Thu Jul 17 13:29:34 2008 -0700
1.2 +++ b/DateUtils.m Tue Mar 10 22:34:39 2009 -0700
1.3 @@ -33,13 +33,17 @@
1.4
1.5 NSTimeInterval TimeIntervalSinceBoot(void)
1.6 {
1.7 - // From http://developer.apple.com/qa/qa2004/qa1398.html
1.8 - uint64_t abstime = mach_absolute_time();
1.9 - // Have to do some pointer fun because AbsoluteToNanoseconds
1.10 + // Adapted from http://developer.apple.com/qa/qa2004/qa1398.html
1.11 + // Have to do some union tricks because AbsoluteToNanoseconds
1.12 // works in terms of UnsignedWide, which is a structure rather
1.13 // than a proper 64-bit integer.
1.14 - Nanoseconds elapsedNano = AbsoluteToNanoseconds( *(AbsoluteTime *) &abstime );
1.15 - return *(uint64_t*)&elapsedNano / 1.0e9;
1.16 + union {
1.17 + uint64_t asUInt64;
1.18 + UnsignedWide asUWide;
1.19 + } t;
1.20 + t.asUInt64 = mach_absolute_time();
1.21 + t.asUWide = AbsoluteToNanoseconds(t.asUWide);
1.22 + return t.asUInt64 / 1.0e9;
1.23 }
1.24
1.25
2.1 --- a/FileAlias.m Thu Jul 17 13:29:34 2008 -0700
2.2 +++ b/FileAlias.m Tue Mar 10 22:34:39 2009 -0700
2.3 @@ -33,7 +33,7 @@
2.4 }
2.5
2.6 if( ! CheckOSErr(err,error) ) {
2.7 - Warn(@"FileAlias init failed with OSStatus %i",err);
2.8 + Warn(@"FileAlias init failed with OSStatus %i for %@",err,targetPath);
2.9 [self release];
2.10 return nil;
2.11 }
2.12 @@ -74,7 +74,7 @@
2.13
2.14 self = [super init];
2.15 if( self ) {
2.16 - Handle handle;
2.17 + Handle handle = NULL;
2.18 unsigned length;
2.19 const void *bytes = [arch decodeBytesForKey:@"aliasHandle" returnedLength: &length];
2.20 if( bytes )
3.1 --- a/Logging.h Thu Jul 17 13:29:34 2008 -0700
3.2 +++ b/Logging.h Tue Mar 10 22:34:39 2009 -0700
3.3 @@ -36,9 +36,9 @@
3.4 #define Warn Warn
3.5
3.6 void AlwaysLog( NSString *msg, ... ) __attribute__((format(__NSString__, 1, 2)));
3.7 -BOOL _WillLogTo( NSString *domain );
3.8 BOOL EnableLog( BOOL enable );
3.9 #define EnableLogTo( DOMAIN, VALUE ) _EnableLogTo(@""#DOMAIN, VALUE)
3.10 +#define WillLog() _WillLogTo(nil)
3.11 #define WillLogTo( DOMAIN ) _WillLogTo(@""#DOMAIN)
3.12
3.13
4.1 --- a/Logging.m Thu Jul 17 13:29:34 2008 -0700
4.2 +++ b/Logging.m Tue Mar 10 22:34:39 2009 -0700
4.3 @@ -99,7 +99,7 @@
4.4 {
4.5 if( _gShouldLog == -1 )
4.6 InitLogging();
4.7 - return _gShouldLog && [sEnabledDomains containsObject: domain];
4.8 + return _gShouldLog && (domain==nil || [sEnabledDomains containsObject: domain]);
4.9 }
4.10
4.11 BOOL _EnableLogTo( NSString *domain, BOOL enable )
5.1 --- a/URLUtils.m Thu Jul 17 13:29:34 2008 -0700
5.2 +++ b/URLUtils.m Tue Mar 10 22:34:39 2009 -0700
5.3 @@ -75,8 +75,7 @@
5.4 // HTTP status >= 300 is considered an error:
5.5 int status = self.statusCode;
5.6 if( status >= 300 ) {
5.7 - NSString *reason = NSLocalizedStringFromTable( @"HTTP_ERROR_MESSAGE",@"UKCrashReporter",@"");
5.8 - reason = [NSHTTPURLResponse localizedStringForStatusCode: status];
5.9 + NSString *reason = [NSHTTPURLResponse localizedStringForStatusCode: status];
5.10 NSDictionary *info = $dict({NSLocalizedFailureReasonErrorKey,reason});
5.11 return [NSError errorWithDomain: MyHTTPErrorDomain code: status userInfo: info];
5.12 } else