mirror of
https://github.com/gnustep/libs-base.git
synced 2025-05-31 16:50:58 +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
4ae6afbfc6
commit
d68d872655
10 changed files with 110 additions and 97 deletions
|
@ -1361,6 +1361,7 @@ setNonBlocking(SOCKET fd)
|
||||||
struct sockaddr sin;
|
struct sockaddr sin;
|
||||||
socklen_t size = sizeof(sin);
|
socklen_t size = sizeof(sin);
|
||||||
|
|
||||||
|
memset(&sin, '\0', size);
|
||||||
if ([key isEqualToString: GSStreamLocalAddressKey])
|
if ([key isEqualToString: GSStreamLocalAddressKey])
|
||||||
{
|
{
|
||||||
if (getsockname(s, (struct sockaddr*)&sin, &size) != -1)
|
if (getsockname(s, (struct sockaddr*)&sin, &size) != -1)
|
||||||
|
|
|
@ -596,7 +596,7 @@ static NSAffineTransformStruct identityTransform = {
|
||||||
|
|
||||||
- (id) initWithCoder: (NSCoder*)aCoder
|
- (id) initWithCoder: (NSCoder*)aCoder
|
||||||
{
|
{
|
||||||
NSAffineTransformStruct replace;
|
NSAffineTransformStruct replace = identityTransform;
|
||||||
|
|
||||||
if ([aCoder allowsKeyedCoding])
|
if ([aCoder allowsKeyedCoding])
|
||||||
{
|
{
|
||||||
|
|
|
@ -244,7 +244,7 @@ static unsigned systemVersion = MAX_SUPPORTED_SYSTEM_VERSION;
|
||||||
|
|
||||||
- (id) decodeObject
|
- (id) decodeObject
|
||||||
{
|
{
|
||||||
id o;
|
id o = nil;
|
||||||
|
|
||||||
[self decodeValueOfObjCType: @encode(id) at: &o];
|
[self decodeValueOfObjCType: @encode(id) at: &o];
|
||||||
return AUTORELEASE(o);
|
return AUTORELEASE(o);
|
||||||
|
@ -253,7 +253,7 @@ static unsigned systemVersion = MAX_SUPPORTED_SYSTEM_VERSION;
|
||||||
- (id) decodePropertyList
|
- (id) decodePropertyList
|
||||||
{
|
{
|
||||||
id o;
|
id o;
|
||||||
id d;
|
id d = nil;
|
||||||
|
|
||||||
[self decodeValueOfObjCType: @encode(id) at: &d];
|
[self decodeValueOfObjCType: @encode(id) at: &d];
|
||||||
if (d != nil)
|
if (d != nil)
|
||||||
|
|
|
@ -609,103 +609,106 @@ GSListModules()
|
||||||
|
|
||||||
- (NSArray*) symbols
|
- (NSArray*) symbols
|
||||||
{
|
{
|
||||||
|
if (nil == symbols)
|
||||||
|
{
|
||||||
|
NSUInteger count = [addresses count];
|
||||||
|
|
||||||
|
if (count > 0)
|
||||||
|
{
|
||||||
#if defined(HAVE_BACKTRACE)
|
#if defined(HAVE_BACKTRACE)
|
||||||
if (nil == symbols)
|
char **strs;
|
||||||
{
|
void **addr;
|
||||||
char **strs;
|
NSString **symbolArray;
|
||||||
void **addr;
|
NSUInteger i;
|
||||||
NSString **symbolArray;
|
|
||||||
unsigned count;
|
|
||||||
int i;
|
|
||||||
|
|
||||||
count = [addresses count];
|
addr = alloca(count * sizeof(void*));
|
||||||
addr = alloca(count * sizeof(void*));
|
for (i = 0; i < count; i++)
|
||||||
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)
|
|
||||||
{
|
{
|
||||||
aFrame = [bfi functionForAddress: (void*)(address - base)];
|
addr[i] = (void*)[[addresses objectAtIndex: i]
|
||||||
if (aFrame == nil)
|
unsignedIntegerValue];
|
||||||
{
|
|
||||||
/* 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];
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
|
||||||
|
strs = backtrace_symbols(addr, count);
|
||||||
|
symbolArray = alloca(count * sizeof(NSString*));
|
||||||
|
for (i = 0; i < count; i++)
|
||||||
{
|
{
|
||||||
NSArray *modules;
|
symbolArray[i] = [NSString stringWithUTF8String: strs[i]];
|
||||||
int j;
|
}
|
||||||
int m;
|
symbols = [[NSArray alloc] initWithObjects: symbolArray count: count];
|
||||||
|
free(strs);
|
||||||
|
#elif defined(USE_BINUTILS)
|
||||||
|
NSMutableArray *a;
|
||||||
|
NSUInteger i;
|
||||||
|
|
||||||
modules = GSListModules();
|
a = [[NSMutableArray alloc] initWithCapacity: count];
|
||||||
m = [modules count];
|
|
||||||
for (j = 0; j < m; j++)
|
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];
|
aFrame = [bfi functionForAddress: (void*)(address - base)];
|
||||||
|
if (aFrame == nil)
|
||||||
if ((id)bfi != (id)[NSNull null])
|
|
||||||
{
|
{
|
||||||
|
/* 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];
|
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
|
// not found (?!), add an 'unknown' function
|
||||||
if (aFrame == nil)
|
if (aFrame == nil)
|
||||||
{
|
{
|
||||||
aFrame = [GSFunctionInfo alloc];
|
aFrame = [GSFunctionInfo alloc];
|
||||||
[aFrame initWithModule: nil
|
[aFrame initWithModule: nil
|
||||||
address: address
|
address: address
|
||||||
file: nil
|
file: nil
|
||||||
function: nil
|
function: nil
|
||||||
line: 0];
|
line: 0];
|
||||||
[aFrame autorelease];
|
[aFrame autorelease];
|
||||||
|
}
|
||||||
|
[a addObject: [aFrame description]];
|
||||||
}
|
}
|
||||||
[a addObject: [aFrame description]];
|
symbols = [a copy];
|
||||||
}
|
[a release];
|
||||||
symbols = [a copy];
|
|
||||||
[a release];
|
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
symbols = [NSArray new];
|
||||||
|
}
|
||||||
|
}
|
||||||
return symbols;
|
return symbols;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -758,8 +758,7 @@ static char **_gnu_noobjc_env = NULL;
|
||||||
if (_gnu_noobjc_argv == NULL)
|
if (_gnu_noobjc_argv == NULL)
|
||||||
goto malloc_error;
|
goto malloc_error;
|
||||||
|
|
||||||
|
ifp = fopen(proc_file_name,"r");
|
||||||
ifp=fopen(proc_file_name,"r");
|
|
||||||
//freopen(proc_file_name, "r", ifp);
|
//freopen(proc_file_name, "r", ifp);
|
||||||
if (ifp == NULL)
|
if (ifp == NULL)
|
||||||
{
|
{
|
||||||
|
@ -781,17 +780,25 @@ static char **_gnu_noobjc_env = NULL;
|
||||||
argument++;
|
argument++;
|
||||||
length = 0;
|
length = 0;
|
||||||
if (c == EOF) // End of command line
|
if (c == EOF) // End of command line
|
||||||
break;
|
{
|
||||||
|
_gnu_noobjc_argc = argument;
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fclose(ifp);
|
fclose(ifp);
|
||||||
ifp=fopen(proc_file_name,"r");
|
ifp = fopen(proc_file_name,"r");
|
||||||
//freopen(proc_file_name, "r", ifp);
|
//freopen(proc_file_name, "r", ifp);
|
||||||
if (ifp == NULL)
|
if (ifp == NULL)
|
||||||
{
|
{
|
||||||
for (c = 0; c < _gnu_noobjc_argc; c++)
|
if (0 != _gnu_noobjc_argv)
|
||||||
free(_gnu_noobjc_argv[c]);
|
{
|
||||||
free(_gnu_noobjc_argv);
|
for (c = 0; c < _gnu_noobjc_argc; c++)
|
||||||
|
{
|
||||||
|
free(_gnu_noobjc_argv[c]);
|
||||||
|
}
|
||||||
|
free(_gnu_noobjc_argv);
|
||||||
|
}
|
||||||
goto proc_fs_error;
|
goto proc_fs_error;
|
||||||
}
|
}
|
||||||
argument = 0;
|
argument = 0;
|
||||||
|
|
|
@ -717,12 +717,12 @@ static inline BOOL timerInvalidated(NSTimer *t)
|
||||||
GSRunLoopThreadInfo *info = GSRunLoopInfoForThread(nil);
|
GSRunLoopThreadInfo *info = GSRunLoopInfoForThread(nil);
|
||||||
NSRunLoop *current = info->loop;
|
NSRunLoop *current = info->loop;
|
||||||
|
|
||||||
if (current == nil)
|
if (nil == current)
|
||||||
{
|
{
|
||||||
current = info->loop = [[self alloc] _init];
|
current = info->loop = [[self alloc] _init];
|
||||||
/* If this is the main thread, set up a housekeeping timer.
|
/* 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];
|
NSAutoreleasePool *arp = [NSAutoreleasePool new];
|
||||||
GSRunLoopCtxt *context;
|
GSRunLoopCtxt *context;
|
||||||
|
|
|
@ -1439,7 +1439,7 @@ static NSUInteger urlAlign;
|
||||||
memcpy(tmp, myData->path, l + 1);
|
memcpy(tmp, myData->path, l + 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (_baseURL == nil)
|
else if (nil == _baseURL)
|
||||||
{
|
{
|
||||||
if (myData->path != 0)
|
if (myData->path != 0)
|
||||||
{
|
{
|
||||||
|
@ -1447,7 +1447,7 @@ static NSUInteger urlAlign;
|
||||||
memcpy(tmp, myData->path, l + 1);
|
memcpy(tmp, myData->path, l + 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (*myData->path == 0)
|
else if (0 == myData->path || 0 == *myData->path)
|
||||||
{
|
{
|
||||||
if (baseData->hasNoPath == NO)
|
if (baseData->hasNoPath == NO)
|
||||||
{
|
{
|
||||||
|
|
|
@ -1446,9 +1446,9 @@ NSLog(@"_processTag <%@%@ %@>", flag?@"/": @"", tag, attributes);
|
||||||
len = this->cp - ep - 1;
|
len = this->cp - ep - 1;
|
||||||
|
|
||||||
*result = [self _newEntity: ep length: len];
|
*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;
|
return YES;
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,6 +29,7 @@
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#import "GNUstepBase/GSConfig.h"
|
#import "GNUstepBase/GSConfig.h"
|
||||||
|
#import "GNUstepBase/GSVersionMacros.h"
|
||||||
|
|
||||||
/* Set localisation macro for use within the base library itsself.
|
/* Set localisation macro for use within the base library itsself.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -2289,6 +2289,7 @@ handle_accept()
|
||||||
socklen_t len = sizeof(sa);
|
socklen_t len = sizeof(sa);
|
||||||
int desc;
|
int desc;
|
||||||
|
|
||||||
|
memset(&sa, '\0', len);
|
||||||
desc = accept(tcp_desc, (void*)&sa, &len);
|
desc = accept(tcp_desc, (void*)&sa, &len);
|
||||||
if (desc >= 0)
|
if (desc >= 0)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue