Merge pull request #8318 from ChillerDragon/pr_clang_tidy_19

Add support for clang tidy 19
This commit is contained in:
Robert Müller 2024-06-02 08:52:47 +00:00 committed by GitHub
commit bbf54ec625
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
15 changed files with 48 additions and 36 deletions

View file

@ -31,6 +31,10 @@ Checks: >
-bugprone-suspicious-include,
-bugprone-unhandled-self-assignment,
-bugprone-suspicious-realloc-usage,
-bugprone-switch-missing-default-case,
-bugprone-casting-through-void,
-bugprone-multi-level-implicit-pointer-conversion,
-bugprone-unchecked-optional-access,
clang-analyzer-*,
-clang-analyzer-optin.cplusplus.UninitializedObject,
-clang-analyzer-optin.cplusplus.VirtualCall,
@ -50,6 +54,7 @@ Checks: >
-misc-static-assert,
-misc-unused-parameters,
-misc-use-anonymous-namespace,
-misc-include-cleaner,
modernize-avoid-bind,
modernize-concat-nested-namespaces,
modernize-deprecated-headers,
@ -85,8 +90,11 @@ Checks: >
-readability-simplify-boolean-expr,
-readability-suspicious-call-argument,
-readability-uppercase-literal-suffix,
-readability-use-std-min-max,
-readability-avoid-nested-conditional-operator,
performance-*,
-performance-no-int-to-ptr,
-performance-enum-size,
portability-*,
WarningsAsErrors:

View file

@ -1987,6 +1987,8 @@ int net_tcp_connect(NETSOCKET sock, const NETADDR *a)
{
struct sockaddr_in addr;
netaddr_to_sockaddr_in(a, &addr);
if(sock->ipv4sock < 0)
return -2;
return connect(sock->ipv4sock, (struct sockaddr *)&addr, sizeof(addr));
}
@ -1994,6 +1996,8 @@ int net_tcp_connect(NETSOCKET sock, const NETADDR *a)
{
struct sockaddr_in6 addr;
netaddr_to_sockaddr_in6(a, &addr);
if(sock->ipv6sock < 0)
return -2;
return connect(sock->ipv6sock, (struct sockaddr *)&addr, sizeof(addr));
}

View file

@ -17,10 +17,10 @@ bool CCommandProcessorFragment_GLBase::Texture2DTo3D(uint8_t *pImageBuffer, int
int DepthIndex = X + Y * SplitCountWidth;
size_t TargetImageFullWidth = (size_t)Target3DImageWidth * PixelSize;
size_t TargetImageFullSize = (size_t)TargetImageFullWidth * Target3DImageHeight;
size_t TargetImageFullSize = TargetImageFullWidth * Target3DImageHeight;
ptrdiff_t ImageOffset = (ptrdiff_t)(((size_t)Y * FullImageWidth * (size_t)Target3DImageHeight) + ((size_t)Y3D * FullImageWidth) + ((size_t)X * TargetImageFullWidth));
ptrdiff_t TargetImageOffset = (ptrdiff_t)(TargetImageFullSize * (size_t)DepthIndex + ((size_t)Y3D * TargetImageFullWidth));
mem_copy(pTarget3DImageData + TargetImageOffset, pImageBuffer + (ptrdiff_t)(ImageOffset), TargetImageFullWidth);
mem_copy(pTarget3DImageData + TargetImageOffset, pImageBuffer + ImageOffset, TargetImageFullWidth);
}
}
}

View file

