1
0
mirror of https://gitlab.com/OpenMW/openmw.git synced 2025-04-06 19:20:42 +00:00

Merge branch 'coverity' into 'master'

Fix some Coverity issues

See merge request OpenMW/openmw!2082
This commit is contained in:
jvoisin 2022-07-03 16:29:05 +00:00
commit 498a835b77
22 changed files with 54 additions and 38 deletions

View File

@ -68,7 +68,7 @@ namespace
{ {
if (isIndexedRefId(indexedRefId)) if (isIndexedRefId(indexedRefId))
{ {
int refIndex; int refIndex = 0;
std::string refId; std::string refId;
splitIndexedRefId(indexedRefId, refIndex, refId); splitIndexedRefId(indexedRefId, refIndex, refId);
@ -320,6 +320,8 @@ namespace ESSImport
esm.startRecord(ESM::REC_CSTA); esm.startRecord(ESM::REC_CSTA);
ESM::CellState csta; ESM::CellState csta;
csta.mHasFogOfWar = 0; csta.mHasFogOfWar = 0;
csta.mLastRespawn.mDay = 0;
csta.mLastRespawn.mHour = 0;
csta.mId = esmcell.getCellId(); csta.mId = esmcell.getCellId();
csta.mId.save(esm); csta.mId.save(esm);
// TODO csta.mLastRespawn; // TODO csta.mLastRespawn;
@ -352,7 +354,7 @@ namespace ESSImport
} }
else else
{ {
int refIndex; int refIndex = 0;
splitIndexedRefId(cellref.mIndexedRefId, refIndex, out.mRefID); splitIndexedRefId(cellref.mIndexedRefId, refIndex, out.mRefID);
std::string idLower = Misc::StringUtils::lowerCase(out.mRefID); std::string idLower = Misc::StringUtils::lowerCase(out.mRefID);
@ -490,6 +492,7 @@ namespace ESSImport
out.mSpellId = it->mSPDT.mId.toString(); out.mSpellId = it->mSPDT.mId.toString();
out.mSpeed = pnam.mSpeed * 0.001f; // not sure where this factor comes from out.mSpeed = pnam.mSpeed * 0.001f; // not sure where this factor comes from
out.mSlot = 0;
esm.startRecord(ESM::REC_MPRJ); esm.startRecord(ESM::REC_MPRJ);
out.save(esm); out.save(esm);

View File

@ -368,6 +368,7 @@ namespace ESSImport
profile.mInGameTime.mGameHour = context.mHour; profile.mInGameTime.mGameHour = context.mHour;
profile.mInGameTime.mMonth = context.mMonth; profile.mInGameTime.mMonth = context.mMonth;
profile.mInGameTime.mYear = context.mYear; profile.mInGameTime.mYear = context.mYear;
profile.mTimePlayed = 0;
profile.mPlayerCell = header.mGameData.mCurrentCell.toString(); profile.mPlayerCell = header.mGameData.mCurrentCell.toString();
if (context.mPlayerBase.mClass == "NEWCLASSID_CHARGEN") if (context.mPlayerBase.mClass == "NEWCLASSID_CHARGEN")
profile.mPlayerClassName = context.mCustomPlayerClassName; profile.mPlayerClassName = context.mCustomPlayerClassName;

View File

@ -21,6 +21,7 @@ void CSMDoc::Document::addGmsts()
ESM::GameSetting gmst; ESM::GameSetting gmst;
gmst.mId = CSMWorld::DefaultGmsts::Floats[i]; gmst.mId = CSMWorld::DefaultGmsts::Floats[i];
gmst.mValue.setType (ESM::VT_Float); gmst.mValue.setType (ESM::VT_Float);
gmst.mRecordFlags = 0;
gmst.mValue.setFloat (CSMWorld::DefaultGmsts::FloatsDefaultValues[i]); gmst.mValue.setFloat (CSMWorld::DefaultGmsts::FloatsDefaultValues[i]);
getData().getGmsts().add (gmst); getData().getGmsts().add (gmst);
} }
@ -30,6 +31,7 @@ void CSMDoc::Document::addGmsts()
ESM::GameSetting gmst; ESM::GameSetting gmst;
gmst.mId = CSMWorld::DefaultGmsts::Ints[i]; gmst.mId = CSMWorld::DefaultGmsts::Ints[i];
gmst.mValue.setType (ESM::VT_Int); gmst.mValue.setType (ESM::VT_Int);
gmst.mRecordFlags = 0;
gmst.mValue.setInteger (CSMWorld::DefaultGmsts::IntsDefaultValues[i]); gmst.mValue.setInteger (CSMWorld::DefaultGmsts::IntsDefaultValues[i]);
getData().getGmsts().add (gmst); getData().getGmsts().add (gmst);
} }
@ -39,6 +41,7 @@ void CSMDoc::Document::addGmsts()
ESM::GameSetting gmst; ESM::GameSetting gmst;
gmst.mId = CSMWorld::DefaultGmsts::Strings[i]; gmst.mId = CSMWorld::DefaultGmsts::Strings[i];
gmst.mValue.setType (ESM::VT_String); gmst.mValue.setType (ESM::VT_String);
gmst.mRecordFlags = 0;
gmst.mValue.setString (""); gmst.mValue.setString ("");
getData().getGmsts().add (gmst); getData().getGmsts().add (gmst);
} }
@ -164,6 +167,7 @@ void CSMDoc::Document::createBase()
{ {
ESM::Global record; ESM::Global record;
record.mId = sGlobals[i]; record.mId = sGlobals[i];
record.mRecordFlags = 0;
record.mValue.setType (i==2 ? ESM::VT_Float : ESM::VT_Long); record.mValue.setType (i==2 ? ESM::VT_Float : ESM::VT_Long);
if (i==0 || i==1) if (i==0 || i==1)

View File

@ -1032,6 +1032,7 @@ void CSMWorld::Data::loadFallbackEntries()
ESM::Static newMarker; ESM::Static newMarker;
newMarker.mId = marker.first; newMarker.mId = marker.first;
newMarker.mModel = marker.second; newMarker.mModel = marker.second;
newMarker.mRecordFlags = 0;
auto record = std::make_unique<CSMWorld::Record<ESM::Static>>(); auto record = std::make_unique<CSMWorld::Record<ESM::Static>>();
record->mBase = newMarker; record->mBase = newMarker;
record->mState = CSMWorld::RecordBase::State_BaseOnly; record->mState = CSMWorld::RecordBase::State_BaseOnly;
@ -1046,6 +1047,7 @@ void CSMWorld::Data::loadFallbackEntries()
ESM::Door newMarker; ESM::Door newMarker;
newMarker.mId = marker.first; newMarker.mId = marker.first;
newMarker.mModel = marker.second; newMarker.mModel = marker.second;
newMarker.mRecordFlags = 0;
auto record = std::make_unique<CSMWorld::Record<ESM::Door>>(); auto record = std::make_unique<CSMWorld::Record<ESM::Door>>();
record->mBase = newMarker; record->mBase = newMarker;
record->mState = CSMWorld::RecordBase::State_BaseOnly; record->mState = CSMWorld::RecordBase::State_BaseOnly;

View File

@ -27,7 +27,10 @@ namespace CSMWorld
const RefIdColumn *mType; const RefIdColumn *mType;
const RefIdColumn *mBlocked; const RefIdColumn *mBlocked;
BaseColumns () : mBlocked(nullptr) {} BaseColumns () : mId(nullptr)
, mModified(nullptr)
, mType(nullptr)
, mBlocked(nullptr) {}
}; };
/// \brief Base adapter for all refereceable record types /// \brief Base adapter for all refereceable record types

