Fixes for bugs revealed by static analysis.

git-svn-id: http://svn.berlios.de/svnroot/repos/oolite-linux/trunk@1685 127b21dd-08f5-0310-b4b7-95ae10353056
This commit is contained in:
Jens Ayton 2008-07-04 18:48:57 +00:00
parent f2c07b5ee7
commit 635d51d98b
8 changed files with 31 additions and 26 deletions

View File

@ -181,7 +181,9 @@ enum
- (BOOL)prepareToPlayWithContext:(OOCASoundRenderContext *)outContext looped:(BOOL)inLoop
{
BOOL OK = YES;
OOCAStreamingSoundRenderContext context;
OOCAStreamingSoundRenderContext context = NULL;
assert(outContext != NULL);
if (OK)
{
@ -192,6 +194,10 @@ enum
context->loop = inLoop;
context->empty = YES;
}
else
{
OK = NO;
}
}
if (OK)

View File

@ -478,7 +478,6 @@ noteChangedConfigrationValue:(in id)newValue
if (_status == kOOTCPClientStartedConnectionStage2)
{
_status = kOOTCPClientConnected;
hostName = [_host name];
// Build "Connected..." message with two optional parts, console identity and host name.
connectedMessage = [NSMutableString stringWithString:@"Connected to external debug console"];

View File

@ -305,7 +305,7 @@ MA 02110-1301, USA.
thing_uids_found[things_found++] = found_target;
}
}
//
if (found_target != NO_TARGET)
{
found_target = thing_uids_found[ranrot_rand() % things_found];

View File

@ -54,7 +54,7 @@ BOOL CheckOpenGLErrors(NSString *format, ...)
if (format == nil) format = @"<unknown>";
va_start(args, format);
format = [[NSString alloc] initWithFormat:format arguments:args];
format = [[[NSString alloc] initWithFormat:format arguments:args] autorelease];
va_end(args);
OOLog(kOOLogOpenGLError, @"OpenGL error: \"%s\" (%#x), context: %@", errString, errCode, format);
}

View File

@ -328,6 +328,7 @@ static NSArray *TokensFromXML(NSData *data, NSString *whereFrom)
else
{
scanner = [NSScanner scannerWithString:xmlString];
[xmlString release];
OOLogPushIndent();
NS_DURING

View File

@ -88,8 +88,8 @@ void quaternion_into_gl_matrix(Quaternion quat, GLfloat *glmat)
Vector vector_forward_from_quaternion(Quaternion quat)
{
GLfloat w, wz, wy, wx;
GLfloat x, xz, xy, xx;
GLfloat w, wy, wx;
GLfloat x, xz, xx;
GLfloat y, yz, yy;
GLfloat z, zz;
Vector res;
@ -100,10 +100,9 @@ Vector vector_forward_from_quaternion(Quaternion quat)
x = quat.x;
xx = 2.0f * x; yy = 2.0f * y; zz = 2.0f * z;
wx = w * xx; wy = w * yy; wz = w * zz;
xx = x * xx; xy = x * yy; xz = x * zz;
wx = w * xx; wy = w * yy;
xx = x * xx; xz = x * zz;
yy = y * yy; yz = y * zz;
zz = z * zz;
res.x = xz - wy;
res.y = yz + wx;
@ -116,8 +115,8 @@ Vector vector_forward_from_quaternion(Quaternion quat)
Vector vector_up_from_quaternion(Quaternion quat)
{
GLfloat w, wz, wy, wx;
GLfloat x, xz, xy, xx;
GLfloat w, wz, wx;
GLfloat x, xy, xx;
GLfloat y, yz, yy;
GLfloat z, zz;
Vector res;
@ -128,9 +127,9 @@ Vector vector_up_from_quaternion(Quaternion quat)
x = quat.x;
xx = 2.0f * x; yy = 2.0f * y; zz = 2.0f * z;
wx = w * xx; wy = w * yy; wz = w * zz;
xx = x * xx; xy = x * yy; xz = x * zz;
yy = y * yy; yz = y * zz;
wx = w * xx; wz = w * zz;
xx = x * xx; xy = x * yy;
yz = y * zz;
zz = z * zz;
res.x = xy + wz;
@ -144,9 +143,9 @@ Vector vector_up_from_quaternion(Quaternion quat)
Vector vector_right_from_quaternion(Quaternion quat)
{
GLfloat w, wz, wy, wx;
GLfloat x, xz, xy, xx;
GLfloat y, yz, yy;
GLfloat w, wz, wy;
GLfloat x, xz, xy;
GLfloat y, yy;
GLfloat z, zz;
Vector res;
@ -155,10 +154,10 @@ Vector vector_right_from_quaternion(Quaternion quat)
y = quat.y;
x = quat.x;
xx = 2.0f * x; yy = 2.0f * y; zz = 2.0f * z;
wx = w * xx; wy = w * yy; wz = w * zz;
xx = x * xx; xy = x * yy; xz = x * zz;
yy = y * yy; yz = y * zz;
yy = 2.0f * y; zz = 2.0f * z;
wy = w * yy; wz = w * zz;
xy = x * yy; xz = x * zz;
yy = y * yy;
zz = z * zz;
res.x = 1.0f - yy - zz;
@ -204,7 +203,7 @@ void basis_vectors_from_quaternion(Quaternion quat, Vector *outRight, Vector *ou
outUp->y = 1.0f - xx - zz;
outUp->z = yz - wx;
if (outUp->x || outUp->y || outUp->z) *outRight = vector_normal(*outRight);
if (outUp->x || outUp->y || outUp->z) *outUp = vector_normal(*outUp);
else *outUp = make_vector(0.0f, 1.0f, 0.0f);
}
@ -214,7 +213,7 @@ void basis_vectors_from_quaternion(Quaternion quat, Vector *outRight, Vector *ou
outForward->y = yz + wx;
outForward->z = 1.0f - xx - yy;
if (outForward->x || outForward->y || outForward->z) *outRight = vector_normal(*outRight);
if (outForward->x || outForward->y || outForward->z) *outForward = vector_normal(*outForward);
else *outForward = make_vector(0.0f, 0.0f, 1.0f);
}
}

View File

@ -786,7 +786,7 @@ static BOOL CheckNameConflict(NSString *lcName, NSDictionary *directoryCases, NS
if (existing != nil)
{
if (outExisting != NULL) *outExisting = existing;
if (outExistingType != NULL) *outExisting = @"directory";
if (outExistingType != NULL) *outExistingType = @"directory";
return YES;
}
@ -794,7 +794,7 @@ static BOOL CheckNameConflict(NSString *lcName, NSDictionary *directoryCases, NS
if (existing != nil)
{
if (outExisting != NULL) *outExisting = existing;
if (outExistingType != NULL) *outExisting = @"file";
if (outExistingType != NULL) *outExistingType = @"file";
return YES;
}

View File

@ -6943,7 +6943,7 @@ double estimatedTimeForJourney(double distance, int hops)
ranrot_srand(super_rand2);
// select a random point in the histogram
qr = super_rand2 % total_quantity;
qr = total_quantity ? (super_rand2 % total_quantity) : 0;
co_type = 0;
while (qr > 0)