@ -218,7 +218,7 @@ class CCommandProcessorFragment_Vulkan : public CCommandProcessorFragment_GLBase
else
{
// check if there is enough space in this instance
if(bool(SMemoryHeapQueueElement::SMemoryHeapQueueElementFind{}(*m_Elements.begin(), std::make_pair(AllocSize, AllocAlignment))))
if(SMemoryHeapQueueElement::SMemoryHeapQueueElementFind{}(*m_Elements.begin(), std::make_pair(AllocSize, AllocAlignment)))
{
return false;
}
@ -1984,7 +1984,7 @@ protected:
if(IsVerbose())
{
VerboseDeallocatedMemory(BufferMem.m_Size, (size_t)ImageIndex, BufferMem.m_UsageType);
VerboseDeallocatedMemory(BufferMem.m_Size, ImageIndex, BufferMem.m_UsageType);
}
BufferMem.m_Mem = VK_NULL_HANDLE;
@ -2081,7 +2081,7 @@ protected:
m_pStagingMemoryUsage->store(m_pStagingMemoryUsage->load(std::memory_order_relaxed) - FreeedMemory, std::memory_order_relaxed);
if(IsVerbose())
{
dbg_msg("vulkan", "deallocated chunks of memory with size: %" PRIzu " from all frames (staging buffer)", (size_t)FreeedMemory);
dbg_msg("vulkan", "deallocated chunks of memory with size: %" PRIzu " from all frames (staging buffer)", FreeedMemory);
}
}
FreeedMemory = 0;
@ -2091,7 +2091,7 @@ protected:
m_pBufferMemoryUsage->store(m_pBufferMemoryUsage->load(std::memory_order_relaxed) - FreeedMemory, std::memory_order_relaxed);
if(IsVerbose())
{
dbg_msg("vulkan", "deallocated chunks of memory with size: %" PRIzu " from all frames (buffer)", (size_t)FreeedMemory);
dbg_msg("vulkan", "deallocated chunks of memory with size: %" PRIzu " from all frames (buffer)", FreeedMemory);
}
}
FreeedMemory = 0;
@ -2102,7 +2102,7 @@ protected:
m_pTextureMemoryUsage->store(m_pTextureMemoryUsage->load(std::memory_order_relaxed) - FreeedMemory, std::memory_order_relaxed);
if(IsVerbose())
{
dbg_msg("vulkan", "deallocated chunks of memory with size: %" PRIzu " from all frames (texture)", (size_t)FreeedMemory);
dbg_msg("vulkan", "deallocated chunks of memory with size: %" PRIzu " from all frames (texture)", FreeedMemory);
}
}
}
@ -3285,7 +3285,7 @@ protected:
else
{
Scissor.offset = {0, 0};
Scissor.extent = {(uint32_t)ScissorViewport.width, (uint32_t)ScissorViewport.height};
Scissor.extent = {ScissorViewport.width, ScissorViewport.height};
}
// if there is a dynamic viewport make sure the scissor data is scaled down to that
@ -3401,7 +3401,7 @@ protected:
vkCmdPushConstants(CommandBuffer, PipeLayout, VK_SHADER_STAGE_VERTEX_BIT, 0, VertexPushConstantSize, &VertexPushConstants);
vkCmdPushConstants(CommandBuffer, PipeLayout, VK_SHADER_STAGE_FRAGMENT_BIT, sizeof(SUniformTileGPosBorder) + sizeof(SUniformTileGVertColorAlign), FragPushConstantSize, &FragPushConstants);
size_t DrawCount = (size_t)IndicesDrawNum;
size_t DrawCount = IndicesDrawNum;
vkCmdBindIndexBuffer(CommandBuffer, ExecBuffer.m_IndexBuffer, 0, VK_INDEX_TYPE_UINT32);
for(size_t i = 0; i < DrawCount; ++i)
{
@ -6333,7 +6333,7 @@ public:
}
{
mem_copy(pMem + Offset, pData, (size_t)DataSize);
mem_copy(pMem + Offset, pData, DataSize);
}
NewBuffer = Buffer;

View file

@ -423,7 +423,7 @@ const SGfxErrorContainer &CCommandProcessor_SDL_GL::GetError() const
void CCommandProcessor_SDL_GL::ErroneousCleanup()
{
return m_pGLBackend->ErroneousCleanup();
m_pGLBackend->ErroneousCleanup();
}
const SGfxWarningContainer &CCommandProcessor_SDL_GL::GetWarning() const

View file

@ -4419,7 +4419,7 @@ int main(int argc, const char **argv)
delete pEngine;
});
IStorage *pStorage = CreateStorage(IStorage::STORAGETYPE_CLIENT, argc, (const char **)argv);
IStorage *pStorage = CreateStorage(IStorage::STORAGETYPE_CLIENT, argc, argv);
pKernel->RegisterInterface(pStorage);
pFutureAssertionLogger->Set(CreateAssertionLogger(pStorage, GAME_NAME));
@ -4529,7 +4529,7 @@ int main(int argc, const char **argv)
// parse the command line arguments
pConsole->SetUnknownCommandCallback(UnknownArgumentCallback, pClient);
pConsole->ParseArguments(argc - 1, (const char **)&argv[1]);
pConsole->ParseArguments(argc - 1, &argv[1]);
pConsole->SetUnknownCommandCallback(IConsole::EmptyUnknownCommandCallback, nullptr);
if(pSteam->GetConnectAddress())

View file

@ -2022,7 +2022,7 @@ void *CGraphics_Threaded::AllocCommandBufferData(size_t AllocSize)
if(pData == nullptr)
{
char aError[256];
str_format(aError, sizeof(aError), "graphics: failed to allocate data (size %" PRIzu ") for command buffer", (size_t)AllocSize);
str_format(aError, sizeof(aError), "graphics: failed to allocate data (size %" PRIzu ") for command buffer", AllocSize);
dbg_assert(false, aError);
}
}
@ -2784,12 +2784,12 @@ int CGraphics_Threaded::WindowOpen()
void CGraphics_Threaded::SetWindowGrab(bool Grab)
{
return m_pBackend->SetWindowGrab(Grab);
m_pBackend->SetWindowGrab(Grab);
}
void CGraphics_Threaded::NotifyWindow()
{
return m_pBackend->NotifyWindow();
m_pBackend->NotifyWindow();
}
void CGraphics_Threaded::ReadPixel(ivec2 Position, ColorRGBA *pColor)

