Author: rfm
Date: Tue Jan 6 11:56:39 2015
New Revision: 38280
URL: http://svn.gna.org/viewcvs/gnustep?rev=38280&view=rev
Log:
avoid some compiler warnings
Modified:
libs/sqlclient/trunk/SQLClient.m
Modified: libs/sqlclient/trunk/SQLClient.m
URL:
http://svn.gna.org/viewcvs/gnustep/libs/sqlclient/trunk/SQLClient.m?rev=38280&r1=38279&r2=38280&view=diff
==============================================================================
--- libs/sqlclient/trunk/SQLClient.m (original)
+++ libs/sqlclient/trunk/SQLClient.m Tue Jan 6 11:56:39 2015
@@ -134,14 +134,22 @@
- (NSArray*) allKeys
{
- unsigned count = [self count];
- id buf[count];
-
- while (count-- > 0)
- {
- buf[count] = [self keyAtIndex: count];
- }
- return [NSArray arrayWithObjects: buf count: count];
+ NSUInteger count = [self count];
+
+ if (count > 0)
+ {
+ id buf[count];
+
+ while (count-- > 0)
+ {
+ buf[count] = [self keyAtIndex: count];
+ }
+ return [NSArray arrayWithObjects: buf count: count];
+ }
+ else
+ {
+ return [NSArray array];
+ }
}
- (id) copyWithZone: (NSZone*)z
@@ -157,15 +165,23 @@
- (NSMutableDictionary*) dictionary
{
- unsigned count = [self count];
- id keys[count];
- id vals[count];
-
- [self getKeys: keys];
- [self getObjects: vals];
- return [NSMutableDictionary dictionaryWithObjects: vals
- forKeys: keys
- count: count];
+ NSUInteger count = [self count];
+
+ if (count > 0)
+ {
+ id keys[count];
+ id vals[count];
+
+ [self getKeys: keys];
+ [self getObjects: vals];
+ return [NSMutableDictionary dictionaryWithObjects: vals
+ forKeys: keys
+ count: count];
+ }
+ else
+ {
+ return [NSMutableDictionary dictionary];
+ }
}
- (void) getKeys: (id*)buf
@@ -209,92 +225,102 @@
- (id) objectForKey: (NSString*)key
{
- unsigned count = [self count];
- unsigned pos;
- id keys[count];
-
- [self getKeys: keys];
- for (pos = 0; pos < count; pos++)
- {
- if ([key isEqualToString: keys[pos]] == YES)
- {
- break;
- }
- }
- if (pos == count)
- {
+ NSUInteger count = [self count];
+
+ if (count > 0)
+ {
+ NSUInteger pos;
+ id keys[count];
+
+ [self getKeys: keys];
for (pos = 0; pos < count; pos++)
- {
- if ([key caseInsensitiveCompare: keys[pos]] == NSOrderedSame)
- {
- break;
- }
- }
- }
-
- if (pos == count)
- {
- return nil;
+ {
+ if ([key isEqualToString: keys[pos]] == YES)
+ {
+ break;
+ }
+ }
+ if (pos == count)
+ {
+ for (pos = 0; pos < count; pos++)
+ {
+ if ([key caseInsensitiveCompare: keys[pos]] == NSOrderedSame)
+ {
+ break;
+ }
+ }
+ }
+
+ if (pos != count)
+ {
+ return [self objectAtIndex: pos];
+ }
+ }
+ return nil;
+}
+
+- (void) replaceObjectAtIndex: (NSUInteger)index withObject: (id)anObject
+{
+ SUBCLASS_RESPONSIBILITY
+}
+
+- (void) setObject: (id)anObject forKey: (NSString*)aKey
+{
+ NSUInteger count = [self count];
+
+ if (count > 0)
+ {
+ NSUInteger pos;
+ id keys[count];
+
+ if (anObject == nil)
+ {
+ anObject = null;
+ }
+ [self getKeys: keys];
+ for (pos = 0; pos < count; pos++)
+ {
+ if ([aKey isEqualToString: keys[pos]] == YES)
+ {
+ break;
+ }
+ }
+ if (pos == count)
+ {
+ for (pos = 0; pos < count; pos++)
+ {
+ if ([aKey caseInsensitiveCompare: keys[pos]] == NSOrderedSame)
+ {
+ break;
+ }
+ }
+ }
+
+ if (pos == count)
+ {
+ [NSException raise: NSInvalidArgumentException
+ format: @"Bad key (%@) in -setObject:forKey:", aKey];
+ }
+ else
+ {
+ [self replaceObjectAtIndex: pos withObject: anObject];
+ }
}
else
- {
- return [self objectAtIndex: pos];
- }
-}
-
-- (void) replaceObjectAtIndex: (NSUInteger)index withObject: (id)anObject
-{
- SUBCLASS_RESPONSIBILITY
-}
-
-- (void) setObject: (id)anObject forKey: (NSString*)aKey
-{
- unsigned count = [self count];
- unsigned pos;
- id keys[count];
-
- if (anObject == nil)
- {
- anObject = null;
- }
- [self getKeys: keys];
- for (pos = 0; pos < count; pos++)
- {
- if ([aKey isEqualToString: keys[pos]] == YES)
- {
- break;
- }
- }
- if (pos == count)
- {
- for (pos = 0; pos < count; pos++)
- {
- if ([aKey caseInsensitiveCompare: keys[pos]] == NSOrderedSame)
- {
- break;
- }
- }
- }
-
- if (pos == count)
{
[NSException raise: NSInvalidArgumentException
format: @"Bad key (%@) in -setObject:forKey:", aKey];
}
- else
- {
- [self replaceObjectAtIndex: pos withObject: anObject];
- }
}
- (NSUInteger) sizeInBytes: (NSMutableSet*)exclude
{
NSUInteger size = [super sizeInBytes: exclude];
-
- if (size > 0)
+ NSUInteger count = [self count];
+
+ if (size > 0 && count > 0)
{
NSUInteger pos;
- NSUInteger count = [self count];
id vals[count];
[self getObjects: vals];
@@ -750,10 +776,10 @@
}
o = [self existingClient: reference];
- if (o == nil)
- {
- o = [[SQLClient alloc] initWithConfiguration: config name: reference];
- [o autorelease];
+ if (nil == o)
+ {
+ o = [[[SQLClient alloc] initWithConfiguration: config name: reference]
+ autorelease];
}
return o;
}
@@ -1637,6 +1663,12 @@
}
}
[clientsLock unlock];
+}
+
+- (id) retain
+{
+ NSIncrementExtraRefCount(self);
+ return self;
}
- (void) rollback
@@ -3699,8 +3731,11 @@
- (id) initWithCapacity: (NSUInteger)capacity
{
- DESTROY(content);
- content = [[NSMutableDictionary alloc] initWithCapacity: capacity];
+ if (nil != (self = [super init]))
+ {
+ DESTROY(content);
+ content = [[NSMutableDictionary alloc] initWithCapacity: capacity];
+ }
return self;
}
@@ -3752,9 +3787,12 @@
- (id) initWithCapacity: (NSUInteger)capacity
{
- DESTROY(content);
- content = [[NSCountedSet alloc] initWithCapacity: capacity];
- added = 0;
+ if (nil != (self = [super init]))
+ {
+ DESTROY(content);
+ content = [[NSCountedSet alloc] initWithCapacity: capacity];
+ added = 0;
+ }
return self;
}
_______________________________________________
Gnustep-cvs mailing list
[email protected]
https://mail.gna.org/listinfo/gnustep-cvs