a few more static analyser tweaks

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@32517 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
rfm 2011-03-09 12:40:50 +00:00
parent 4b9d324725
commit 3f15443f98
15 changed files with 41 additions and 41 deletions

View file

@ -2,6 +2,13 @@
* Source/NSUserDefaults.m: Fix bug in resetting ... was ending up * Source/NSUserDefaults.m: Fix bug in resetting ... was ending up
with an immutable dictionary for the registration domain. with an immutable dictionary for the registration domain.
* Source/NSObject.m: fix references to isa.
* Source/NSPropertyList.m: Fix unused increments.
* Source/NSRunLoop.m: Remove unused code.
* Source/NSSocketPort.m: Remove unused code.
* Source/NSSocketPortNameServer.m: Remove unused code.
* Source/NSTimeZone.m: Fix unused increment.
* Source/NSUnarchiver.m: Fix unused assignment.
2011-03-08 Richard Frith-Macdonald <rfm@gnu.org> 2011-03-08 Richard Frith-Macdonald <rfm@gnu.org>

View file

@ -58,8 +58,8 @@ GS_EXPORT NSString *const NSGrammarUserDescription;
#if GS_EXPOSE(NSSpellServer) #if GS_EXPOSE(NSSpellServer)
@private @private
id _delegate; id _delegate;
BOOL _caseSensitive; BOOL _caseSensitive GS_UNUSED_IVAR;
unsigned char _dummy[3]; unsigned char _dummy[3] GS_UNUSED_IVAR;
NSMutableDictionary *_userDictionaries; NSMutableDictionary *_userDictionaries;
NSString *_currentLanguage; NSString *_currentLanguage;
NSArray *_ignoredWords; NSArray *_ignoredWords;

View file

@ -2274,7 +2274,6 @@ tables:
* No mapping has been found. * No mapping has been found.
*/ */
result = NO; result = NO;
spos = slen;
goto done; goto done;
} }
} }

View file

@ -119,8 +119,9 @@ GSAvahiClientState(AvahiClient *client, AvahiClientState state, void *userInfo)
- (id) initWithRunLoop: (NSRunLoop*)rl - (id) initWithRunLoop: (NSRunLoop*)rl
forMode: (NSString*)mode forMode: (NSString*)mode
{ {
return [self avahiClientInitWithRunLoop: rl self = [self avahiClientInitWithRunLoop: rl
forMode: mode]; forMode: mode];
return self;
} }
- (id) avahiClientInit - (id) avahiClientInit
@ -131,7 +132,8 @@ GSAvahiClientState(AvahiClient *client, AvahiClientState state, void *userInfo)
- (id) init - (id) init
{ {
return [self avahiClientInit]; self = [self avahiClientInit];
return self;
} }
- (void*) client - (void*) client

View file

@ -1005,7 +1005,8 @@ didUpdateRecordData: (id)data
} }
else else
{ {
ret = AVAHI_ERR_FAILURE; ret = AVAHI_ERR_FAILURE;
break;
} }
} }

View file