View File

@ -459,6 +459,7 @@ OMW::Engine::Engine(Files::ConfigurationManager& configurationManager)
, mScriptBlacklistUse (true) , mScriptBlacklistUse (true)
, mNewGame (false) , mNewGame (false)
, mCfgMgr(configurationManager) , mCfgMgr(configurationManager)
, mGlMaxTextureImageUnits(0)
{ {
SDL_SetHint(SDL_HINT_ACCELEROMETER_AS_JOYSTICK, "0"); // We use only gamepads SDL_SetHint(SDL_HINT_ACCELEROMETER_AS_JOYSTICK, "0"); // We use only gamepads

View File

@ -1047,7 +1047,7 @@ public:
for (ActiveTextFormats::iterator i = mActiveTextFormats.begin (); i != mActiveTextFormats.end (); ++i) for (ActiveTextFormats::iterator i = mActiveTextFormats.begin (); i != mActiveTextFormats.end (); ++i)
{ {
if (mNode != nullptr) if (mNode != nullptr && i->second != nullptr)
i->second->destroyDrawItem (mNode); i->second->destroyDrawItem (mNode);
i->second.reset(); i->second.reset();
} }

View File

@ -494,6 +494,7 @@ namespace MWGui
klass.mDescription = mCreateClassDialog->getDescription(); klass.mDescription = mCreateClassDialog->getDescription();
klass.mData.mSpecialization = mCreateClassDialog->getSpecializationId(); klass.mData.mSpecialization = mCreateClassDialog->getSpecializationId();
klass.mData.mIsPlayable = 0x1; klass.mData.mIsPlayable = 0x1;
klass.mRecordFlags = 0;
std::vector<int> attributes = mCreateClassDialog->getFavoriteAttributes(); std::vector<int> attributes = mCreateClassDialog->getFavoriteAttributes();
assert(attributes.size() == 2); assert(attributes.size() == 2);

View File

@ -56,7 +56,7 @@ namespace MWRender
postProcessor->getStateUpdater()->setEyePos(cv->getEyePoint()); postProcessor->getStateUpdater()->setEyePos(cv->getEyePoint());
postProcessor->getStateUpdater()->setEyeVec(cv->getLookVectorLocal()); postProcessor->getStateUpdater()->setEyeVec(cv->getLookVectorLocal());
if (!postProcessor || !postProcessor->getFbo(PostProcessor::FBO_Primary, frameId)) if (!postProcessor->getFbo(PostProcessor::FBO_Primary, frameId))
{ {
renderStage->setMultisampleResolveFramebufferObject(nullptr); renderStage->setMultisampleResolveFramebufferObject(nullptr);
renderStage->setFrameBufferObject(nullptr); renderStage->setFrameBufferObject(nullptr);

View File

@ -238,7 +238,7 @@ namespace MWRender
} }
mGLSLVersion = ext->glslLanguageVersion * 100; mGLSLVersion = ext->glslLanguageVersion * 100;
mUBO = ext && ext->isUniformBufferObjectSupported && mGLSLVersion >= 330; mUBO = ext->isUniformBufferObjectSupported && mGLSLVersion >= 330;
mStateUpdater = new fx::StateUpdater(mUBO); mStateUpdater = new fx::StateUpdater(mUBO);
if (!Stereo::getStereo() && !SceneUtil::AutoDepth::isReversed() && !mSoftParticles && !mUsePostProcessing) if (!Stereo::getStereo() && !SceneUtil::AutoDepth::isReversed() && !mSoftParticles && !mUsePostProcessing)

View File

@ -62,6 +62,7 @@ namespace MWWorld
else else
params.mType = ESM::ActiveSpells::Type_Permanent; params.mType = ESM::ActiveSpells::Type_Permanent;
params.mWorsenings = -1; params.mWorsenings = -1;
params.mNextWorsening = ESM::TimeStamp();
int effectIndex = 0; int effectIndex = 0;
for(const auto& enam : spell->mEffects.mList) for(const auto& enam : spell->mEffects.mList)
{ {
@ -131,6 +132,7 @@ namespace MWWorld
params.mCasterActorId = creatureStats.mActorId; params.mCasterActorId = creatureStats.mActorId;
params.mType = ESM::ActiveSpells::Type_Enchantment; params.mType = ESM::ActiveSpells::Type_Enchantment;
params.mWorsenings = -1; params.mWorsenings = -1;
params.mNextWorsening = ESM::TimeStamp();
for(std::size_t effectIndex = 0; effectIndex < oldMagnitudes.size() && effectIndex < enchantment->mEffects.mList.size(); ++effectIndex) for(std::size_t effectIndex = 0; effectIndex < oldMagnitudes.size() && effectIndex < enchantment->mEffects.mList.size(); ++effectIndex)
{ {
const auto& enam = enchantment->mEffects.mList[effectIndex]; const auto& enam = enchantment->mEffects.mList[effectIndex];

View File

@ -11,17 +11,8 @@ namespace
const T* base = list.find(name); const T* base = list.find(name);
ESM::CellRef cellRef; ESM::CellRef cellRef;
cellRef.mRefNum.unset(); cellRef.blank();
cellRef.mRefID = name; cellRef.mRefID = name;
cellRef.mScale = 1;
cellRef.mFactionRank = 0;
cellRef.mChargeInt = -1;
cellRef.mChargeIntRemainder = 0.0f;
cellRef.mGoldValue = 1;
cellRef.mEnchantmentCharge = -1;
cellRef.mTeleport = false;
cellRef.mLockLevel = 0;
cellRef.mReferenceBlocked = 0;
MWWorld::LiveCellRef<T> ref(cellRef, base); MWWorld::LiveCellRef<T> ref(cellRef, base);

View File

@ -490,6 +490,7 @@ namespace MWWorld
ESM::Global record; ESM::Global record;
record.mId = params.first; record.mId = params.first;
record.mValue = params.second; record.mValue = params.second;
record.mRecordFlags = 0;
mStore.insertStatic(record); mStore.insertStatic(record);
} }
} }
@ -509,6 +510,7 @@ namespace MWWorld
ESM::Static record; ESM::Static record;
record.mId = params.first; record.mId = params.first;
record.mModel = params.second; record.mModel = params.second;
record.mRecordFlags = 0;
mStore.insertStatic(record); mStore.insertStatic(record);
} }
} }
@ -523,6 +525,7 @@ namespace MWWorld
ESM::Door record; ESM::Door record;
record.mId = params.first; record.mId = params.first;
record.mModel = params.second; record.mModel = params.second;
record.mRecordFlags = 0;
mStore.insertStatic(record); mStore.insertStatic(record);
} }
} }

