Skip to content

Commit

Permalink
Fix cppcheck issues
Browse files Browse the repository at this point in the history
  • Loading branch information
scrawl committed Sep 26, 2014
1 parent 790e015 commit 7252cb6
Show file tree
Hide file tree
Showing 119 changed files with 655 additions and 945 deletions.
890 changes: 460 additions & 430 deletions apps/esmtool/labels.cpp

Large diffs are not rendered by default.

38 changes: 19 additions & 19 deletions apps/esmtool/record.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -412,7 +412,7 @@ void Record<ESM::Armor>::print()
std::cout << " Armor: " << mData.mData.mArmor << std::endl;
std::cout << " Enchantment Points: " << mData.mData.mEnchant << std::endl;
std::vector<ESM::PartReference>::iterator pit;
for (pit = mData.mParts.mParts.begin(); pit != mData.mParts.mParts.end(); pit++)
for (pit = mData.mParts.mParts.begin(); pit != mData.mParts.mParts.end(); ++pit)
{
std::cout << " Body Part: " << bodyPartLabel(pit->mPart)
<< " (" << (int)(pit->mPart) << ")" << std::endl;
Expand Down Expand Up @@ -484,7 +484,7 @@ void Record<ESM::BirthSign>::print()
std::cout << " Texture: " << mData.mTexture << std::endl;
std::cout << " Description: " << mData.mDescription << std::endl;
std::vector<std::string>::iterator pit;
for (pit = mData.mPowers.mList.begin(); pit != mData.mPowers.mList.end(); pit++)
for (pit = mData.mPowers.mList.begin(); pit != mData.mPowers.mList.end(); ++pit)
std::cout << " Power: " << *pit << std::endl;
}

Expand Down Expand Up @@ -554,7 +554,7 @@ void Record<ESM::Clothing>::print()
std::cout << " Value: " << mData.mData.mValue << std::endl;
std::cout << " Enchantment Points: " << mData.mData.mEnchant << std::endl;
std::vector<ESM::PartReference>::iterator pit;
for (pit = mData.mParts.mParts.begin(); pit != mData.mParts.mParts.end(); pit++)
for (pit = mData.mParts.mParts.begin(); pit != mData.mParts.mParts.end(); ++pit)
{
std::cout << " Body Part: " << bodyPartLabel(pit->mPart)
<< " (" << (int)(pit->mPart) << ")" << std::endl;
Expand All @@ -574,7 +574,7 @@ void Record<ESM::Container>::print()
std::cout << " Flags: " << containerFlags(mData.mFlags) << std::endl;
std::cout << " Weight: " << mData.mWeight << std::endl;
std::vector<ESM::ContItem>::iterator cit;
for (cit = mData.mInventory.mList.begin(); cit != mData.mInventory.mList.end(); cit++)
for (cit = mData.mInventory.mList.begin(); cit != mData.mInventory.mList.end(); ++cit)
std::cout << " Inventory: Count: " << boost::format("%4d") % cit->mCount
<< " Item: " << cit->mItem.toString() << std::endl;
}
Expand Down Expand Up @@ -619,12 +619,12 @@ void Record<ESM::Creature>::print()
std::cout << " Gold: " << mData.mData.mGold << std::endl;

std::vector<ESM::ContItem>::iterator cit;
for (cit = mData.mInventory.mList.begin(); cit != mData.mInventory.mList.end(); cit++)
for (cit = mData.mInventory.mList.begin(); cit != mData.mInventory.mList.end(); ++cit)
std::cout << " Inventory: Count: " << boost::format("%4d") % cit->mCount
<< " Item: " << cit->mItem.toString() << std::endl;

std::vector<std::string>::iterator sit;
for (sit = mData.mSpells.mList.begin(); sit != mData.mSpells.mList.end(); sit++)
for (sit = mData.mSpells.mList.begin(); sit != mData.mSpells.mList.end(); ++sit)
std::cout << " Spell: " << *sit << std::endl;