@ -45,7 +45,9 @@ NSString * const NSNetServicesErrorCode = @"NSNetServicesErrorCode";
*/ */
NSString * const NSNetServicesErrorDomain = @"NSNetServicesErrorDomain"; NSString * const NSNetServicesErrorDomain = @"NSNetServicesErrorDomain";
static Class abstractServiceClass;
static Class concreteServiceClass; static Class concreteServiceClass;
static Class abstractBrowserClass;
static Class concreteBrowserClass; static Class concreteBrowserClass;
@implementation NSNetService @implementation NSNetService
@ -53,6 +55,7 @@ static Class concreteBrowserClass;
{ {
if (self == [NSNetService class]) if (self == [NSNetService class])
{ {
abstractServiceClass = self;
# if GS_USE_AVAHI==1 # if GS_USE_AVAHI==1
concreteServiceClass = [GSAvahiNetService class]; concreteServiceClass = [GSAvahiNetService class];
# else # else
@ -63,9 +66,10 @@ static Class concreteBrowserClass;
+ (id) allocWithZone: (NSZone*)zone + (id) allocWithZone: (NSZone*)zone
{ {
// Note: Assignging the subclass to self will make NSObject allocate the if (self == abstractServiceClass)
// correct class layout. {
self = concreteServiceClass; return [concreteServiceClass allocWithZone: zone];
}
return [super allocWithZone: zone]; return [super allocWithZone: zone];
} }
@ -386,6 +390,7 @@ static Class concreteBrowserClass;
{ {
if (self == [NSNetServiceBrowser class]) if (self == [NSNetServiceBrowser class])
{ {
abstractBrowserClass = self;
# if GS_USE_AVAHI==1 # if GS_USE_AVAHI==1
concreteBrowserClass = [GSAvahiNetServiceBrowser class]; concreteBrowserClass = [GSAvahiNetServiceBrowser class];
# else // Not Avahi (=GS_USE_MDNS) # else // Not Avahi (=GS_USE_MDNS)
@ -396,9 +401,10 @@ static Class concreteBrowserClass;
+ (id) allocWithZone: (NSZone*)zone + (id) allocWithZone: (NSZone*)zone
{ {
// Note: Assignging the subclass to self will make NSObject allocate the if (self == abstractBrowserClass)
// correct class layout. {
self = concreteBrowserClass; return [concreteBrowserClass allocWithZone: zone];
}
return [super allocWithZone: zone]; return [super allocWithZone: zone];
} }
- (id) init - (id) init

View file

@ -1570,7 +1570,7 @@ PString(NSString *obj, NSMutableData *output)
break; break;
} }
} }
*ptr++ = '"'; *ptr = '"';
GS_ENDITEMBUF(); GS_ENDITEMBUF();
} }
@ -1921,7 +1921,7 @@ OAppend(id obj, NSDictionary *loc, unsigned lev, unsigned step,
dst[++j] = ' '; dst[++j] = ' ';
} }
} }
dst[j++] = '>'; dst[j] = '>';
} }
} }
else if ([obj isKindOfClass: NSDateClass]) else if ([obj isKindOfClass: NSDateClass])
@ -2186,7 +2186,7 @@ OAppend(id obj, NSDictionary *loc, unsigned lev, unsigned step,
comp = (NSComparisonResult (*)(id, SEL, id)) comp = (NSComparisonResult (*)(id, SEL, id))
[a methodForSelector: @selector(compare:)]; [a methodForSelector: @selector(compare:)];
} }
r = (*comp)(a, @selector(compare:), b); r = (0 == comp) ? 0 : (*comp)(a, @selector(compare:), b);
if (r < 0) if (r < 0)
{ {
#ifdef GSWARN #ifdef GSWARN

View file

@ -915,7 +915,6 @@ updateTimer(NSTimer *t, NSDate *d, NSTimeInterval now)
ti += (increment * add); ti += (increment * add);
if (ti < now) if (ti < now)
{ {
add++;
ti += increment; ti += increment;
} }
} }
@ -1099,7 +1098,7 @@ updateTimer(NSTimer *t, NSDate *d, NSTimeInterval now)
#endif #endif
NSDebugMLLog(@"NSRunLoop", @"limit date %f in %@", NSDebugMLLog(@"NSRunLoop", @"limit date %f in %@",
[when timeIntervalSinceReferenceDate], mode); nil == when ? 0.0 : [when timeIntervalSinceReferenceDate], mode);
} }
return when; return when;
} }

View file

@ -252,14 +252,12 @@ decodePort(NSData *data, NSString *defaultAddress)
GSPortInfo *pi; GSPortInfo *pi;
NSString *addr; NSString *addr;
uint16_t pnum; uint16_t pnum;
uint32_t length;
NSHost *host; NSHost *host;
unichar c; unichar c;
pih = (GSPortItemHeader*)[data bytes]; pih = (GSPortItemHeader*)[data bytes];
NSCAssert(GSSwapBigI32ToHost(pih->type) == GSP_PORT, NSCAssert(GSSwapBigI32ToHost(pih->type) == GSP_PORT,
NSInternalInconsistencyException); NSInternalInconsistencyException);
length = GSSwapBigI32ToHost(pih->length);
pi = (GSPortInfo*)&pih[1]; pi = (GSPortInfo*)&pih[1];
pnum = GSSwapBigI16ToHost(pi->num); pnum = GSSwapBigI16ToHost(pi->num);
if (strncmp(pi->addr, "VER", 3) == 0) if (strncmp(pi->addr, "VER", 3) == 0)

View file