View File

@ -511,6 +511,8 @@ namespace DetourNavigator
const auto offMeshConnections = mOffMeshConnectionsManager.get().get(job.mChangedTile); const auto offMeshConnections = mOffMeshConnectionsManager.get().get(job.mChangedTile);
const PreparedNavMeshData* preparedNavMeshDataPtr = cachedNavMeshData ? &cachedNavMeshData.get() : preparedNavMeshData.get(); const PreparedNavMeshData* preparedNavMeshDataPtr = cachedNavMeshData ? &cachedNavMeshData.get() : preparedNavMeshData.get();
assert (preparedNavMeshDataPtr != nullptr);
const UpdateNavMeshStatus status = navMeshCacheItem.lock()->updateTile(job.mChangedTile, std::move(cachedNavMeshData), const UpdateNavMeshStatus status = navMeshCacheItem.lock()->updateTile(job.mChangedTile, std::move(cachedNavMeshData),
makeNavMeshTileData(*preparedNavMeshDataPtr, offMeshConnections, job.mAgentBounds, job.mChangedTile, mSettings.get().mRecast)); makeNavMeshTileData(*preparedNavMeshDataPtr, offMeshConnections, job.mAgentBounds, job.mChangedTile, mSettings.get().mRecast));

View File

@ -19,7 +19,7 @@ class ESMWriter;
struct ContItem struct ContItem
{ {
int mCount; int mCount{0};
std::string mItem; std::string mItem;
}; };

