mirror of
				https://github.com/OpenMW/openmw.git
				synced 2025-10-30 02:56:44 +00:00 
			
		
		
		
	Merge pull request #3024 from akortunov/coverity
Fix some issues, found by CoverityScan
This commit is contained in:
		
						commit
						0eaac4b522
					
				
					 9 changed files with 29 additions and 10 deletions
				
			
		|  | @ -590,7 +590,9 @@ namespace MWMechanics | ||||||
| 
 | 
 | ||||||
|         if (!actorState.isTurningToPlayer()) |         if (!actorState.isTurningToPlayer()) | ||||||
|         { |         { | ||||||
|             float angle = std::atan2(dir.x(), dir.y()); |             float from = dir.x(); | ||||||
|  |             float to = dir.y(); | ||||||
|  |             float angle = std::atan2(from, to); | ||||||
|             actorState.setAngleToPlayer(angle); |             actorState.setAngleToPlayer(angle); | ||||||
|             float deltaAngle = Misc::normalizeAngle(angle - actor.getRefData().getPosition().rot[2]); |             float deltaAngle = Misc::normalizeAngle(angle - actor.getRefData().getPosition().rot[2]); | ||||||
|             if (!mSmoothMovement || std::abs(deltaAngle) > osg::DegreesToRadians(60.f)) |             if (!mSmoothMovement || std::abs(deltaAngle) > osg::DegreesToRadians(60.f)) | ||||||
|  | @ -1723,7 +1725,7 @@ namespace MWMechanics | ||||||
|                     shouldAvoidCollision = true; |                     shouldAvoidCollision = true; | ||||||
|                 else if (package->getTypeId() == AiPackageTypeId::Wander && giveWayWhenIdle) |                 else if (package->getTypeId() == AiPackageTypeId::Wander && giveWayWhenIdle) | ||||||
|                 { |                 { | ||||||
|                     if (!dynamic_cast<const AiWander*>(package.get())->isStationary()) |                     if (!static_cast<const AiWander*>(package.get())->isStationary()) | ||||||
|                         shouldAvoidCollision = true; |                         shouldAvoidCollision = true; | ||||||
|                 } |                 } | ||||||
|                 else if (package->getTypeId() == AiPackageTypeId::Combat || package->getTypeId() == AiPackageTypeId::Pursue) |                 else if (package->getTypeId() == AiPackageTypeId::Combat || package->getTypeId() == AiPackageTypeId::Pursue) | ||||||
|  |  | ||||||
|  | @ -142,6 +142,7 @@ namespace MWPhysics | ||||||
| { | { | ||||||
|     PhysicsTaskScheduler::PhysicsTaskScheduler(float physicsDt, std::shared_ptr<btCollisionWorld> collisionWorld) |     PhysicsTaskScheduler::PhysicsTaskScheduler(float physicsDt, std::shared_ptr<btCollisionWorld> collisionWorld) | ||||||
|           : mPhysicsDt(physicsDt) |           : mPhysicsDt(physicsDt) | ||||||
|  |           , mTimeAccum(0.f) | ||||||
|           , mCollisionWorld(std::move(collisionWorld)) |           , mCollisionWorld(std::move(collisionWorld)) | ||||||
|           , mNumJobs(0) |           , mNumJobs(0) | ||||||
|           , mRemainingSteps(0) |           , mRemainingSteps(0) | ||||||
|  |  | ||||||
|  | @ -66,6 +66,9 @@ namespace MWRender | ||||||
|       mIsNearest(false), |       mIsNearest(false), | ||||||
|       mHeight(124.f), |       mHeight(124.f), | ||||||
|       mBaseCameraDistance(Settings::Manager::getFloat("third person camera distance", "Camera")), |       mBaseCameraDistance(Settings::Manager::getFloat("third person camera distance", "Camera")), | ||||||
|  |       mPitch(0.f), | ||||||
|  |       mYaw(0.f), | ||||||
|  |       mRoll(0.f), | ||||||
|       mVanityToggleQueued(false), |       mVanityToggleQueued(false), | ||||||
|       mVanityToggleQueuedValue(false), |       mVanityToggleQueuedValue(false), | ||||||
|       mViewModeToggleQueued(false), |       mViewModeToggleQueued(false), | ||||||
|  | @ -81,6 +84,9 @@ namespace MWRender | ||||||
|       mDynamicCameraDistanceEnabled(false), |       mDynamicCameraDistanceEnabled(false), | ||||||
|       mShowCrosshairInThirdPersonMode(false), |       mShowCrosshairInThirdPersonMode(false), | ||||||
|       mHeadBobbingEnabled(Settings::Manager::getBool("head bobbing", "Camera")), |       mHeadBobbingEnabled(Settings::Manager::getBool("head bobbing", "Camera")), | ||||||
|  |       mHeadBobbingOffset(0.f), | ||||||
|  |       mHeadBobbingWeight(0.f), | ||||||
|  |       mTotalMovement(0.f), | ||||||
|       mDeferredRotation(osg::Vec3f()), |       mDeferredRotation(osg::Vec3f()), | ||||||
|       mDeferredRotationDisabled(false) |       mDeferredRotationDisabled(false) | ||||||
|     { |     { | ||||||
|  |  | ||||||
|  | @ -74,8 +74,8 @@ namespace MWRender | ||||||
| 
 | 
 | ||||||
|         bool mHeadBobbingEnabled; |         bool mHeadBobbingEnabled; | ||||||
|         float mHeadBobbingOffset; |         float mHeadBobbingOffset; | ||||||
|         float mHeadBobbingWeight = 0; // Value from 0 to 1 for smooth enabling/disabling.
 |         float mHeadBobbingWeight; // Value from 0 to 1 for smooth enabling/disabling.
 | ||||||
|         float mTotalMovement = 0; // Needed for head bobbing.
 |         float mTotalMovement; // Needed for head bobbing.
 | ||||||
|         void updateHeadBobbing(float duration); |         void updateHeadBobbing(float duration); | ||||||
| 
 | 
 | ||||||
|         void updateFocalPointOffset(float duration); |         void updateFocalPointOffset(float duration); | ||||||
|  |  | ||||||
|  | @ -65,6 +65,9 @@ namespace MWSound | ||||||
|         , mUnderwaterSound(nullptr) |         , mUnderwaterSound(nullptr) | ||||||
|         , mNearWaterSound(nullptr) |         , mNearWaterSound(nullptr) | ||||||
|         , mPlaybackPaused(false) |         , mPlaybackPaused(false) | ||||||
|  |         , mTimePassed(0.f) | ||||||
|  |         , mLastCell(nullptr) | ||||||
|  |         , mCurrentRegionSound(nullptr) | ||||||
|     { |     { | ||||||
|         mBufferCacheMin = std::max(Settings::Manager::getInt("buffer cache min", "Sound"), 1); |         mBufferCacheMin = std::max(Settings::Manager::getInt("buffer cache min", "Sound"), 1); | ||||||
|         mBufferCacheMax = std::max(Settings::Manager::getInt("buffer cache max", "Sound"), 1); |         mBufferCacheMax = std::max(Settings::Manager::getInt("buffer cache max", "Sound"), 1); | ||||||
|  |  | ||||||
|  | @ -116,9 +116,9 @@ namespace MWSound | ||||||
| 
 | 
 | ||||||
|         RegionSoundSelector mRegionSoundSelector; |         RegionSoundSelector mRegionSoundSelector; | ||||||
| 
 | 
 | ||||||
|         float mTimePassed = 0; |         float mTimePassed; | ||||||
| 
 | 
 | ||||||
|         const ESM::Cell *mLastCell = nullptr; |         const ESM::Cell *mLastCell; | ||||||
| 
 | 
 | ||||||
|         Sound* mCurrentRegionSound; |         Sound* mCurrentRegionSound; | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -143,8 +143,14 @@ static void gdb_info(pid_t pid) | ||||||
|     FILE *f; |     FILE *f; | ||||||
|     int fd; |     int fd; | ||||||
| 
 | 
 | ||||||
|     /* Create a temp file to put gdb commands into */ |     /*
 | ||||||
|  |      * Create a temp file to put gdb commands into. | ||||||
|  |      * Note: POSIX.1-2008 declares that the file should be already created with mode 0600 by default. | ||||||
|  |      * Modern systems implement it and and suggest to do not touch masks in multithreaded applications. | ||||||
|  |      * So CoverityScan warning is valid only for ancient versions of stdlib. | ||||||
|  |     */ | ||||||
|     strcpy(respfile, "/tmp/gdb-respfile-XXXXXX"); |     strcpy(respfile, "/tmp/gdb-respfile-XXXXXX"); | ||||||
|  |     // coverity[secure_temp]
 | ||||||
|     if((fd=mkstemp(respfile)) >= 0 && (f=fdopen(fd, "w")) != nullptr) |     if((fd=mkstemp(respfile)) >= 0 && (f=fdopen(fd, "w")) != nullptr) | ||||||
|     { |     { | ||||||
|         fprintf(f, "attach %d\n" |         fprintf(f, "attach %d\n" | ||||||
|  |  | ||||||
|  | @ -331,9 +331,10 @@ namespace ESM | ||||||
|         std::copy(land.mWnam, land.mWnam + LAND_GLOBAL_MAP_LOD_SIZE, mWnam); |         std::copy(land.mWnam, land.mWnam + LAND_GLOBAL_MAP_LOD_SIZE, mWnam); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     Land& Land::operator= (Land land) |     Land& Land::operator= (const Land& land) | ||||||
|     { |     { | ||||||
|         swap (land); |         Land tmp(land); | ||||||
|  |         swap(tmp); | ||||||
|         return *this; |         return *this; | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -148,7 +148,7 @@ struct Land | ||||||
| 
 | 
 | ||||||
|         Land (const Land& land); |         Land (const Land& land); | ||||||
| 
 | 
 | ||||||
|         Land& operator= (Land land); |         Land& operator= (const Land& land); | ||||||
| 
 | 
 | ||||||
|         void swap (Land& land); |         void swap (Land& land); | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
		Loading…
	
		Reference in a new issue