Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion AI/Wrappers/CUtils/SimpleLog.c
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,8 @@ void simpleLog_log(const char* fmt, ...) {

void simpleLog_initcallback(int id, const char* section, logfunction func, int _logLevel)
{
strncpy(logSection, section, 32);
strncpy(logSection, section, sizeof(logSection) - 1);
logSection[sizeof(logSection) - 1] = '\0';
Comment thread
sprunk marked this conversation as resolved.
logFunction = func;
interfaceid = id;
logLevel = _logLevel;
Expand Down
2 changes: 1 addition & 1 deletion rts/Game/InMapDrawModel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ void CInMapDrawModel::EraseNear(const float3& constPos, int playerID, const bool
if (!playerHandler.IsValidPlayer(playerID))
return;

const CPlayer* sender;
const CPlayer* sender = nullptr;
Comment thread
sprunk marked this conversation as resolved.

if (!alwaysErase) // we don't need to check sender if we always erase regardless of sender
sender = playerHandler.Player(playerID);
Expand Down
2 changes: 1 addition & 1 deletion rts/Game/UnsyncedGameCommands.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ class MapMeshDrawerActionExecutor : public IUnsyncedActionExecutor {
}

auto args = CSimpleParser::Tokenize(action.GetArgs());
bool parseFailure;
bool parseFailure = false;
Comment thread
sprunk marked this conversation as resolved.

int smfMeshDrawerArg = (!args.empty()) ? StringToInt(args[0], &parseFailure) : -1.0;
if (parseFailure) smfMeshDrawerArg = -1.0;
Expand Down
4 changes: 1 addition & 3 deletions rts/Lua/LuaFonts.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -200,9 +200,7 @@ int LuaFonts::LoadFont(lua_State* L)
return 0;

auto shPtrFontPtr = static_cast<decltype(f)*>(lua_newuserdata(L, sizeof(decltype(f))));
memset(shPtrFontPtr, 0, sizeof(decltype(f)));

*shPtrFontPtr = std::move(f);
new (shPtrFontPtr) decltype(f)(std::move(f));
Comment thread
sprunk marked this conversation as resolved.

luaL_getmetatable(L, "Font");
lua_setmetatable(L, -2);
Expand Down
8 changes: 4 additions & 4 deletions rts/Lua/LuaOpenGL.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2922,10 +2922,10 @@ int LuaOpenGL::DispatchCompute(lua_State* L)

static std::array<GLint, 3> maxNumGroups = maxCompWGFunc();

if (numGroupX < 0 && numGroupX > maxNumGroups[0] ||
numGroupY < 0 && numGroupY > maxNumGroups[1] ||
numGroupZ < 0 && numGroupZ > maxNumGroups[2])
luaL_error(L, "%s Incorrect number of work groups specified x: 0 > %d < %d; y: 0 > %d < %d; z: 0 > %d < %d", __func__, numGroupX, maxNumGroups[0], numGroupY, maxNumGroups[1], numGroupZ, maxNumGroups[2]);
if (numGroupX > maxNumGroups[0] ||
numGroupY > maxNumGroups[1] ||
numGroupZ > maxNumGroups[2])
luaL_error(L, "%s: work groups count exceeds GL_MAX_COMPUTE_WORK_GROUP_COUNT. (x=%u > %d, y=%u > %d, z=%u > %d)", __func__, numGroupX, maxNumGroups[0], numGroupY, maxNumGroups[1], numGroupZ, maxNumGroups[2]);
Comment thread
sprunk marked this conversation as resolved.

glDispatchCompute(numGroupX, numGroupY, numGroupZ);

Expand Down
6 changes: 4 additions & 2 deletions rts/Rendering/Fonts/CFontTexture.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -924,15 +924,17 @@ void CFontTexture::PinFont(std::shared_ptr<FontFace>& face, const std::string& f
cached->second.timestamp = time;
} else {
if (pinnedRecentFonts.size() >= maxPinnedFonts) {
SizedFontKey* oldest;
SizedFontKey* oldest = nullptr;
Comment thread
sprunk marked this conversation as resolved.
float oldestTime = time;
for(auto &[key, timestampedFont]: pinnedRecentFonts) {
if (timestampedFont.timestamp <= oldestTime) {
oldest = &key;
oldestTime = timestampedFont.timestamp;
}
}
pinnedRecentFonts.erase(*oldest);
if (oldest != nullptr) {
pinnedRecentFonts.erase(*oldest);
}
}
pinnedRecentFonts[fontKey] = { face, time };
}
Expand Down
6 changes: 3 additions & 3 deletions rts/Rendering/GL/FBO.h
Original file line number Diff line number Diff line change
Expand Up @@ -188,9 +188,9 @@ class FBO
}

public:
GLuint id;
GLsizei xsize, ysize, zsize;
GLenum target, format, type;
GLuint id = 0;
GLsizei xsize = 0, ysize = 0, zsize = 0;
GLenum target = 0, format = 0, type = 0;
Comment thread
sprunk marked this conversation as resolved.
std::vector<unsigned char> pixels;
};

Expand Down
1 change: 1 addition & 0 deletions rts/Rendering/Models/3DModelPiece.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
struct S3DModel;
struct S3DModelPiece {
S3DModelPiece() = default;
virtual ~S3DModelPiece() = default;
Comment thread
sprunk marked this conversation as resolved.

virtual void Clear() {
name.clear();
Expand Down
2 changes: 1 addition & 1 deletion rts/Rml/SolLua/RmlSolLua.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ namespace Rml::SolLua
{
SolLuaPlugin* Initialise(sol::state_view* state, const Rml::String& lua_environment_identifier)
{
SolLuaPlugin* slp;
SolLuaPlugin* slp = nullptr;
Comment thread
sprunk marked this conversation as resolved.
if (state != nullptr)
{
slp = new SolLuaPlugin(*state, lua_environment_identifier);
Expand Down
4 changes: 2 additions & 2 deletions rts/System/Platform/Linux/CpuTopology.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ enum Vendor { VENDOR_INTEL, VENDOR_AMD, VENDOR_UNKNOWN };

// Detect CPU vendor (Intel or VENDOR_AMD)
Vendor detect_cpu_vendor() {
unsigned int eax, ebx, ecx, edx;
unsigned int eax = 0, ebx = 0, ecx = 0, edx = 0;
__get_cpuid(0, &eax, &ebx, &ecx, &edx);
if (ebx == 0x756E6547) return VENDOR_INTEL; // "GenuineIntel"
if (ebx == 0x68747541) return VENDOR_AMD; // "AuthenticAMD"
Expand All @@ -152,7 +152,7 @@ Vendor detect_cpu_vendor() {
// Detect Intel core type using CPUID 0x1A
CoreType get_intel_core_type(int cpu) {
set_cpu_affinity(cpu);
unsigned int eax, ebx, ecx, edx;
unsigned int eax = 0, ebx = 0, ecx = 0, edx = 0;
Comment thread
sprunk marked this conversation as resolved.
if (__get_cpuid(0x1A, &eax, &ebx, &ecx, &edx)) {
uint8_t coreType = ( eax & 0xFF000000 ) >> 24; // Extract core type

Expand Down
22 changes: 18 additions & 4 deletions rts/System/Platform/Watchdog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,12 @@ namespace Watchdog
};

struct WatchDogThreadSlot {
void Reset() {
primary = false;
active = false;
regorder = 0;
}

std::atomic<bool> primary = {false};
std::atomic<bool> active = {false};
std::atomic<unsigned int> regorder = {0};
Expand Down Expand Up @@ -366,12 +372,16 @@ namespace Watchdog
{
std::lock_guard<spring::mutex> lock(wdmutex);

memset(registeredThreadsData, 0, sizeof(registeredThreadsData));
for (auto& info : registeredThreadsData) {
info.ResetThreadInfo();
info.ResetThreadControls();
}
for (unsigned int i = 0; i < WDT_COUNT; ++i) {
registeredThreads[i] = &registeredThreadsData[WDT_COUNT];
threadNumTable[hashString(threadNames[i])] = i;
}
memset(threadSlots, 0, sizeof(threadSlots));
for (auto& slot : threadSlots)
slot.Reset();

// disable if gdb is running
if (Platform::IsRunningInDebugger()) {
Expand Down Expand Up @@ -416,10 +426,14 @@ namespace Watchdog
hangDetectorThread.join();
LOG_L(L_INFO, "[WatchDog::%s][3]", __func__);

memset(registeredThreadsData, 0, sizeof(registeredThreadsData));
for (auto& info : registeredThreadsData) {
info.ResetThreadInfo();
info.ResetThreadControls();
}
for (unsigned int i = 0; i < WDT_COUNT; ++i)
registeredThreads[i] = &registeredThreadsData[WDT_COUNT];
memset(threadSlots, 0, sizeof(threadSlots));
for (auto& slot : threadSlots)
slot.Reset();
threadNumTable.clear();
}
}
Loading