Skip to content

Commit

Permalink
address analysis warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
Jamiras committed Dec 2, 2023
1 parent 3751c1b commit 72f31df
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 18 deletions.
40 changes: 25 additions & 15 deletions src/services/AchievementRuntime.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2317,7 +2317,7 @@ int AchievementRuntime::SaveProgressToBuffer(uint8_t* pBuffer, int nBufferSize)
class AchievementRuntimeExports : private AchievementRuntime
{
public:
static void destroy()
static void destroy() noexcept
{
memset(&s_callbacks, 0, sizeof(s_callbacks));
}
Expand Down Expand Up @@ -2432,6 +2432,7 @@ class AchievementRuntimeExports : private AchievementRuntime
const char* password, rc_client_callback_t callback,
void* callback_userdata)
{
GSL_SUPPRESS_R3
auto* pCallbackData = new CallbackWrapper(client, callback, callback_userdata);

auto& pClient = ra::services::ServiceLocator::GetMutable<ra::services::AchievementRuntime>();
Expand Down Expand Up @@ -2476,6 +2477,7 @@ class AchievementRuntimeExports : private AchievementRuntime
static rc_client_async_handle_t* begin_load_game(rc_client_t* client, const char* hash,
rc_client_callback_t callback, void* callback_userdata)
{
GSL_SUPPRESS_R3
auto* pCallbackData = new CallbackWrapper(client, callback, callback_userdata);

auto& pClient = ra::services::ServiceLocator::GetMutable<ra::services::AchievementRuntime>();
Expand Down Expand Up @@ -2510,6 +2512,7 @@ class AchievementRuntimeExports : private AchievementRuntime
const uint8_t* data, size_t data_size,
rc_client_callback_t callback, void* callback_userdata)
{
GSL_SUPPRESS_R3
auto* pCallbackData = new CallbackWrapper(client, callback, callback_userdata);

auto& pClient = ra::services::ServiceLocator::GetMutable<ra::services::AchievementRuntime>();
Expand All @@ -2519,8 +2522,9 @@ class AchievementRuntimeExports : private AchievementRuntime
static rc_client_achievement_list_info_t* create_achievement_list(int category, int grouping)
{
auto& pClient = ra::services::ServiceLocator::GetMutable<ra::services::AchievementRuntime>();
auto* list = (rc_client_achievement_list_info_t*)
rc_client_create_achievement_list(pClient.GetClient(), category, grouping);
GSL_SUPPRESS_TYPE1
auto* list = reinterpret_cast<rc_client_achievement_list_info_t*>(
rc_client_create_achievement_list(pClient.GetClient(), category, grouping));
list->destroy_func = destroy_achievement_list;
return list;
}
Expand All @@ -2540,8 +2544,9 @@ class AchievementRuntimeExports : private AchievementRuntime
static rc_client_leaderboard_list_info_t* create_leaderboard_list(int grouping)
{
auto& pClient = ra::services::ServiceLocator::GetMutable<ra::services::AchievementRuntime>();
auto* list = (rc_client_leaderboard_list_info_t*)
rc_client_create_leaderboard_list(pClient.GetClient(), grouping);
GSL_SUPPRESS_TYPE1
auto* list = reinterpret_cast<rc_client_leaderboard_list_info_t*>(
rc_client_create_leaderboard_list(pClient.GetClient(), grouping));
list->destroy_func = destroy_leaderboard_list;
return list;
}
Expand Down Expand Up @@ -2580,7 +2585,10 @@ class AchievementRuntimeExports : private AchievementRuntime
Expects(wrapper != nullptr);

if (pList)
((rc_client_leaderboard_entry_list_info_t*)pList)->destroy_func = destroy_leaderboard_entry_list;
{
GSL_SUPPRESS_TYPE1
reinterpret_cast<rc_client_leaderboard_entry_list_info_t*>(pList)->destroy_func = destroy_leaderboard_entry_list;
}

wrapper->DoCallback(nResult, pList, sErrorMessage);

Expand All @@ -2598,6 +2606,7 @@ class AchievementRuntimeExports : private AchievementRuntime
uint32_t leaderboard_id, uint32_t first_entry, uint32_t count,
rc_client_fetch_leaderboard_entries_callback_t callback, void* callback_userdata)
{
GSL_SUPPRESS_R3
auto* pCallbackData = new LeaderboardEntriesListCallbackWrapper(client, callback, callback_userdata);

auto& pClient = ra::services::ServiceLocator::GetMutable<ra::services::AchievementRuntime>();
Expand All @@ -2609,6 +2618,7 @@ class AchievementRuntimeExports : private AchievementRuntime
uint32_t leaderboard_id, uint32_t count,
rc_client_fetch_leaderboard_entries_callback_t callback, void* callback_userdata)
{
GSL_SUPPRESS_R3
auto* pCallbackData = new LeaderboardEntriesListCallbackWrapper(client, callback, callback_userdata);

auto& pClient = ra::services::ServiceLocator::GetMutable<ra::services::AchievementRuntime>();
Expand All @@ -2628,7 +2638,7 @@ class AchievementRuntimeExports : private AchievementRuntime
return rc_client_has_rich_presence(pClient.GetClient());
}

static void do_frame()
static void do_frame() noexcept
{
_RA_DoAchievementsFrame();
}
Expand All @@ -2651,7 +2661,7 @@ class AchievementRuntimeExports : private AchievementRuntime
return rc_client_can_pause(pClient.GetClient(), frames_remaining);
}