std::cout << " Artifical Intelligence: " << mData.mHasAI << std::endl;
Expand All @@ -639,7 +639,7 @@ void Record<ESM::Creature>::print()
std::cout << " AI Services:" << boost::format("0x%08X") % mData.mAiData.mServices << std::endl;

std::vector<ESM::AIPackage>::iterator pit;
for (pit = mData.mAiPackage.mList.begin(); pit != mData.mAiPackage.mList.end(); pit++)
for (pit = mData.mAiPackage.mList.begin(); pit != mData.mAiPackage.mList.end(); ++pit)
printAIPackage(*pit);
}

Expand Down Expand Up @@ -706,7 +706,7 @@ void Record<ESM::Faction>::print()
<< mData.mData.mRankData[i].mFactReaction << std::endl;
}
std::map<std::string, int>::iterator rit;
for (rit = mData.mReactions.begin(); rit != mData.mReactions.end(); rit++)
for (rit = mData.mReactions.begin(); rit != mData.mReactions.end(); ++rit)
std::cout << " Reaction: " << rit->second << " = " << rit->first << std::endl;
}

Expand Down Expand Up @@ -763,7 +763,7 @@ void Record<ESM::DialInfo>::print()
std::cout << " Unknown2: " << (int)mData.mData.mUnknown2 << std::endl;

std::vector<ESM::DialInfo::SelectStruct>::iterator sit;
for (sit = mData.mSelects.begin(); sit != mData.mSelects.end(); sit++)
for (sit = mData.mSelects.begin(); sit != mData.mSelects.end(); ++sit)
std::cout << " Select Rule: " << ruleString(*sit) << std::endl;

if (mData.mResultScript != "")
Expand Down Expand Up @@ -835,7 +835,7 @@ void Record<ESM::CreatureLevList>::print()
std::cout << " Flags: " << creatureListFlags(mData.mFlags) << std::endl;
std::cout << " Number of items: " << mData.mList.size() << std::endl;
std::vector<ESM::LeveledListBase::LevelItem>::iterator iit;
for (iit = mData.mList.begin(); iit != mData.mList.end(); iit++)
for (iit = mData.mList.begin(); iit != mData.mList.end(); ++iit)
std::cout << " Creature: Level: " << iit->mLevel
<< " Creature: " << iit->mId << std::endl;
}
Expand All @@ -847,7 +847,7 @@ void Record<ESM::ItemLevList>::print()
std::cout << " Flags: " << itemListFlags(mData.mFlags) << std::endl;
std::cout << " Number of items: " << mData.mList.size() << std::endl;
std::vector<ESM::LeveledListBase::LevelItem>::iterator iit;
for (iit = mData.mList.begin(); iit != mData.mList.end(); iit++)
for (iit = mData.mList.begin(); iit != mData.mList.end(); ++iit)
std::cout << " Inventory: Level: " << iit->mLevel
<< " Item: " << iit->mId << std::endl;
}
Expand Down Expand Up @@ -1031,16 +1031,16 @@ void Record<ESM::NPC>::print()
}

std::vector<ESM::ContItem>::iterator cit;
for (cit = mData.mInventory.mList.begin(); cit != mData.mInventory.mList.end(); cit++)
for (cit = mData.mInventory.mList.begin(); cit != mData.mInventory.mList.end(); ++cit)
std::cout << " Inventory: Count: " << boost::format("%4d") % cit->mCount
<< " Item: " << cit->mItem.toString() << std::endl;

std::vector<std::string>::iterator sit;
for (sit = mData.mSpells.mList.begin(); sit != mData.mSpells.mList.end(); sit++)
for (sit = mData.mSpells.mList.begin(); sit != mData.mSpells.mList.end(); ++sit)
std::cout << " Spell: " << *sit << std::endl;

