ソースを参照

Fixed errors detected by static code analyzer.

Darryl Gough 13 年 前
コミット
64383a84ec

+ 2 - 2
gameplay/src/Animation.cpp

@@ -344,7 +344,7 @@ Animation::Channel* Animation::createChannel(AnimationTarget* target, int proper
     normalizedKeyTimes[i] = 1.0f;
     curve->setPoint(i, normalizedKeyTimes[i], keyValues + pointOffset, (Curve::InterpolationType) type);
 
-    SAFE_DELETE(normalizedKeyTimes);
+    SAFE_DELETE_ARRAY(normalizedKeyTimes);
 
     Channel* channel = new Channel(this, target, propertyId, curve, duration);
     curve->release();
@@ -386,7 +386,7 @@ Animation::Channel* Animation::createChannel(AnimationTarget* target, int proper
     normalizedKeyTimes[i] = 1.0f;
     curve->setPoint(i, normalizedKeyTimes[i], keyValues + pointOffset, (Curve::InterpolationType) type, keyInValue + pointOffset, keyOutValue + pointOffset);
 
-    SAFE_DELETE(normalizedKeyTimes);
+    SAFE_DELETE_ARRAY(normalizedKeyTimes);
 
     Channel* channel = new Channel(this, target, propertyId, curve, duration);
     curve->release();

+ 4 - 4
gameplay/src/AnimationTarget.cpp

@@ -261,10 +261,10 @@ Animation* AnimationTarget::createAnimation(const char* id, Properties* animatio
         animation = createAnimation(id, propertyId, keyCount, keyTimes, keyValues, (Curve::InterpolationType) curve);
     }
 
-    SAFE_DELETE(keyOut);
-    SAFE_DELETE(keyIn);
-    SAFE_DELETE(keyValues);
-    SAFE_DELETE(keyTimes);
+    SAFE_DELETE_ARRAY(keyOut);
+    SAFE_DELETE_ARRAY(keyIn);
+    SAFE_DELETE_ARRAY(keyValues);
+    SAFE_DELETE_ARRAY(keyTimes);
 
     Properties* pClip = animationProperties->getNextNamespace();
     if (pClip && std::strcmp(pClip->getNamespace(), "clip") == 0)

+ 1 - 1
gameplay/src/FileSystem.cpp

@@ -335,7 +335,7 @@ void createFileFromAsset(const char* path)
     std::string directoryPath = fullPath.substr(0, fullPath.rfind('/'));
     struct stat s;
     if (stat(directoryPath.c_str(), &s) != 0)
-        makepath(directoryPath.c_str(), 0777);
+        makepath(directoryPath, 0777);
 
     // To ensure that the files on the file system corresponding to the assets in the APK bundle
     // are always up to date (and in sync), we copy them from the APK to the file system once

+ 0 - 1
gameplay/src/Joystick.cpp

@@ -95,7 +95,6 @@ void Joystick::initialize(Theme::Style* style, Properties* properties)
         if (inner)
         {
             const Rectangle& rect = inner->getRegion();
-            float radiusx2 = _radius * 2;;
             _screenRegion.width = rect.width;
             _screenRegion.height = rect.height;
         }

+ 1 - 4
gameplay/src/Material.cpp

@@ -21,10 +21,7 @@ Material::~Material()
     for (unsigned int i = 0, count = _techniques.size(); i < count; ++i)
     {
         Technique* technique = _techniques[i];
-        if (technique)
-        {
-            SAFE_RELEASE(technique);
-        }
+        SAFE_RELEASE(technique);
     }
 }
 

+ 0 - 1
gameplay/src/PlatformQNX.cpp

@@ -866,7 +866,6 @@ int Platform::enterMessagePump()
     int position[2];
     int domain;
     mtouch_event_t touchEvent;
-    int touchId = 0;
     bool suspended = false;
 
     // Get the initial time.

+ 0 - 1
gameplay/src/PlatformWin32.cpp

@@ -849,7 +849,6 @@ error:
 int Platform::enterMessagePump()
 {
     GP_ASSERT(_game);
-    int rc = 0;
 
     // Get the initial time.
     LARGE_INTEGER tps;

+ 1 - 3
gameplay/src/Properties.cpp

@@ -466,7 +466,7 @@ void Properties::mergeWith(Properties* overrides)
         this->_properties[name] = value;
         name = overrides->getNextProperty(&value);
     }
-    SAFE_DELETE(value);
+    SAFE_DELETE_ARRAY(value);
     this->_propertiesItr = this->_properties.end();
 
     // Merge all common nested namespaces, add new ones.
@@ -998,11 +998,9 @@ Properties* getPropertiesFromNamespacePath(Properties* properties, const std::ve
 {
     // If the url references a specific namespace within the file,
     // return the specified namespace or notify the user if it cannot be found.
-    Properties* originalProperties = properties;
     if (namespacePath.size() > 0)
     {
         unsigned int size = namespacePath.size();
-        const char* tmp = namespacePath[0].c_str();
         properties->rewind();
         Properties* iter = properties->getNextNamespace();
         for (unsigned int i = 0; i < size;)

+ 1 - 1
gameplay/src/Quaternion.cpp

@@ -57,7 +57,7 @@ bool Quaternion::isIdentity() const
 
 bool Quaternion::isZero() const
 {
-    return x == 0.0f && y == 0.0f && z == 0.0f && z == 0.0f;
+    return x == 0.0f && y == 0.0f && z == 0.0f && w == 0.0f;
 }
 
 void Quaternion::createFromRotationMatrix(const Matrix& m, Quaternion* dst)

+ 0 - 6
gameplay/src/SceneLoader.cpp

@@ -88,7 +88,6 @@ Scene* SceneLoader::loadInternal(const char* url)
 
     // Find the physics properties object.
     Properties* physics = NULL;
-    Properties* ns = NULL;
     sceneProperties->rewind();
     while (true)
     {
@@ -201,10 +200,6 @@ void SceneLoader::applyNodeProperty(SceneNode& sceneNode, Node* node, const Prop
             break;
         }
         case SceneNodeProperty::MATERIAL:
-            {
-                const char* id = node->getId();
-                id = NULL;
-            }
             if (!node->getModel())
             {
                 GP_ERROR("Attempting to set a material on node '%s', which has no model.", sceneNode._nodeID);
@@ -288,7 +283,6 @@ void SceneLoader::applyNodeProperty(SceneNode& sceneNode, Node* node, const Prop
     {
         // Handle scale, rotate and translate.
         Properties* np = sceneProperties->getNamespace(sceneNode._nodeID);
-        const char* name = NULL;
 
         switch (snp._type)
         {

+ 1 - 0
gameplay/src/Texture.cpp

@@ -401,6 +401,7 @@ GLubyte* Texture::readCompressedPVRTC(const char* path, FILE* file, GLsizei* wid
     read = fread(data, 1, dataSize, file);
     if (read != dataSize)
     {
+		SAFE_DELETE_ARRAY(data);
         GP_ERROR("Failed to read texture data from PVR file '%s'.", path);
         return NULL;
     }

+ 1 - 1
gameplay/src/Vector4.cpp

@@ -91,7 +91,7 @@ bool Vector4::isZero() const
 
 bool Vector4::isOne() const
 {
-    return x == 1.0f && y == 1.0f && z == 1.0f && z == 1.0f;
+    return x == 1.0f && y == 1.0f && z == 1.0f && w == 1.0f;
 }
 
 float Vector4::angle(const Vector4& v1, const Vector4& v2)