@ -656,7 +656,6 @@ typedef enum {
[serverLock lock]; [serverLock lock];
NS_DURING NS_DURING
{ {
GSPortCom *tmp;
NSData *dat; NSData *dat;
[com startListNameServers]; [com startListNameServers];
@ -683,9 +682,7 @@ typedef enum {
[NSException raise: NSInternalInconsistencyException [NSException raise: NSInternalInconsistencyException
format: @"failed to get list of name servers"]; format: @"failed to get list of name servers"];
} }
tmp = com; RELEASE(com);
com = nil;
RELEASE(tmp);
} }
NS_HANDLER NS_HANDLER
{ {
@ -1083,8 +1080,6 @@ typedef enum {
NS_DURING NS_DURING
{ {
GSPortCom *tmp;
com = [GSPortCom new]; com = [GSPortCom new];
[com startPortUnregistration: 0 withName: name]; [com startPortUnregistration: 0 withName: name];
while ([limit timeIntervalSinceNow] > 0 && [com isActive] == YES) while ([limit timeIntervalSinceNow] > 0 && [com isActive] == YES)
@ -1134,9 +1129,7 @@ typedef enum {
} }
} }
} }
tmp = com; RELEASE(com);
com = nil;
RELEASE(tmp);
} }
NS_HANDLER NS_HANDLER
{ {

View file

@ -308,7 +308,7 @@ decode (const void *ptr)
result = (result << 8) | *p++; result = (result << 8) | *p++;
result = (result << 8) | *p++; result = (result << 8) | *p++;
result = (result << 8) | *p++; result = (result << 8) | *p++;
result = (result << 8) | *p++; result = (result << 8) | *p;
return result; return result;
#endif /* defined(WORDS_BIGENDIAN) && SIZEOF_INT == 4 */ #endif /* defined(WORDS_BIGENDIAN) && SIZEOF_INT == 4 */
} }

View file

@ -753,7 +753,7 @@ static Class NSDataMallocClass;
className = @"_NSUnarchiverUnknownClass"; className = @"_NSUnarchiverUnknownClass";
} }
classInfo = [objDict objectForKey: className]; classInfo = [objDict objectForKey: className];
if (classInfo == nil) if (nil == classInfo)
{ {
classInfo = [NSUnarchiverObjectInfo newWithName: className]; classInfo = [NSUnarchiverObjectInfo newWithName: className];
c = NSClassFromString(className); c = NSClassFromString(className);
@ -770,10 +770,6 @@ static Class NSDataMallocClass;
[objDict setObject: classInfo forKey: className]; [objDict setObject: classInfo forKey: className];
RELEASE(classInfo); RELEASE(classInfo);
} }
else
{
c = classInfo->class;
}
RELEASE(className); RELEASE(className);
classInfo->version = (NSInteger)cver; classInfo->version = (NSInteger)cver;
GSIArrayAddItem(clsMap, (GSIArrayItem)((id)classInfo)); GSIArrayAddItem(clsMap, (GSIArrayItem)((id)classInfo));

View file

@ -790,7 +790,7 @@ static int verbose = 0;
NSString *filename; NSString *filename;
e = [HTMLDirectoryEnumerator alloc]; e = [HTMLDirectoryEnumerator alloc];
e = [e initWithBasePath: pathOnDisk]; e = [[e initWithBasePath: pathOnDisk] autorelease];
[e setLooksForHTMLLinkFiles: YES]; [e setLooksForHTMLLinkFiles: YES];
[e setReturnsAbsolutePaths: YES]; [e setReturnsAbsolutePaths: YES];
@ -1125,7 +1125,7 @@ int main (int argc, char** argv, char** env)
NSArray *args; NSArray *args;
NSMutableArray *inputFiles; NSMutableArray *inputFiles;
unsigned i, count; unsigned i, count;
BOOL warn, fixupAllLinks; BOOL warn;
NSString *linksMarker; NSString *linksMarker;
HTMLLinker *linker; HTMLLinker *linker;
CREATE_AUTORELEASE_POOL(pool); CREATE_AUTORELEASE_POOL(pool);
@ -1152,7 +1152,6 @@ int main (int argc, char** argv, char** env)
nil]]; nil]];
warn = [userDefs boolForKey: @"Warn"]; warn = [userDefs boolForKey: @"Warn"];
fixupAllLinks = [userDefs boolForKey: @"FixupAllLinks"];
linksMarker = [userDefs stringForKey: @"LinksMarker"]; linksMarker = [userDefs stringForKey: @"LinksMarker"];

View file

@ -285,8 +285,8 @@ main(int argc, char** argv, char **env)
} }
} }
NSZoneFree(z, u); NSZoneFree(z, u);
myData = [[NSData alloc] initWithBytesNoCopy: c myData = [[[NSData alloc]
length: o]; initWithBytesNoCopy: c length: o] autorelease];
} }
else if (eIn == YES) else if (eIn == YES)
{ {

View file

@ -50,8 +50,8 @@ convert_unicode(NSArray *args)
IF_NO_GC([myString autorelease];) IF_NO_GC([myString autorelease];)
if ([myString length] == 0) if ([myString length] == 0)
{ {
myString = [[NSString alloc] initWithData: data myString = [[[NSString alloc] initWithData: data
encoding: [NSString defaultCStringEncoding]]; encoding: [NSString defaultCStringEncoding]] autorelease];
} }
output = [[file lastPathComponent] output = [[file lastPathComponent]
stringByAppendingPathExtension: @"unicode"]; stringByAppendingPathExtension: @"unicode"];