Remove superfluous pointer null checks
authorQrchackOfficial <qrchackofficial@gmail.com>
Sun, 4 Jun 2017 23:52:55 +0000 (01:52 +0200)
committerShadowNinja <shadowninja@minetest.net>
Sun, 11 Jun 2017 01:04:47 +0000 (21:04 -0400)
src/client.cpp
src/client/clientlauncher.cpp
src/game.cpp
src/guiFormSpecMenu.cpp
src/guiFormSpecMenu.h
src/itemdef.cpp
src/mapblock.cpp
src/mesh_generator_thread.cpp
src/util/pointer.h
src/util/srp.cpp

index 56e35ac1fbc4fa8f953fe2dc4581e92d20246081..1f6f64ce077cbc2185dc7c976b38b9ae1ba2950e 100644 (file)
@@ -490,10 +490,8 @@ void Client::step(float dtime)
                        MapBlock *block = m_env.getMap().getBlockNoCreateNoEx(r.p);
                        if (block) {
                                // Delete the old mesh
-                               if (block->mesh != NULL) {
-                                       delete block->mesh;
-                                       block->mesh = NULL;
-                               }
+                               delete block->mesh;
+                               block->mesh = NULL;
 
                                if (r.mesh) {
                                        minimap_mapblock = r.mesh->moveMinimapMapblock();
index aeab825126a2de1e7a0ddb8f9b7b9e81a3a31603..76d8797256c2c5e8017e68994a6ea4ecf5556a5b 100644 (file)
@@ -53,14 +53,11 @@ MainGameCallback *g_gamecallback = NULL;
 
 ClientLauncher::~ClientLauncher()
 {
-       if (receiver)
-               delete receiver;
+       delete receiver;
 
-       if (input)
-               delete input;
+       delete input;
 
-       if (g_fontengine)
-               delete g_fontengine;
+       delete g_fontengine;
 
        if (device)
                device->drop();
index 3b5f1f3829460f549e48b305bad4fe74a9b97410..ed7316a4d2a872cb1fd85aa608617315a1b82282 100644 (file)
@@ -3231,8 +3231,7 @@ void Game::processClientEvents(CameraOrientation *cam)
                        {
                                HudElement *e = player->removeHud(event.hudrm.id);
 
-                               if (e != NULL)
-                                       delete e;
+                               delete e;
                        }
                        break;
 
index 888536128a8edfb25a80a2c8af610c0566e098a1..e73f02e5cc2dda7d535464089bca891c5513bc66 100644 (file)
@@ -134,13 +134,8 @@ GUIFormSpecMenu::~GUIFormSpecMenu()
        }
 
        delete m_selected_item;
-
-       if (m_form_src != NULL) {
-               delete m_form_src;
-       }
-       if (m_text_dst != NULL) {
-               delete m_text_dst;
-       }
+       delete m_form_src;
+       delete m_text_dst;
 }
 
 void GUIFormSpecMenu::removeChildren()
index bf0b4f356b81907d24b41b65b43d221f151e4ced..d08bb4ab59cdbdebed78c896365a7ea2423c3810 100644 (file)
@@ -310,18 +310,14 @@ public:
        // form_src is deleted by this GUIFormSpecMenu
        void setFormSource(IFormSource *form_src)
        {
-               if (m_form_src != NULL) {
-                       delete m_form_src;
-               }
+               delete m_form_src;
                m_form_src = form_src;
        }
 
        // text_dst is deleted by this GUIFormSpecMenu
        void setTextDest(TextDest *text_dst)
        {
-               if (m_text_dst != NULL) {
-                       delete m_text_dst;
-               }
+               delete m_text_dst;
                m_text_dst = text_dst;
        }
 
index 51d8f1d5d662045511a4183825ddc38c54d4e048..53b6e04cdf8265a6af3b62fe10e457137e944ab2 100644 (file)
@@ -112,11 +112,8 @@ void ItemDefinition::reset()
        stack_max = 99;
        usable = false;
        liquids_pointable = false;
-       if(tool_capabilities)
-       {
-               delete tool_capabilities;
-               tool_capabilities = NULL;
-       }
+       delete tool_capabilities;
+       tool_capabilities = NULL;
        groups.clear();
        sound_place = SimpleSoundSpec();
        sound_place_failed = SimpleSoundSpec();
index ec10a49bb8c83a5346caca9dd385659eea995072..f36117059d357cdecb06886da8593ffd421aeefc 100644 (file)
@@ -97,16 +97,12 @@ MapBlock::~MapBlock()
        {
                //MutexAutoLock lock(mesh_mutex);
 
-               if(mesh)
-               {
-                       delete mesh;
-                       mesh = NULL;
-               }
+               delete mesh;
+               mesh = NULL;
        }
 #endif
 
-       if(data)
-               delete[] data;
+       delete[] data;
 }
 
 bool MapBlock::isValidPositionParent(v3s16 p)
index dce788a7cbddbfaef065833f57fe3bb5f39af7f4..d95506de1e633d4eb66cfecc2acd034c7d448ee8 100644 (file)
@@ -40,8 +40,7 @@ CachedMapBlockData::~CachedMapBlockData()
 {
        assert(refcount_from_queue == 0);
 
-       if (data)
-               delete[] data;
+       delete[] data;
 }
 
 /*
@@ -60,8 +59,7 @@ QueuedMeshUpdate::QueuedMeshUpdate():
 
 QueuedMeshUpdate::~QueuedMeshUpdate()
 {
-       if (data)
-               delete data;
+       delete data;
 }
 
 /*
index 6614ca2c247f93d558146481a3c95c25a8635911..f68269882f22ccd1ce36fbb298292f0c5aaf5044 100644 (file)
@@ -97,8 +97,7 @@ public:
 private:
        void drop()
        {
-               if(data)
-                       delete[] data;
+               delete[] data;
        }
        T *data;
        unsigned int m_size;
@@ -214,8 +213,7 @@ private:
                (*refcount)--;
                if(*refcount == 0)
                {
-                       if(data)
-                               delete[] data;
+                       delete[] data;
                        delete refcount;
                }
        }
index 430ba11379ec0e722abdae88aecea1d8b40d1d9b..e0ddb9020125de6c6d164a2ef27bc0c7bdbe47ed 100644 (file)
@@ -861,7 +861,7 @@ err_exit:
                mpz_clear(usr->a);
                mpz_clear(usr->A);
                mpz_clear(usr->S);
-               if (usr->ng) delete_ng(usr->ng);
+               delete_ng(usr->ng);
                srp_free(usr->username);
                srp_free(usr->username_verifier);
                if (usr->password) {