std::vector<ESM::NPC::Dest>::iterator dit;
for (dit = mData.mTransport.begin(); dit != mData.mTransport.end(); dit++)
for (dit = mData.mTransport.begin(); dit != mData.mTransport.end(); ++dit)
{
std::cout << " Destination Position: "
<< boost::format("%12.3f") % dit->mPos.pos[0] << ","
Expand All @@ -1066,7 +1066,7 @@ void Record<ESM::NPC>::print()
std::cout << " AI Services:" << boost::format("0x%08X") % mData.mAiData.mServices << std::endl;

std::vector<ESM::AIPackage>::iterator pit;
for (pit = mData.mAiPackage.mList.begin(); pit != mData.mAiPackage.mList.end(); pit++)
for (pit = mData.mAiPackage.mList.begin(); pit != mData.mAiPackage.mList.end(); ++pit)
printAIPackage(*pit);
}

Expand Down Expand Up @@ -1140,7 +1140,7 @@ void Record<ESM::Race>::print()
<< mData.mData.mBonus[i].mBonus << std::endl;

std::vector<std::string>::iterator sit;
for (sit = mData.mPowers.mList.begin(); sit != mData.mPowers.mList.end(); sit++)
for (sit = mData.mPowers.mList.begin(); sit != mData.mPowers.mList.end(); ++sit)
std::cout << " Power: " << *sit << std::endl;
}

Expand All @@ -1164,7 +1164,7 @@ void Record<ESM::Region>::print()
if (mData.mSleepList != "")
std::cout << " Sleep List: " << mData.mSleepList << std::endl;
std::vector<ESM::Region::SoundRef>::iterator sit;
for (sit = mData.mSoundList.begin(); sit != mData.mSoundList.end(); sit++)
for (sit = mData.mSoundList.begin(); sit != mData.mSoundList.end(); ++sit)
std::cout << " Sound: " << (int)sit->mChance << " = " << sit->mSound.toString() << std::endl;
}

Expand All @@ -1181,12 +1181,12 @@ void Record<ESM::Script>::print()


std::vector<std::string>::iterator vit;
for (vit = mData.mVarNames.begin(); vit != mData.mVarNames.end(); vit++)
for (vit = mData.mVarNames.begin(); vit != mData.mVarNames.end(); ++vit)
std::cout << " Variable: " << *vit << std::endl;

std::cout << " ByteCode: ";
std::vector<unsigned char>::iterator cit;
for (cit = mData.mScriptData.begin(); cit != mData.mScriptData.end(); cit++)
for (cit = mData.mScriptData.begin(); cit != mData.mScriptData.end(); ++cit)
std::cout << boost::format("%02X") % (int)(*cit);
std::cout << std::endl;

Expand Down
7 changes: 3 additions & 4 deletions apps/mwiniimporter/importer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ namespace bfs = boost::filesystem;