View file

@ -216,7 +216,7 @@ void CInput::CJoystick::GetJoystickHatKeys(int Hat, int HatValue, int (&HatKeys)
void CInput::CJoystick::GetHatValue(int Hat, int (&HatKeys)[2])
{
return GetJoystickHatKeys(Hat, SDL_JoystickGetHat(m_pDelegate, Hat), HatKeys);
GetJoystickHatKeys(Hat, SDL_JoystickGetHat(m_pDelegate, Hat), HatKeys);
}
bool CInput::CJoystick::Relative(float *pX, float *pY)

View file

@ -1838,13 +1838,13 @@ public:
}
if(pCursor->m_CalculateSelectionMode == TEXT_CURSOR_SELECTION_MODE_SET)
{
if((int)pCursor->m_GlyphCount == pCursor->m_SelectionStart)
if(pCursor->m_GlyphCount == pCursor->m_SelectionStart)
{
SelectionStarted = !SelectionStarted;
SelectionStartChar = pCursor->m_GlyphCount;
SelectionUsedPress = true;
}
if((int)pCursor->m_GlyphCount == pCursor->m_SelectionEnd)
if(pCursor->m_GlyphCount == pCursor->m_SelectionEnd)
{
SelectionStarted = !SelectionStarted;
SelectionEndChar = pCursor->m_GlyphCount;
@ -1854,7 +1854,7 @@ public:
if(pCursor->m_CursorMode != TEXT_CURSOR_CURSOR_MODE_NONE)
{
if((int)pCursor->m_GlyphCount == pCursor->m_CursorCharacter)
if(pCursor->m_GlyphCount == pCursor->m_CursorCharacter)
{
HasCursor = true;
aCursorQuads[0] = IGraphics::CQuadItem(SelX - CursorOuterInnerDiff, DrawY, CursorOuterWidth, pCursor->m_AlignedFontSize);
@ -1936,13 +1936,13 @@ public:
}
else if(pCursor->m_CalculateSelectionMode == TEXT_CURSOR_SELECTION_MODE_SET)
{
if((int)pCursor->m_GlyphCount == pCursor->m_SelectionStart)
if(pCursor->m_GlyphCount == pCursor->m_SelectionStart)
{
SelectionStarted = !SelectionStarted;
SelectionStartChar = pCursor->m_GlyphCount;
SelectionUsedPress = true;
}
if((int)pCursor->m_GlyphCount == pCursor->m_SelectionEnd)
if(pCursor->m_GlyphCount == pCursor->m_SelectionEnd)
{
SelectionStarted = !SelectionStarted;
SelectionEndChar = pCursor->m_GlyphCount;
@ -1957,7 +1957,7 @@ public:
pCursor->m_CursorCharacter = pCursor->m_GlyphCount;
}
if((int)pCursor->m_GlyphCount == pCursor->m_CursorCharacter)
if(pCursor->m_GlyphCount == pCursor->m_CursorCharacter)
{
HasCursor = true;
aCursorQuads[0] = IGraphics::CQuadItem((LastSelX + LastSelWidth) - CursorOuterInnerDiff, DrawY, CursorOuterWidth, pCursor->m_AlignedFontSize);

View file

@ -183,7 +183,7 @@ void CUpdater::Update()
void CUpdater::AddFileJob(const char *pFile, bool Job)
{
m_FileJobs.emplace_front(std::make_pair(pFile, Job));
m_FileJobs.emplace_front(pFile, Job);
}
bool CUpdater::ReplaceClient()

View file

@ -461,7 +461,7 @@ void CMenus::RenderDemoPlayer(CUIRect MainView)
else
{
static float s_PrevAmount = 0.0f;
float AmountSeek = clamp((Ui()->MouseX() - SeekBar.x - Rounding) / (float)(SeekBar.w - 2 * Rounding), 0.0f, 1.0f);
float AmountSeek = clamp((Ui()->MouseX() - SeekBar.x - Rounding) / (SeekBar.w - 2 * Rounding), 0.0f, 1.0f);
if(Input()->ShiftIsPressed())
{
@ -494,7 +494,7 @@ void CMenus::RenderDemoPlayer(CUIRect MainView)
if(Ui()->HotItem() == pId)
{
const int HoveredTick = (int)(clamp((Ui()->MouseX() - SeekBar.x - Rounding) / (float)(SeekBar.w - 2 * Rounding), 0.0f, 1.0f) * TotalTicks);
const int HoveredTick = (int)(clamp((Ui()->MouseX() - SeekBar.x - Rounding) / SeekBar.w - 2 * Rounding, 0.0f, 1.0f) * TotalTicks);
static char s_aHoveredTime[32];
str_time((int64_t)HoveredTick / Client()->GameTickSpeed() * 100, TIME_HOURS, s_aHoveredTime, sizeof(s_aHoveredTime));
GameClient()->m_Tooltips.DoToolTip(pId, &SeekBar, s_aHoveredTime);

View file

@ -640,7 +640,7 @@ CEntity *CGameWorld::FindMatch(int ObjId, int ObjType, const void *pObjData)
case NETOBJTYPE_CHARACTER:
{
CCharacter *pEnt = (CCharacter *)GetEntity(ObjId, ENTTYPE_CHARACTER);
if(pEnt && CCharacter(this, ObjId, (CNetObj_Character *)pObjData).Match((CCharacter *)pEnt))
if(pEnt && CCharacter(this, ObjId, (CNetObj_Character *)pObjData).Match(pEnt))
{
return pEnt;
}

View file

@ -1160,7 +1160,7 @@ int CCollision::IntersectNoLaser(vec2 Pos0, vec2 Pos1, vec2 *pOutCollision, vec2
for(int i = 0, id = std::ceil(d); i < id; i++)
{
float a = (int)i / d;
float a = i / d;
vec2 Pos = mix(Pos0, Pos1, a);
int Nx = clamp(round_to_int(Pos.x) / 32, 0, m_Width - 1);
int Ny = clamp(round_to_int(Pos.y) / 32, 0, m_Height - 1);

View file

@ -986,7 +986,7 @@ void CEditor::DoAudioPreview(CUIRect View, const void *pPlayPauseButtonId, const
}
else
{
const float AmountSeek = clamp((Ui()->MouseX() - SeekBar.x - Rounding) / (float)(SeekBar.w - 2 * Rounding), 0.0f, 1.0f);
const float AmountSeek = clamp((Ui()->MouseX() - SeekBar.x - Rounding) / (SeekBar.w - 2 * Rounding), 0.0f, 1.0f);
Sound()->SetSampleCurrentTime(SampleId, AmountSeek);
}
}
@ -6491,7 +6491,7 @@ void CEditor::RenderEnvelopeEditor(CUIRect View)
if(Value / m_ZoomEnvelopeY.GetValue() * View.h < 40.0f)
UnitsPerLineY = Value;
}
int NumLinesY = m_ZoomEnvelopeY.GetValue() / static_cast<float>(UnitsPerLineY) + 1;
int NumLinesY = m_ZoomEnvelopeY.GetValue() / UnitsPerLineY + 1;
Ui()->ClipEnable(&View);
Graphics()->TextureClear();
@ -6536,7 +6536,7 @@ void CEditor::RenderEnvelopeEditor(CUIRect View)
if(Value.AsSeconds() / m_ZoomEnvelopeX.GetValue() * View.w < 160.0f)
UnitsPerLineX = Value;
}
int NumLinesX = m_ZoomEnvelopeX.GetValue() / static_cast<float>(UnitsPerLineX.AsSeconds()) + 1;
int NumLinesX = m_ZoomEnvelopeX.GetValue() / UnitsPerLineX.AsSeconds() + 1;
Ui()->ClipEnable(&View);
Graphics()->TextureClear();
@ -8390,8 +8390,8 @@ void CEditor::HandleCursorMovement()
}
// update positions for ui, but only update ui when rendering
m_MouseX = Ui()->Screen()->w * ((float)s_MouseX / Graphics()->WindowWidth());
m_MouseY = Ui()->Screen()->h * ((float)s_MouseY / Graphics()->WindowHeight());
m_MouseX = Ui()->Screen()->w * (s_MouseX / Graphics()->WindowWidth());
m_MouseY = Ui()->Screen()->h * (s_MouseY / Graphics()->WindowHeight());
// fix correct world x and y
std::shared_ptr<CLayerGroup> pGroup = GetSelectedGroup();
@ -8475,8 +8475,8 @@ void CEditor::OnMouseMove(float MouseX, float MouseY)
continue;
CTile Tile = pTiles->GetTile(x, y);
if(Tile.m_Index)
m_vHoverTiles.emplace_back(CHoverTile(
g, l, x, y, Tile));
m_vHoverTiles.emplace_back(
g, l, x, y, Tile);
}
}
Ui()->MapScreen();

View file

@ -634,7 +634,7 @@ bool GetLineIntersection(const float aLine1[2], const float aLine2[2], float aIn
std::min(aLine1[1], aLine2[1])};
if(aIntersection)
SetInexistent((float *)aIntersection, 2);
SetInexistent(aIntersection, 2);
if(aBorders[0] - aBorders[1] > 0.01f)
return false;