diff options
author | Andrei Karas <akaras@inbox.ru> | 2015-07-11 00:12:43 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2015-07-11 00:12:43 +0300 |
commit | 368afa4bc05e5b66e521b6c881cd8e8f260cf5df (patch) | |
tree | ec9bd6a3c992c46550ad9aa396f10862257db68d /src | |
parent | ee75580d40c5c444d184a6ecbeb99493ba42085a (diff) | |
download | plus-368afa4bc05e5b66e521b6c881cd8e8f260cf5df.tar.gz plus-368afa4bc05e5b66e521b6c881cd8e8f260cf5df.tar.bz2 plus-368afa4bc05e5b66e521b6c881cd8e8f260cf5df.tar.xz plus-368afa4bc05e5b66e521b6c881cd8e8f260cf5df.zip |
Add missing checks into other files.
Diffstat (limited to 'src')
-rw-r--r-- | src/being/being.cpp | 8 | ||||
-rw-r--r-- | src/being/playerrelations.h | 2 | ||||
-rw-r--r-- | src/client.cpp | 3 | ||||
-rw-r--r-- | src/graphicsvertexes.h | 8 | ||||
-rw-r--r-- | src/guild.h | 2 | ||||
-rw-r--r-- | src/localconsts.h | 2 | ||||
-rw-r--r-- | src/net/ea/playerhandler.cpp | 5 | ||||
-rw-r--r-- | src/net/eathena/pethandler.cpp | 2 | ||||
-rw-r--r-- | src/party.h | 2 | ||||
-rw-r--r-- | src/test/testlauncher.cpp | 4 | ||||
-rw-r--r-- | src/utils/translation/poparser.cpp | 3 | ||||
-rw-r--r-- | src/utils/translation/poparser.h | 2 |
12 files changed, 24 insertions, 19 deletions
diff --git a/src/being/being.cpp b/src/being/being.cpp index 35d5bc9ee..bf05eb7eb 100644 --- a/src/being/being.cpp +++ b/src/being/being.cpp @@ -2581,12 +2581,8 @@ void Being::drawSpriteAt(Graphics *const graphics, if (mDrawHotKeys && !mName.empty()) { - Font *const font = gui->getFont(); - if (font) - { - const Color &color = userPalette->getColor(UserColorId::BEING); - font->drawString(graphics, color, color, mName, x, y); - } + const Color &color = userPalette->getColor(UserColorId::BEING); + gui->getFont()->drawString(graphics, color, color, mName, x, y); } } diff --git a/src/being/playerrelations.h b/src/being/playerrelations.h index 7ead62777..e014071b8 100644 --- a/src/being/playerrelations.h +++ b/src/being/playerrelations.h @@ -150,7 +150,7 @@ class PlayerRelationsManager final * Retrieves a sorted vector of all players for which we have any * relations recorded. */ - StringVect *getPlayers() const A_WARN_UNUSED; + StringVect *getPlayers() const RETURNS_NONNULL A_WARN_UNUSED; StringVect *getPlayersByRelation(const RelationT rel) const A_WARN_UNUSED; diff --git a/src/client.cpp b/src/client.cpp index 981ead21c..a94134baf 100644 --- a/src/client.cpp +++ b/src/client.cpp @@ -900,8 +900,7 @@ int Client::gameExec() delete2(mGame); Game::clearInstance(); ResourceManager *const resman = ResourceManager::getInstance(); - if (resman) - resman->cleanOrphans(); + resman->cleanOrphans(); Party::clearParties(); Guild::clearGuilds(); NpcDialog::clearDialogs(); diff --git a/src/graphicsvertexes.h b/src/graphicsvertexes.h index 5ca75b2bd..0606ea3b9 100644 --- a/src/graphicsvertexes.h +++ b/src/graphicsvertexes.h @@ -94,13 +94,13 @@ class OpenGLGraphicsVertexes final void switchVp(const int n); - GLfloat *continueFloatTexArray(); + GLfloat *continueFloatTexArray() RETURNS_NONNULL; - GLint *continueIntVertArray(); + GLint *continueIntVertArray() RETURNS_NONNULL; - GLshort *continueShortVertArray(); + GLshort *continueShortVertArray() RETURNS_NONNULL; - GLint *continueIntTexArray(); + GLint *continueIntTexArray() RETURNS_NONNULL; int continueVp(); diff --git a/src/guild.h b/src/guild.h index 02c2f8794..b0beed665 100644 --- a/src/guild.h +++ b/src/guild.h @@ -199,7 +199,7 @@ class Guild final : public AvatarListModel typedef std::vector<GuildMember*> MemberList; - const MemberList *getMembers() const A_WARN_UNUSED + const MemberList *getMembers() const RETURNS_NONNULL A_WARN_UNUSED { return &mMembers; } private: diff --git a/src/localconsts.h b/src/localconsts.h index 58923b609..51bec578a 100644 --- a/src/localconsts.h +++ b/src/localconsts.h @@ -70,6 +70,7 @@ #define A_WARN_UNUSED __attribute__ ((warn_unused_result)) #define DEPRECATED __attribute__ ((deprecated)) #define restrict __restrict__ +#define RETURNS_NONNULL __attribute__((returns_nonnull)) #ifndef ENABLE_CILKPLUS #define A_NONNULL(...) __attribute__((nonnull (__VA_ARGS__))) @@ -83,6 +84,7 @@ #define gnu_printf printf #define DEPRECATED #define restrict +#define RETURNS_NONNULL #define A_NONNULL(...) #endif #ifdef __clang__ diff --git a/src/net/ea/playerhandler.cpp b/src/net/ea/playerhandler.cpp index 177b3a023..ead22a984 100644 --- a/src/net/ea/playerhandler.cpp +++ b/src/net/ea/playerhandler.cpp @@ -100,6 +100,11 @@ void PlayerHandler::processPlayerWarp(Net::MessageIn &msg) localPlayer->stopAttack(); Game *const game = Game::instance(); + if (!game) + { + BLOCK_END("PlayerHandler::processPlayerWarp") + return; + } const std::string ¤tMapName = game->getCurrentMapName(); const bool sameMap = (currentMapName == mapPath); diff --git a/src/net/eathena/pethandler.cpp b/src/net/eathena/pethandler.cpp index d813b6551..8b0103bab 100644 --- a/src/net/eathena/pethandler.cpp +++ b/src/net/eathena/pethandler.cpp @@ -202,6 +202,8 @@ void PetHandler::processEggsList(Net::MessageIn &msg) { const int count = (msg.readInt16("len") - 4) / 2; Inventory *const inv = PlayerInfo::getInventory(); + if (!inv) + return; menu = MenuType::Eggs; if (count == 1) diff --git a/src/party.h b/src/party.h index 47d84cf45..96eb8206e 100644 --- a/src/party.h +++ b/src/party.h @@ -154,7 +154,7 @@ class Party final : public AvatarListModel typedef std::vector<PartyMember*> MemberList; - const MemberList *getMembers() const A_WARN_UNUSED + const MemberList *getMembers() const RETURNS_NONNULL A_WARN_UNUSED { return &mMembers; } static Party *getParty(const int16_t id) A_WARN_UNUSED; diff --git a/src/test/testlauncher.cpp b/src/test/testlauncher.cpp index 84890fe85..ca47f1b29 100644 --- a/src/test/testlauncher.cpp +++ b/src/test/testlauncher.cpp @@ -340,6 +340,8 @@ int TestLauncher::testTextures() SDL_Surface *const screen1 = mainGraphics->getScreenshot(); SDL_Surface *const screen2 = imageHelper->convertTo32Bit(screen1); SDL_FreeSurface(screen1); + if (!screen2) + break; pixels = static_cast<uint32_t*>(screen2->pixels); bool fail(false); for (int f = 0; f < 6; f ++) @@ -588,6 +590,8 @@ int TestLauncher::testDraw() vert->image = img[2]; Skin *skin = theme->load("button.xml", "button.xml"); + if (!skin) + return 0; mainGraphics->pushClipArea(Rect(10, 20, 790, 580)); mainGraphics->setColor(Color(0xFFU, 0xFFU, 0x00U, 0xFFU)); mainGraphics->drawRectangle(Rect(0, 0, 400, 200)); diff --git a/src/utils/translation/poparser.cpp b/src/utils/translation/poparser.cpp index 934035cc5..19f5443e9 100644 --- a/src/utils/translation/poparser.cpp +++ b/src/utils/translation/poparser.cpp @@ -45,9 +45,6 @@ PoParser::PoParser() : void PoParser::openFile(const std::string &name) { - const ResourceManager *const resman = ResourceManager::getInstance(); - if (!resman) - return; int size; char *buf = static_cast<char*>(PhysFs::loadFile(getFileName(name), size)); diff --git a/src/utils/translation/poparser.h b/src/utils/translation/poparser.h index bb7816161..7dcde6fe9 100644 --- a/src/utils/translation/poparser.h +++ b/src/utils/translation/poparser.h @@ -58,7 +58,7 @@ class PoParser final static std::string getFileName(const std::string &lang); - PoDict *getDict() const; + PoDict *getDict() const RETURNS_NONNULL A_WARN_UNUSED; static void convertStr(std::string &str); |