From 47b76180d6aba73964f2ecb360ee9f439904a4e7 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sun, 26 Mar 2023 08:33:09 +0200 Subject: [PATCH] - fixed several warnings emitted by Clang. --- libraries/ZVulkan/include/zvulkan/vulkanobjects.h | 2 +- src/common/audio/music/music.cpp | 2 +- src/common/filesystem/filesystem.cpp | 4 ++-- src/common/models/models_iqm.cpp | 10 +++++----- src/common/platform/win32/i_system.cpp | 2 +- src/common/rendering/vulkan/renderer/vk_renderpass.cpp | 2 +- src/common/utility/tarray.h | 4 ++++ src/gamedata/a_weapons.h | 1 + src/playsim/fragglescript/t_script.h | 2 +- src/sound/s_doomsound.cpp | 4 ++-- src/utility/nodebuilder/nodebuild_events.cpp | 2 +- src/utility/nodebuilder/nodebuild_gl.cpp | 2 +- 12 files changed, 21 insertions(+), 16 deletions(-) diff --git a/libraries/ZVulkan/include/zvulkan/vulkanobjects.h b/libraries/ZVulkan/include/zvulkan/vulkanobjects.h index c7842f670..e3bf4505c 100644 --- a/libraries/ZVulkan/include/zvulkan/vulkanobjects.h +++ b/libraries/ZVulkan/include/zvulkan/vulkanobjects.h @@ -569,7 +569,7 @@ inline RenderPassBegin& RenderPassBegin::Framebuffer(VulkanFramebuffer* framebuf inline RenderPassBegin& RenderPassBegin::AddClearColor(float r, float g, float b, float a) { VkClearValue clearValue = { }; - clearValue.color = { r, g, b, a }; + clearValue.color = { { r, g, b, a } }; clearValues.push_back(clearValue); renderPassInfo.clearValueCount = (uint32_t)clearValues.size(); diff --git a/src/common/audio/music/music.cpp b/src/common/audio/music/music.cpp index 3da91a6e9..610f0368f 100644 --- a/src/common/audio/music/music.cpp +++ b/src/common/audio/music/music.cpp @@ -410,7 +410,7 @@ static FString ReplayGainHash(ZMusicCustomReader* reader, int flength, int playe for (size_t j = 0; j < sizeof(digest); ++j) { - sprintf(digestout + (j * 2), "%02X", digest[j]); + snprintf(digestout + (j * 2), 3, "%02X", digest[j]); } digestout[32] = 0; diff --git a/src/common/filesystem/filesystem.cpp b/src/common/filesystem/filesystem.cpp index f18ad5138..6b60e8e68 100644 --- a/src/common/filesystem/filesystem.cpp +++ b/src/common/filesystem/filesystem.cpp @@ -395,7 +395,7 @@ void FileSystem::AddFile (const char *filename, FileReader *filer, bool quiet, L for (size_t j = 0; j < sizeof(cksum); ++j) { - sprintf(cksumout + (j * 2), "%02X", cksum[j]); + snprintf(cksumout + (j * 2), 3, "%02X", cksum[j]); } fprintf(hashfile, "file: %s, hash: %s, size: %d\n", filename, cksumout, (int)filereader.GetLength()); @@ -417,7 +417,7 @@ void FileSystem::AddFile (const char *filename, FileReader *filer, bool quiet, L for (size_t j = 0; j < sizeof(cksum); ++j) { - sprintf(cksumout + (j * 2), "%02X", cksum[j]); + snprintf(cksumout + (j * 2), 3, "%02X", cksum[j]); } fprintf(hashfile, "file: %s, lump: %s, hash: %s, size: %d\n", filename, lump->getName(), cksumout, lump->LumpSize); diff --git a/src/common/models/models_iqm.cpp b/src/common/models/models_iqm.cpp index 9d4ab2652..a2d72b11a 100644 --- a/src/common/models/models_iqm.cpp +++ b/src/common/models/models_iqm.cpp @@ -528,15 +528,15 @@ const TArray IQMModel::CalculateBones(int frame1, int frame2, double i const TArray& animationFrames = animationData ? *animationData : TRSData; if (Joints.Size() > 0) { - int numbones = Joints.Size(); + int numbones = Joints.SSize(); - if (boneComponentData->trscomponents[index].Size() != numbones) + if (boneComponentData->trscomponents[index].SSize() != numbones) boneComponentData->trscomponents[index].Resize(numbones); - if (boneComponentData->trsmatrix[index].Size() != numbones) + if (boneComponentData->trsmatrix[index].SSize() != numbones) boneComponentData->trsmatrix[index].Resize(numbones); - frame1 = clamp(frame1, 0, ((int)animationFrames.Size() - 1) / numbones); - frame2 = clamp(frame2, 0, ((int)animationFrames.Size() - 1) / numbones); + frame1 = clamp(frame1, 0, (animationFrames.SSize() - 1) / numbones); + frame2 = clamp(frame2, 0, (animationFrames.SSize() - 1) / numbones); int offset1 = frame1 * numbones; int offset2 = frame2 * numbones; diff --git a/src/common/platform/win32/i_system.cpp b/src/common/platform/win32/i_system.cpp index bd1d0dbbe..8b39061a6 100644 --- a/src/common/platform/win32/i_system.cpp +++ b/src/common/platform/win32/i_system.cpp @@ -405,7 +405,7 @@ BOOL CALLBACK IWADBoxCallback(HWND hDlg, UINT message, WPARAM wParam, LPARAM lPa SendDlgItemMessage( hDlg, IDC_WELCOME_WIDESCREEN, BM_SETCHECK, (flags & 8) ? BST_CHECKED : BST_UNCHECKED, 0 ); // Set up our version string. - sprintf(szString, "Version %s.", GetVersionString()); + snprintf(szString, sizeof(szString), "Version %s.", GetVersionString()); SetDlgItemTextA (hDlg, IDC_WELCOME_VERSION, szString); // Populate the list with all the IWADs found diff --git a/src/common/rendering/vulkan/renderer/vk_renderpass.cpp b/src/common/rendering/vulkan/renderer/vk_renderpass.cpp index 5ecb3f65e..257f35c16 100644 --- a/src/common/rendering/vulkan/renderer/vk_renderpass.cpp +++ b/src/common/rendering/vulkan/renderer/vk_renderpass.cpp @@ -52,7 +52,7 @@ VkRenderPassManager::VkRenderPassManager(VulkanRenderDevice* fb) : fb(fb) { std::vector data; data.resize(fr.GetLength()); - if (fr.Read(data.data(), data.size()) == data.size()) + if (fr.Read(data.data(), data.size()) == (FileReader::Size)data.size()) { builder.InitialData(data.data(), data.size()); } diff --git a/src/common/utility/tarray.h b/src/common/utility/tarray.h index e3b234b47..29d62289c 100644 --- a/src/common/utility/tarray.h +++ b/src/common/utility/tarray.h @@ -580,6 +580,10 @@ public: { return Count; } + int SSize() const + { + return (int)Count; + } unsigned int Max () const { return Most; diff --git a/src/gamedata/a_weapons.h b/src/gamedata/a_weapons.h index 1ef6d6cc1..3de18cf4b 100644 --- a/src/gamedata/a_weapons.h +++ b/src/gamedata/a_weapons.h @@ -52,6 +52,7 @@ struct FWeaponSlots { FWeaponSlots() { Clear(); } FWeaponSlots(const FWeaponSlots &other) = default; + FWeaponSlots& operator=(const FWeaponSlots& other) = default; private: FWeaponSlot Slots[NUM_WEAPON_SLOTS]; diff --git a/src/playsim/fragglescript/t_script.h b/src/playsim/fragglescript/t_script.h index 94770645b..a80987078 100644 --- a/src/playsim/fragglescript/t_script.h +++ b/src/playsim/fragglescript/t_script.h @@ -102,7 +102,7 @@ struct svalue_t } svalue_t(const svalue_t & other) = default; - + svalue_t& operator=(const svalue_t& other) = default; void setInt(int ip) { value.i = ip; diff --git a/src/sound/s_doomsound.cpp b/src/sound/s_doomsound.cpp index 697fdcc3a..bc5c092b0 100644 --- a/src/sound/s_doomsound.cpp +++ b/src/sound/s_doomsound.cpp @@ -1344,7 +1344,7 @@ void DoomSoundEngine::PrintSoundList() const sfxinfo_t* sfx = soundEngine->GetSfx(FSoundID::fromInt(i)); if (sfx->bRandomHeader) { - Printf("%3d. %s -> #%d {", i, sfx->name.GetChars(), sfx->link); + Printf("%3d. %s -> #%d {", i, sfx->name.GetChars(), sfx->link.index()); const FRandomSoundList* list = &S_rnd[sfx->link.index()]; for (auto& me : list->Choices) { @@ -1354,7 +1354,7 @@ void DoomSoundEngine::PrintSoundList() } else if (sfx->UserData[0] & SND_PlayerReserve) { - Printf("%3d. %s <>\n", i, sfx->name.GetChars(), sfx->link); + Printf("%3d. %s <>\n", i, sfx->name.GetChars(), sfx->link.index()); } else if (S_sfx[i].lumpnum != -1) { diff --git a/src/utility/nodebuilder/nodebuild_events.cpp b/src/utility/nodebuilder/nodebuild_events.cpp index 84e187081..3ac42a6c2 100644 --- a/src/utility/nodebuilder/nodebuild_events.cpp +++ b/src/utility/nodebuilder/nodebuild_events.cpp @@ -218,7 +218,7 @@ void FEventTree::PrintTree (const FEvent *event) const if (event != &Nil) { PrintTree(event->Left); - sprintf(buff, " Distance %g, vertex %d, seg %u\n", + snprintf(buff, sizeof(buff), " Distance %g, vertex %d, seg %u\n", g_sqrt(event->Distance/4294967296.0), event->Info.Vertex, (unsigned)event->Info.FrontSeg); Printf(PRINT_LOG, "%s", buff); PrintTree(event->Right); diff --git a/src/utility/nodebuilder/nodebuild_gl.cpp b/src/utility/nodebuilder/nodebuild_gl.cpp index d2b987e04..6e9074210 100644 --- a/src/utility/nodebuilder/nodebuild_gl.cpp +++ b/src/utility/nodebuilder/nodebuild_gl.cpp @@ -99,7 +99,7 @@ void FNodeBuilder::FixSplitSharers (const node_t &node) // Use the CRT's printf so the formatting matches ZDBSP's D(char buff[200]); - D(sprintf(buff, "Considering events on seg %d(%d[%d,%d]->%d[%d,%d]) [%g:%g]\n", seg, + D(snprintf(buff, sizeof(buff), "Considering events on seg %d(%d[%d,%d]->%d[%d,%d]) [%g:%g]\n", seg, Segs[seg].v1, Vertices[Segs[seg].v1].x>>16, Vertices[Segs[seg].v1].y>>16,