View File

@ -104,7 +104,7 @@ void ESM4::Land::load(ESM4::Reader& reader)
BTXT base; BTXT base;
if (reader.getExact(base)) if (reader.getExact(base))
{ {
assert(base.quadrant < 4 && base.quadrant >= 0 && "base texture quadrant index error"); assert(base.quadrant < 4 && "base texture quadrant index error");
reader.adjustFormId(base.formId); reader.adjustFormId(base.formId);
mTextures[base.quadrant].base = std::move(base); mTextures[base.quadrant].base = std::move(base);
@ -126,8 +126,7 @@ void ESM4::Land::load(ESM4::Reader& reader)
} }
reader.get(layer.texture); reader.get(layer.texture);
reader.adjustFormId(layer.texture.formId); reader.adjustFormId(layer.texture.formId);
assert(layer.texture.quadrant < 4 && layer.texture.quadrant >= 0 assert(layer.texture.quadrant < 4 && "additional texture quadrant index error");
&& "additional texture quadrant index error");
#if 0 #if 0
FormId txt = layer.texture.formId; FormId txt = layer.texture.formId;
std::map<FormId, int>::iterator lb = uniqueTextures.lower_bound(txt); std::map<FormId, int>::iterator lb = uniqueTextures.lower_bound(txt);

View File

