From f13ae3b7063d46fdb08940b2da0115a410fe17a2 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sun, 7 Jan 2024 08:46:47 +0100 Subject: [PATCH] addressed a few things pointed out by static analysis * marking move assignments noexcept * using [[fallthrough]] consistently. * getting rid of alloca. --- libraries/ZWidget/src/core/nanosvg/nanosvg.h | 4 ++-- libraries/asmjit/asmjit/asmjit_build.h | 6 +----- src/common/textures/bitmap.h | 4 ++-- src/common/utility/zstring.cpp | 2 +- src/maploader/maploader.cpp | 4 ++-- src/playsim/mapthinkers/a_floor.cpp | 4 ++-- src/r_data/portalgroups.cpp | 2 +- src/rendering/swrenderer/textures/warpbuffer.h | 2 +- src/rendering/swrenderer/things/r_voxel.cpp | 4 ++-- 9 files changed, 14 insertions(+), 18 deletions(-) diff --git a/libraries/ZWidget/src/core/nanosvg/nanosvg.h b/libraries/ZWidget/src/core/nanosvg/nanosvg.h index 36830f05c6..55f9bc5ea4 100644 --- a/libraries/ZWidget/src/core/nanosvg/nanosvg.h +++ b/libraries/ZWidget/src/core/nanosvg/nanosvg.h @@ -193,7 +193,7 @@ void nsvgDelete(NSVGimage* image); #include #ifdef _MSC_VER -#pragma warning(push); +#pragma warning(push) #pragma warning(disable:4244) #endif @@ -3099,7 +3099,7 @@ void nsvgDelete(NSVGimage* image) } #ifdef _MSC_VER -#pragma warning(pop); +#pragma warning(pop) #endif #endif // NANOSVG_IMPLEMENTATION diff --git a/libraries/asmjit/asmjit/asmjit_build.h b/libraries/asmjit/asmjit/asmjit_build.h index 77b151ac3a..7a41a9e1cd 100644 --- a/libraries/asmjit/asmjit/asmjit_build.h +++ b/libraries/asmjit/asmjit/asmjit_build.h @@ -819,11 +819,7 @@ // [@CC_FALLTHROUGH{@] // \def ASMJIT_FALLTHROUGH // The code falls through annotation (switch / case). -#if ASMJIT_CC_CLANG && __cplusplus >= 201103L -# define ASMJIT_FALLTHROUGH [[clang::fallthrough]] -#else -# define ASMJIT_FALLTHROUGH (void)0 -#endif +# define ASMJIT_FALLTHROUGH [[fallthrough]] // [@CC_FALLTHROUGH}@] // [@CC_UNUSED{@] diff --git a/src/common/textures/bitmap.h b/src/common/textures/bitmap.h index de9850c27c..2828be356a 100644 --- a/src/common/textures/bitmap.h +++ b/src/common/textures/bitmap.h @@ -108,7 +108,7 @@ public: FBitmap(const FBitmap &other) = delete; // disallow because in nearly all cases this creates an unwanted copy. - FBitmap(FBitmap &&other) + FBitmap(FBitmap &&other) noexcept { data = other.data; Pitch = other.Pitch; @@ -122,7 +122,7 @@ public: FBitmap &operator=(const FBitmap &other) = delete; // disallow because in nearly all cases this creates an unwanted copy. Use Copy instead. - FBitmap &operator=(FBitmap &&other) + FBitmap &operator=(FBitmap &&other) noexcept { if (data != nullptr && FreeBuffer) delete[] data; data = other.data; diff --git a/src/common/utility/zstring.cpp b/src/common/utility/zstring.cpp index 160647b7bb..ecd0dc7e63 100644 --- a/src/common/utility/zstring.cpp +++ b/src/common/utility/zstring.cpp @@ -217,7 +217,7 @@ FString &FString::operator = (const FString &other) return *this; } -FString &FString::operator = (FString &&other) +FString &FString::operator = (FString &&other) noexcept { assert (Chars != NULL); diff --git a/src/maploader/maploader.cpp b/src/maploader/maploader.cpp index 904d1dcbca..817b02e1e7 100644 --- a/src/maploader/maploader.cpp +++ b/src/maploader/maploader.cpp @@ -1182,8 +1182,8 @@ bool MapLoader::LoadNodes (MapData * map) auto &nodes = Level->nodes; nodes.Alloc(numnodes); - used = (uint16_t *)alloca (sizeof(uint16_t)*numnodes); - memset (used, 0, sizeof(uint16_t)*numnodes); + TArray used(numnodes, true); + memset (used.data(), 0, sizeof(uint16_t) * numnodes); auto mnp = map->Read(ML_NODES); mn = (nodetype*)(mnp.Data() + nodetype::NF_LUMPOFFSET); diff --git a/src/playsim/mapthinkers/a_floor.cpp b/src/playsim/mapthinkers/a_floor.cpp index ff7c91412b..0d330e4e90 100644 --- a/src/playsim/mapthinkers/a_floor.cpp +++ b/src/playsim/mapthinkers/a_floor.cpp @@ -155,7 +155,7 @@ void DFloor::Tick () case genFloorChgT: case genFloorChg0: m_Sector->SetSpecial(&m_NewSpecial); - //fall thru + [[fallthrough]]; case genFloorChg: m_Sector->SetTexture(sector_t::floor, m_Texture); break; @@ -171,7 +171,7 @@ void DFloor::Tick () case genFloorChgT: case genFloorChg0: m_Sector->SetSpecial(&m_NewSpecial); - //fall thru + [[fallthrough]]; case genFloorChg: m_Sector->SetTexture(sector_t::floor, m_Texture); break; diff --git a/src/r_data/portalgroups.cpp b/src/r_data/portalgroups.cpp index 8d682b78e7..b7f0e7255d 100644 --- a/src/r_data/portalgroups.cpp +++ b/src/r_data/portalgroups.cpp @@ -400,7 +400,7 @@ static void GroupLinePortals(FLevelLocals *Level) for (unsigned i = 0; i < Level->linePortals.Size(); i++) { - auto port = Level->linePortals[i]; + const auto& port = Level->linePortals[i]; bool gotsome; if (tempindex[i] == -1) diff --git a/src/rendering/swrenderer/textures/warpbuffer.h b/src/rendering/swrenderer/textures/warpbuffer.h index 594903a536..16fd09b1fa 100644 --- a/src/rendering/swrenderer/textures/warpbuffer.h +++ b/src/rendering/swrenderer/textures/warpbuffer.h @@ -44,7 +44,7 @@ void WarpBuffer(TYPE *Pixels, const TYPE *source, int width, int height, int xmu if (warptype == 1) { - TYPE *buffer = (TYPE *)alloca(sizeof(TYPE) * max(width, height)); + TArray buffer(max(width, height), true); // [mxd] Rewrote to fix animation for NPo2 textures unsigned timebase = unsigned(time * Speed * 32 / 28); for (y = height - 1; y >= 0; y--) diff --git a/src/rendering/swrenderer/things/r_voxel.cpp b/src/rendering/swrenderer/things/r_voxel.cpp index 455ad48ab5..28d8921f07 100644 --- a/src/rendering/swrenderer/things/r_voxel.cpp +++ b/src/rendering/swrenderer/things/r_voxel.cpp @@ -373,8 +373,8 @@ namespace swrenderer if ((abs(globalposz - dasprz) >> 10) >= abs(dazscale)) return; x = 0; y = 0; j = max(mip->SizeX, mip->SizeY); - fixed_t *ggxinc = (fixed_t *)alloca((j + 1) * sizeof(fixed_t) * 2); - fixed_t *ggyinc = ggxinc + (j + 1); + TArray ggxinc((j + 1) * 2); + fixed_t *ggyinc = ggxinc.data() + (j + 1); for (i = 0; i <= j; i++) { ggxinc[i] = x; x += gxinc;