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:
Richard Frith-MacDonald 2011-03-09 12:40:50 +00:00
parent 4b367a26d2
commit 9810a1ec9c
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
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>

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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