@ -56,11 +56,13 @@ namespace ESM4
{ {
ReaderContext::ReaderContext() : modIndex(0), recHeaderSize(sizeof(RecordHeader)), ReaderContext::ReaderContext() : modIndex(0), recHeaderSize(sizeof(RecordHeader)),
filePos(0), recordRead(0), currWorld(0), currCell(0), cellGridValid(false) filePos(0), fileRead(0), recordRead(0), currWorld(0), currCell(0), cellGridValid(false)
{ {
currCellGrid.cellId = 0; currCellGrid.cellId = 0;
currCellGrid.grid.x = 0; currCellGrid.grid.x = 0;
currCellGrid.grid.y = 0; currCellGrid.grid.y = 0;
subRecordHeader.typeId = 0;
subRecordHeader.dataSize = 0;
} }
Reader::Reader(Files::IStreamPtr&& esmStream, const std::string& filename) Reader::Reader(Files::IStreamPtr&& esmStream, const std::string& filename)

View File

@ -80,14 +80,17 @@ boost::filesystem::path LinuxPath::getGlobalConfigPath() const
boost::filesystem::path LinuxPath::getLocalPath() const boost::filesystem::path LinuxPath::getLocalPath() const
{ {
boost::filesystem::path localPath("./"); boost::filesystem::path localPath("./");
std::string binPath(pathconf(".", _PC_PATH_MAX), '\0');
const char *statusPaths[] = {"/proc/self/exe", "/proc/self/file", "/proc/curproc/exe", "/proc/curproc/file"}; const char *statusPaths[] = {"/proc/self/exe", "/proc/self/file", "/proc/curproc/exe", "/proc/curproc/file"};
for(const char *path : statusPaths) for(const char *path : statusPaths)
{ {
if (readlink(path, &binPath[0], binPath.size()) != -1) boost::filesystem::path statusPath(path);
if (!boost::filesystem::exists(statusPath)) continue;
statusPath = boost::filesystem::read_symlink(statusPath);
if (!boost::filesystem::is_empty(statusPath))
{ {
localPath = boost::filesystem::path(binPath).parent_path() / "/"; localPath = statusPath.parent_path() / "/";
break; break;
} }
} }

View File

@ -67,7 +67,6 @@ namespace fx
std::string mName; std::string mName;
bool mLegacyGLSL; bool mLegacyGLSL;
bool mUBO; bool mUBO;
bool mSupportsNormals;
std::array<std::string, 3> mRenderTargets; std::array<std::string, 3> mRenderTargets;

View File

@ -66,8 +66,8 @@ namespace fx
void initialiseOverride() override; void initialiseOverride() override;
void notifyMouseButtonClick(MyGUI::Widget* sender); void notifyMouseButtonClick(MyGUI::Widget* sender);
MyGUI::Button* mCheckbutton; MyGUI::Button* mCheckbutton{nullptr};
MyGUI::Widget* mFill; MyGUI::Widget* mFill{nullptr};
}; };
template <class T, class UType> template <class T, class UType>
@ -236,11 +236,11 @@ namespace fx
increment(uniform->mStep); increment(uniform->mStep);
} }
MyGUI::Button* mButtonDecrease; MyGUI::Button* mButtonDecrease{nullptr};
MyGUI::Button* mButtonIncrease; MyGUI::Button* mButtonIncrease{nullptr};
MyGUI::Widget* mDragger; MyGUI::Widget* mDragger{nullptr};
MyGUI::Widget* mFill; MyGUI::Widget* mFill{nullptr};
MyGUI::TextBox* mValueLabel; MyGUI::TextBox* mValueLabel{nullptr};
T mValue; T mValue;
int mLastPointerX; int mLastPointerX;
@ -271,9 +271,9 @@ namespace fx
void initialiseOverride() override; void initialiseOverride() override;
Gui::AutoSizedButton* mReset; Gui::AutoSizedButton* mReset{nullptr};
Gui::AutoSizedTextBox* mLabel; Gui::AutoSizedTextBox* mLabel{nullptr};
MyGUI::Widget* mClient; MyGUI::Widget* mClient{nullptr};
std::vector<EditBase*> mBases; std::vector<EditBase*> mBases;
}; };
} }

View File

@ -23,8 +23,8 @@ namespace LuaUi
void textChange(MyGUI::EditBox*); void textChange(MyGUI::EditBox*);
MyGUI::EditBox* mEditBox = nullptr; MyGUI::EditBox* mEditBox = nullptr;
bool mMultiline; bool mMultiline{false};
bool mAutoSize; bool mAutoSize{false};
}; };
} }

View File

@ -160,7 +160,7 @@ namespace LuaUi
sol::object WidgetExtension::keyEvent(MyGUI::KeyCode code) const sol::object WidgetExtension::keyEvent(MyGUI::KeyCode code) const
{ {
SDL_Keysym keySym; auto keySym = SDL_Keysym();
keySym.sym = SDLUtil::myGuiKeyToSdl(code); keySym.sym = SDLUtil::myGuiKeyToSdl(code);
keySym.scancode = SDL_GetScancodeFromKey(keySym.sym); keySym.scancode = SDL_GetScancodeFromKey(keySym.sym);
keySym.mod = SDL_GetModState(); keySym.mod = SDL_GetModState();