MwIniImporter::MwIniImporter()
: mVerbose(false)
, mEncoding(ToUTF8::WINDOWS_1250)
{
const char *map[][2] =
{
Expand Down Expand Up @@ -709,8 +710,7 @@ MwIniImporter::multistrmap MwIniImporter::loadIniFile(const std::string& filenam
continue;
}

multistrmap::iterator it;
if((it = map.find(key)) == map.end()) {
if(map.find(key) == map.end()) {
map.insert( std::make_pair (key, std::vector<std::string>() ) );
}
map[key].push_back(value);
Expand Down Expand Up @@ -746,8 +746,7 @@ MwIniImporter::multistrmap MwIniImporter::loadCfgFile(const std::string& filenam
std::string key(line.substr(0,pos));
std::string value(line.substr(pos+1));

multistrmap::iterator it;
if((it = map.find(key)) == map.end()) {
if(map.find(key) == map.end()) {
map.insert( std::make_pair (key, std::vector<std::string>() ) );
}
map[key].push_back(value);
Expand Down
2 changes: 2 additions & 0 deletions apps/mwiniimporter/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ class utf8argv
char **get() const { return const_cast<char **>(argv); }

private:
utf8argv(const utf8argv&);
utf8argv& operator=(const utf8argv&);

const char **argv;
std::vector<std::string> args;
Expand Down
5 changes: 0 additions & 5 deletions apps/opencs/model/doc/savingstages.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -103,11 +103,6 @@ namespace CSMDoc
if (state==CSMWorld::RecordBase::State_Modified ||
state==CSMWorld::RecordBase::State_ModifiedOnly)
{
std::string type;
for (int i=0; i<4; ++i)
/// \todo make endianess agnostic (change ESMWriter interface?)
type += reinterpret_cast<const char *> (&mCollection.getRecord (stage).mModified.sRecordId)[i];

mState.getWriter().startRecord (mCollection.getRecord (stage).mModified.sRecordId);
mState.getWriter().writeHNCString ("NAME", mCollection.getId (stage));
mCollection.getRecord (stage).mModified.save (mState.getWriter());
Expand Down
7 changes: 6 additions & 1 deletion apps/opencs/view/render/navigation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,14 @@ float CSVRender::Navigation::getFactor (bool mouse) const
return factor;
}

CSVRender::Navigation::Navigation()
: mFastModeFactor(1)
{
}

CSVRender::Navigation::~Navigation() {}

void CSVRender::Navigation::setFastModeFactor (float factor)
{
mFastModeFactor = factor;
}
}
1 change: 1 addition & 0 deletions apps/opencs/view/render/navigation.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ namespace CSVRender

public:

Navigation();
virtual ~Navigation();

void setFastModeFactor (float factor);
Expand Down
5 changes: 0 additions & 5 deletions apps/opencs/view/render/scenewidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -361,11 +361,6 @@ namespace CSVRender
}
}

int SceneWidget::getFastFactor() const
{
return mFast ? mFastFactor : 1;
}

void SceneWidget::setLighting (Lighting *lighting)
{
if (mLighting)
Expand Down
2 changes: 0 additions & 2 deletions apps/opencs/view/render/scenewidget.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,6 @@ namespace CSVRender

void updateOgreWindow();

int getFastFactor() const;

void setLighting (Lighting *lighting);
///< \attention The ownership of \a lighting is not transferred to *this.

Expand Down
2 changes: 1 addition & 1 deletion apps/opencs/view/world/datadisplaydelegate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ void CSVWorld::DataDisplayDelegate::buildPixmaps ()
}
}

void CSVWorld::DataDisplayDelegate::setIconSize(const QSize size)
void CSVWorld::DataDisplayDelegate::setIconSize(const QSize& size)
{
mIconSize = size;
buildPixmaps();
Expand Down
2 changes: 1 addition & 1 deletion apps/opencs/view/world/datadisplaydelegate.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ namespace CSVWorld
virtual void paint (QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const;

/// pass a QSize defining height / width of icon. Default is QSize (16,16).
void setIconSize (const QSize icon);
void setIconSize (const QSize& icon);

/// offset the horizontal position of the icon from the left edge of the cell. Default is 3 pixels.
void setIconLeftOffset (int offset);
Expand Down
2 changes: 1 addition & 1 deletion apps/openmw/crashcatcher.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,6 @@ static int (*cc_user_info)(char*, char*);
static void gdb_info(pid_t pid)
{
char respfile[64];
char cmd_buf[128];
FILE *f;
int fd;

Expand Down Expand Up @@ -156,6 +155,7 @@ static void gdb_info(pid_t pid)
fclose(f);

/* Run gdb and print process info. */
char cmd_buf[128];
snprintf(cmd_buf, sizeof(cmd_buf), "gdb --quiet --batch --command=%s", respfile);
printf("Executing: %s\n", cmd_buf);
fflush(stdout);
Expand Down
3 changes: 1 addition & 2 deletions apps/openmw/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ void validate(boost::any &v, std::vector<std::string> const &tokens, FallbackMap

FallbackMap *map = boost::any_cast<FallbackMap>(&v);

std::map<std::string,std::string>::iterator mapIt;
for(std::vector<std::string>::const_iterator it=tokens.begin(); it != tokens.end(); ++it)
{
int sep = it->find(",");
Expand All @@ -76,7 +75,7 @@ void validate(boost::any &v, std::vector<std::string> const &tokens, FallbackMap
std::string key(it->substr(0,sep));
std::string value(it->substr(sep+1));

if((mapIt = map->mMap.find(key)) == map->mMap.end())
if(map->mMap.find(key) == map->mMap.end())
{
map->mMap.insert(std::make_pair (key,value));
}
Expand Down
1 change: 0 additions & 1 deletion apps/openmw/mwbase/windowmanager.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,6 @@ namespace MWBase

virtual void showCrosshair(bool show) = 0;
virtual bool getSubtitlesEnabled() = 0;
virtual void toggleHud() = 0;
virtual bool toggleGui() = 0;

virtual void disallowMouse() = 0;
Expand Down
7 changes: 0 additions & 7 deletions apps/openmw/mwclass/npc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1188,13 +1188,6 @@ namespace MWClass
+ shield;
}


void Npc::adjustRotation(const MWWorld::Ptr& ptr,float& x,float& y,float& z) const
{
y = 0;
x = 0;
}

void Npc::adjustScale(const MWWorld::Ptr &ptr, float &scale) const
{
MWWorld::LiveCellRef<ESM::NPC> *ref =
Expand Down
2 changes: 0 additions & 2 deletions apps/openmw/mwclass/npc.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -139,8 +139,6 @@ namespace MWClass
virtual void skillUsageSucceeded (const MWWorld::Ptr& ptr, int skill, int usageType, float extraFactor=1.f) const;
///< Inform actor \a ptr that a skill use has succeeded.

virtual void adjustRotation(const MWWorld::Ptr& ptr,float& x,float& y,float& z) const;

virtual bool isEssential (const MWWorld::Ptr& ptr) const;
///< Is \a ptr essential? (i.e. may losing \a ptr make the game unwinnable)

Expand Down
6 changes: 3 additions & 3 deletions apps/openmw/mwdialogue/dialoguemanagerimp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -729,10 +729,10 @@ namespace MWDialogue
{
std::vector<HyperTextToken> result;
MyGUI::UString utext(text);
size_t pos_begin, pos_end, iteration_pos = 0;
size_t pos_end, iteration_pos = 0;
for(;;)
{
pos_begin = utext.find('@', iteration_pos);
size_t pos_begin = utext.find('@', iteration_pos);
if (pos_begin != std::string::npos)
pos_end = utext.find('#', pos_begin);

Expand All @@ -758,12 +758,12 @@ namespace MWDialogue
size_t RemovePseudoAsterisks(std::string& phrase)
{
size_t pseudoAsterisksCount = 0;
const char specialPseudoAsteriskCharacter = 127;

if( !phrase.empty() )
{
std::string::reverse_iterator rit = phrase.rbegin();

const char specialPseudoAsteriskCharacter = 127;
while( rit != phrase.rend() && *rit == specialPseudoAsteriskCharacter )
{
pseudoAsterisksCount++;
Expand Down
8 changes: 0 additions & 8 deletions apps/openmw/mwgui/class.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,6 @@ namespace MWGui

InfoBoxDialog::InfoBoxDialog()
: WindowModal("openmw_infobox.layout")
, mCurrentButton(-1)
{
getWidget(mTextBox, "TextBox");
getWidget(mText, "Text");
Expand Down Expand Up @@ -306,7 +305,6 @@ namespace MWGui
MyGUI::Gui::getInstance().destroyWidget(*it);
}
this->mButtons.clear();
mCurrentButton = -1;

// TODO: The buttons should be generated from a template in the layout file, ie. cloning an existing widget
MyGUI::Button* button;
Expand Down Expand Up @@ -336,11 +334,6 @@ namespace MWGui
center();
}

int InfoBoxDialog::getChosenButton() const
{
return mCurrentButton;
}

void InfoBoxDialog::onButtonClicked(MyGUI::Widget* _sender)
{
std::vector<MyGUI::Button*>::const_iterator end = mButtons.end();
Expand All @@ -349,7 +342,6 @@ namespace MWGui
{
if (*it == _sender)
{
mCurrentButton = i;
eventButtonSelected(i);
return;
}
Expand Down
Loading

0 comments on commit 7252cb6

Please sign in to comment.