mirror of
https://github.com/gnustep/libs-base.git
synced 2025-04-22 16:33:29 +00:00
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:
parent
0fdebe8513
commit
54ff9b7de5
10 changed files with 110 additions and 97 deletions
|
@ -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)
|
||||
|
|
|
@ -596,7 +596,7 @@ static NSAffineTransformStruct identityTransform = {
|
|||
|
||||
- (id) initWithCoder: (NSCoder*)aCoder
|
||||
{
|
||||
NSAffineTransformStruct replace;
|
||||
NSAffineTransformStruct replace = identityTransform;
|
||||
|
||||
if ([aCoder allowsKeyedCoding])
|
||||
{
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -609,103 +609,106 @@ GSListModules()
|
|||
|
||||
- (NSArray*) symbols
|
||||
{
|
||||
if (nil == symbols)
|
||||
{
|
||||
NSUInteger count = [addresses count];
|
||||
|
||||
if (count > 0)
|
||||
{
|
||||
#if defined(HAVE_BACKTRACE)
|
||||
if (nil == symbols)
|
||||
{
|
||||
char **strs;
|
||||
void **addr;
|
||||
NSString **symbolArray;
|
||||
unsigned count;
|
||||
int i;
|
||||
char **strs;
|
||||
void **addr;
|
||||
NSString **symbolArray;
|
||||
NSUInteger i;
|
||||
|
||||
count = [addresses count];
|
||||
addr = alloca(count * sizeof(void*));
|
||||
for (i = 0; i < count; i++)
|
||||
{
|
||||
addr[i] = (void*)[[addresses objectAtIndex: i] unsignedIntegerValue];
|
||||
}
|
||||
|
||||
strs = backtrace_symbols(addr, count);
|
||||
symbolArray = alloca(count * sizeof(NSString*));
|
||||
for (i = 0; i < count; i++)
|
||||
{
|
||||
symbolArray[i] = [NSString stringWithUTF8String: strs[i]];
|
||||
}
|
||||
symbols = [[NSArray alloc] initWithObjects: symbolArray count: count];
|
||||
free(strs);
|
||||
}
|
||||
#elif defined(USE_BINUTILS)
|
||||
if (nil == symbols)
|
||||
{
|
||||
NSMutableArray *a;
|
||||
int i;
|
||||
int n;
|
||||
|
||||
n = [addresses count];
|
||||
a = [[NSMutableArray alloc] initWithCapacity: n];
|
||||
|
||||
for (i = 0; i < n; i++)
|
||||
{
|
||||
GSFunctionInfo *aFrame = nil;
|
||||
void *address;
|
||||
void *base;
|
||||
NSString *modulePath;
|
||||
GSBinaryFileInfo *bfi;
|
||||
|
||||
address = (void*)[[addresses objectAtIndex: i] pointerValue];
|
||||
modulePath = GSPrivateBaseAddress(address, &base);
|
||||
if (modulePath != nil && (bfi = GSLoadModule(modulePath)) != nil)
|
||||
addr = alloca(count * sizeof(void*));
|
||||
for (i = 0; i < count; i++)
|
||||
{
|
||||
aFrame = [bfi functionForAddress: (void*)(address - base)];
|
||||
if (aFrame == nil)
|
||||
{
|
||||
/* We know we have the right module but function lookup
|
||||
* failed ... perhaps we need to use the absolute
|
||||
* address rather than offest by 'base' in this case.
|
||||
*/
|
||||
aFrame = [bfi functionForAddress: address];
|
||||
}
|
||||
addr[i] = (void*)[[addresses objectAtIndex: i]
|
||||
unsignedIntegerValue];
|
||||
}
|
||||
else
|
||||
|
||||
strs = backtrace_symbols(addr, count);
|
||||
symbolArray = alloca(count * sizeof(NSString*));
|
||||
for (i = 0; i < count; i++)
|
||||
{
|
||||
NSArray *modules;
|
||||
int j;
|
||||
int m;
|
||||
symbolArray[i] = [NSString stringWithUTF8String: strs[i]];
|
||||
}
|
||||
symbols = [[NSArray alloc] initWithObjects: symbolArray count: count];
|
||||
free(strs);
|
||||
#elif defined(USE_BINUTILS)
|
||||
NSMutableArray *a;
|
||||
NSUInteger i;
|
||||
|
||||
modules = GSListModules();
|
||||
m = [modules count];
|
||||
for (j = 0; j < m; j++)
|
||||
a = [[NSMutableArray alloc] initWithCapacity: count];
|
||||
|
||||
for (i = 0; i < count; i++)
|
||||
{
|
||||
GSFunctionInfo *aFrame = nil;
|
||||
void *address;
|
||||
void *base;
|
||||
NSString *modulePath;
|
||||
GSBinaryFileInfo *bfi;
|
||||
|
||||
address = (void*)[[addresses objectAtIndex: i] pointerValue];
|
||||
modulePath = GSPrivateBaseAddress(address, &base);
|
||||
if (modulePath != nil && (bfi = GSLoadModule(modulePath)) != nil)
|
||||
{
|
||||
bfi = [modules objectAtIndex: j];
|
||||
|
||||
if ((id)bfi != (id)[NSNull null])
|
||||
aFrame = [bfi functionForAddress: (void*)(address - base)];
|
||||
if (aFrame == nil)
|
||||
{
|
||||
/* We know we have the right module but function lookup
|
||||
* failed ... perhaps we need to use the absolute
|
||||
* address rather than offest by 'base' in this case.
|
||||
*/
|
||||
aFrame = [bfi functionForAddress: address];
|
||||
if (aFrame != nil)
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
NSArray *modules;
|
||||
int j;
|
||||
int m;
|
||||
|
||||
modules = GSListModules();
|
||||
m = [modules count];
|
||||
for (j = 0; j < m; j++)
|
||||
{
|
||||
bfi = [modules objectAtIndex: j];
|
||||
|
||||
if ((id)bfi != (id)[NSNull null])
|
||||
{
|
||||
break;
|
||||
aFrame = [bfi functionForAddress: address];
|
||||
if (aFrame != nil)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// not found (?!), add an 'unknown' function
|
||||
if (aFrame == nil)
|
||||
{
|
||||
aFrame = [GSFunctionInfo alloc];
|
||||
[aFrame initWithModule: nil
|
||||
address: address
|
||||
file: nil
|
||||
function: nil
|
||||
line: 0];
|
||||
[aFrame autorelease];
|
||||
// not found (?!), add an 'unknown' function
|
||||
if (aFrame == nil)
|
||||
{
|
||||
aFrame = [GSFunctionInfo alloc];
|
||||
[aFrame initWithModule: nil
|
||||
address: address
|
||||
file: nil
|
||||
function: nil
|
||||
line: 0];
|
||||
[aFrame autorelease];
|
||||
}
|
||||
[a addObject: [aFrame description]];
|
||||
}
|
||||
[a addObject: [aFrame description]];
|
||||
}
|
||||
symbols = [a copy];
|
||||
[a release];
|
||||
}
|
||||
symbols = [a copy];
|
||||
[a release];
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
symbols = [NSArray new];
|
||||
}
|
||||
}
|
||||
return symbols;
|
||||
}
|
||||
|
||||
|
|
|
@ -758,8 +758,7 @@ static char **_gnu_noobjc_env = NULL;
|
|||
if (_gnu_noobjc_argv == NULL)
|
||||
goto malloc_error;
|
||||
|
||||
|
||||
ifp=fopen(proc_file_name,"r");
|
||||
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
|
||||
break;
|
||||
{
|
||||
_gnu_noobjc_argc = argument;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
fclose(ifp);
|
||||
ifp=fopen(proc_file_name,"r");
|
||||
ifp = fopen(proc_file_name,"r");
|
||||
//freopen(proc_file_name, "r", ifp);
|
||||
if (ifp == NULL)
|
||||
{
|
||||
for (c = 0; c < _gnu_noobjc_argc; c++)
|
||||
free(_gnu_noobjc_argv[c]);
|
||||
free(_gnu_noobjc_argv);
|
||||
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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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)
|
||||
{
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -29,6 +29,7 @@
|
|||
#endif
|
||||
|
||||
#import "GNUstepBase/GSConfig.h"
|
||||
#import "GNUstepBase/GSVersionMacros.h"
|
||||
|
||||
/* Set localisation macro for use within the base library itsself.
|
||||
*/
|
||||
|
|
|
@ -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)
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue