static analyzer tweaks

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@36523 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
rfm 2013-04-14 09:04:40 +00:00
parent 4ae6afbfc6
commit d68d872655
10 changed files with 110 additions and 97 deletions

View file

@ -1361,6 +1361,7 @@ setNonBlocking(SOCKET fd)
struct sockaddr sin;
socklen_t size = sizeof(sin);
memset(&sin, '\0', size);
if ([key isEqualToString: GSStreamLocalAddressKey])
{
if (getsockname(s, (struct sockaddr*)&sin, &size) != -1)

View file

@ -596,7 +596,7 @@ static NSAffineTransformStruct identityTransform = {
- (id) initWithCoder: (NSCoder*)aCoder
{
NSAffineTransformStruct replace;
NSAffineTransformStruct replace = identityTransform;
if ([aCoder allowsKeyedCoding])
{

View file

@ -244,7 +244,7 @@ static unsigned systemVersion = MAX_SUPPORTED_SYSTEM_VERSION;
- (id) decodeObject
{
id o;
id o = nil;
[self decodeValueOfObjCType: @encode(id) at: &o];
return AUTORELEASE(o);
@ -253,7 +253,7 @@ static unsigned systemVersion = MAX_SUPPORTED_SYSTEM_VERSION;
- (id) decodePropertyList
{
id o;
id d;
id d = nil;
[self decodeValueOfObjCType: @encode(id) at: &d];
if (d != nil)

View file

@ -609,20 +609,23 @@ GSListModules()
- (NSArray*) symbols
{
#if defined(HAVE_BACKTRACE)
if (nil == symbols)
{
NSUInteger count = [addresses count];
if (count > 0)
{
#if defined(HAVE_BACKTRACE)
char **strs;
void **addr;
NSString **symbolArray;
unsigned count;
int i;
NSUInteger i;
count = [addresses count];
addr = alloca(count * sizeof(void*));
for (i = 0; i < count; i++)
{
addr[i] = (void*)[[addresses objectAtIndex: i] unsignedIntegerValue];
addr[i] = (void*)[[addresses objectAtIndex: i]
unsignedIntegerValue];
}
strs = backtrace_symbols(addr, count);
@ -633,18 +636,13 @@ GSListModules()
}
symbols = [[NSArray alloc] initWithObjects: symbolArray count: count];
free(strs);
}
#elif defined(USE_BINUTILS)
if (nil == symbols)
{
NSMutableArray *a;
int i;
int n;
NSUInteger i;
n = [addresses count];
a = [[NSMutableArray alloc] initWithCapacity: n];
a = [[NSMutableArray alloc] initWithCapacity: count];
for (i = 0; i < n; i++)
for (i = 0; i < count; i++)
{
GSFunctionInfo *aFrame = nil;
void *address;
@ -704,8 +702,13 @@ GSListModules()
}
symbols = [a copy];
[a release];
}
#endif
}
else
{
symbols = [NSArray new];
}
}
return symbols;
}

View file

@ -758,7 +758,6 @@ static char **_gnu_noobjc_env = NULL;
if (_gnu_noobjc_argv == NULL)
goto malloc_error;
ifp = fopen(proc_file_name,"r");
//freopen(proc_file_name, "r", ifp);
if (ifp == NULL)
@ -781,17 +780,25 @@ static char **_gnu_noobjc_env = NULL;
argument++;
length = 0;
if (c == EOF) // End of command line
{
_gnu_noobjc_argc = argument;
break;
}
}
}
fclose(ifp);
ifp = fopen(proc_file_name,"r");
//freopen(proc_file_name, "r", ifp);
if (ifp == NULL)
{
if (0 != _gnu_noobjc_argv)
{
for (c = 0; c < _gnu_noobjc_argc; c++)
{
free(_gnu_noobjc_argv[c]);
}
free(_gnu_noobjc_argv);
}
goto proc_fs_error;
}
argument = 0;

View file

@ -717,12 +717,12 @@ static inline BOOL timerInvalidated(NSTimer *t)
GSRunLoopThreadInfo *info = GSRunLoopInfoForThread(nil);
NSRunLoop *current = info->loop;
if (current == nil)
if (nil == current)
{
current = info->loop = [[self alloc] _init];
/* If this is the main thread, set up a housekeeping timer.
*/
if ([GSCurrentThread() isMainThread] == YES)
if (nil != current && [GSCurrentThread() isMainThread] == YES)
{
NSAutoreleasePool *arp = [NSAutoreleasePool new];
GSRunLoopCtxt *context;

View file

@ -1439,7 +1439,7 @@ static NSUInteger urlAlign;
memcpy(tmp, myData->path, l + 1);
}
}
else if (_baseURL == nil)
else if (nil == _baseURL)
{
if (myData->path != 0)
{
@ -1447,7 +1447,7 @@ static NSUInteger urlAlign;
memcpy(tmp, myData->path, l + 1);
}
}
else if (*myData->path == 0)
else if (0 == myData->path || 0 == *myData->path)
{
if (baseData->hasNoPath == NO)
{

View file

@ -1446,9 +1446,9 @@ NSLog(@"_processTag <%@%@ %@>", flag?@"/": @"", tag, attributes);
len = this->cp - ep - 1;
*result = [self _newEntity: ep length: len];
if (entity == *result)
if (&entity == result)
{
[entity release]; // Won't be used
[*result release]; // Won't be used
}
return YES;
}

View file

@ -29,6 +29,7 @@
#endif
#import "GNUstepBase/GSConfig.h"
#import "GNUstepBase/GSVersionMacros.h"
/* Set localisation macro for use within the base library itsself.
*/

View file

@ -2289,6 +2289,7 @@ handle_accept()
socklen_t len = sizeof(sa);
int desc;
memset(&sa, '\0', len);
desc = accept(tcp_desc, (void*)&sa, &len);
if (desc >= 0)
{