static void reset()
static void reset() noexcept
{
#ifndef RA_UTEST
_RA_OnReset();
Expand Down Expand Up @@ -2705,49 +2715,49 @@ class AchievementRuntimeExports : private AchievementRuntime
s_callbacks.log_callback(sMessage, s_callbacks.log_client);
}

static void EventHandlerExternal(const rc_client_event_t* event, rc_client_t*)
static void EventHandlerExternal(const rc_client_event_t* event, rc_client_t*) noexcept(false)
{
if (s_callbacks.event_handler)
s_callbacks.event_handler(event, s_callbacks.event_client);
}

static uint32_t ReadMemoryBlock(uint32_t address, uint8_t* buffer, uint32_t num_bytes)
static uint32_t ReadMemoryBlock(uint32_t address, uint8_t* buffer, uint32_t num_bytes) noexcept(false)
{
if (s_callbacks.read_memory_handler)
return s_callbacks.read_memory_handler(address, buffer, num_bytes, s_callbacks.read_memory_client);

return 0;
}

static uint32_t ReadMemoryExternal(uint32_t address, uint8_t* buffer, uint32_t num_bytes, rc_client_t*)
static uint32_t ReadMemoryExternal(uint32_t address, uint8_t* buffer, uint32_t num_bytes, rc_client_t*) noexcept(false)
{
if (s_callbacks.read_memory_handler)
return s_callbacks.read_memory_handler(address, buffer, num_bytes, s_callbacks.read_memory_client);

return 0;
}

static rc_clock_t GetTimeMillisecsExternal(const rc_client_t*)
static rc_clock_t GetTimeMillisecsExternal(const rc_client_t*) noexcept(false)
{
if (s_callbacks.get_time_millisecs_handler)
return s_callbacks.get_time_millisecs_handler(s_callbacks.get_time_millisecs_client);

return 0;
}

static void destroy_achievement_list(rc_client_achievement_list_info_t* list)
static void destroy_achievement_list(rc_client_achievement_list_info_t* list) noexcept
{
if (list)
free(list);
}

static void destroy_leaderboard_list(rc_client_leaderboard_list_info_t* list)
static void destroy_leaderboard_list(rc_client_leaderboard_list_info_t* list) noexcept
{
if (list)
free(list);
}

static void destroy_leaderboard_entry_list(rc_client_leaderboard_entry_list_info_t* list)
static void destroy_leaderboard_entry_list(rc_client_leaderboard_entry_list_info_t* list) noexcept
{
if (list)
free(list);
Expand Down
6 changes: 4 additions & 2 deletions src/services/impl/WindowsHttpRequester.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,7 @@ unsigned int WindowsHttpRequester::Request(const Http::Request& pRequest, TextWr

// open the connection
auto sPathWide = ra::Widen(sPath);
GSL_SUPPRESS_ES47
HINTERNET hRequest = WinHttpOpenRequest(hConnect,
sPostData.empty() ? L"GET" : L"POST",
sPathWide.c_str(),
Expand Down Expand Up @@ -185,6 +186,7 @@ unsigned int WindowsHttpRequester::Request(const Http::Request& pRequest, TextWr
// send the request
if (sPostData.empty())
{
GSL_SUPPRESS_ES47
bResults = WinHttpSendRequest(hRequest,
sHeaders.c_str(), gsl::narrow_cast<int>(sHeaders.length()),
WINHTTP_NO_REQUEST_DATA,
Expand All @@ -195,7 +197,7 @@ unsigned int WindowsHttpRequester::Request(const Http::Request& pRequest, TextWr
{
bResults = WinHttpSendRequest(hRequest,
sHeaders.c_str(), gsl::narrow_cast<int>(sHeaders.length()),
static_cast<LPVOID>(sPostData.data()),
sPostData.data(),
gsl::narrow_cast<int>(sPostData.length()), gsl::narrow_cast<int>(sPostData.length()),
0);
}
Expand Down Expand Up @@ -319,7 +321,7 @@ std::string WindowsHttpRequester::GetStatusCodeText(unsigned int nStatusCode) co
const DWORD nResult = ::FormatMessage(FORMAT_MESSAGE_FROM_HMODULE | FORMAT_MESSAGE_IGNORE_INSERTS,
::GetModuleHandle(TEXT("winhttp.dll")),
nStatusCode, 0, (LPTSTR)szMessageBuffer,
sizeof(szMessageBuffer)/sizeof(szMessageBuffer[0]), NULL);
sizeof(szMessageBuffer)/sizeof(szMessageBuffer[0]), nullptr);

if (nResult > 0)
{
Expand Down
2 changes: 1 addition & 1 deletion src/ui/drawing/gdi/GDISurface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ void GDISurface::DrawSurface(int nX, int nY, const ISurface& pSurface)
if (pGDISurface != nullptr)
{
::BitBlt(m_hDC, nX, nY,
static_cast<int>(pSurface.GetWidth()), static_cast<int>(pSurface.GetHeight()),
gsl::narrow_cast<int>(pSurface.GetWidth()), gsl::narrow_cast<int>(pSurface.GetHeight()),
pGDISurface->m_hDC, 0, 0, SRCCOPY);
}
}
Expand Down
1 change: 1 addition & 0 deletions src/ui/drawing/gdi/ImageRepository.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ bool ImageRepository::Initialize()

if (SUCCEEDED(hr) || hr == RPC_E_CHANGED_MODE)
{
GSL_SUPPRESS_TYPE1
hr = CoCreateInstance(

#if defined (__cplusplus)
Expand Down

0 comments on commit 72f31df

Please sign in to comment.