[warnings] fix clang-tidy issues in server

This commit is contained in:
akallabeth
2024-08-29 15:10:04 +02:00
parent 6a3564407e
commit 24cd7828c9
6 changed files with 34 additions and 50 deletions

View File

@@ -46,7 +46,7 @@ static const std::vector<std::string>& plugin_static_intercept()
{
static std::vector<std::string> vec;
if (vec.empty())
vec.push_back(DRDYNVC_SVC_CHANNEL_NAME);
vec.emplace_back(DRDYNVC_SVC_CHANNEL_NAME);
return vec;
}
@@ -54,7 +54,7 @@ static const std::vector<std::string>& plugin_dyn_intercept()
{
static std::vector<std::string> vec;
if (vec.empty())
vec.push_back(RDPGFX_DVC_CHANNEL_NAME);
vec.emplace_back(RDPGFX_DVC_CHANNEL_NAME);
return vec;
}
@@ -403,7 +403,7 @@ static BOOL filter_dyn_channel_intercept(proxyPlugin* plugin, proxyData* pdata,
return TRUE;
}
static BOOL filter_server_session_started(proxyPlugin* plugin, proxyData* pdata, void*)
static BOOL filter_server_session_started(proxyPlugin* plugin, proxyData* pdata, void* /*unused*/)
{
WINPR_ASSERT(plugin);
WINPR_ASSERT(pdata);
@@ -421,7 +421,7 @@ static BOOL filter_server_session_started(proxyPlugin* plugin, proxyData* pdata,
return TRUE;
}
static BOOL filter_server_session_end(proxyPlugin* plugin, proxyData* pdata, void*)
static BOOL filter_server_session_end(proxyPlugin* plugin, proxyData* pdata, void* /*unused*/)
{
WINPR_ASSERT(plugin);
WINPR_ASSERT(pdata);

View File

@@ -265,7 +265,7 @@ static BOOL demo_mouse_ex_event(proxyPlugin* plugin, proxyData* pdata, void* par
static BOOL demo_client_channel_data(proxyPlugin* plugin, proxyData* pdata, void* param)
{
const proxyChannelDataEventInfo* channel = static_cast<const proxyChannelDataEventInfo*>(param);
const auto* channel = static_cast<const proxyChannelDataEventInfo*>(param);
WINPR_ASSERT(plugin);
WINPR_ASSERT(pdata);
@@ -278,7 +278,7 @@ static BOOL demo_client_channel_data(proxyPlugin* plugin, proxyData* pdata, void
static BOOL demo_server_channel_data(proxyPlugin* plugin, proxyData* pdata, void* param)
{
const proxyChannelDataEventInfo* channel = static_cast<const proxyChannelDataEventInfo*>(param);
const auto* channel = static_cast<const proxyChannelDataEventInfo*>(param);
WINPR_ASSERT(plugin);
WINPR_ASSERT(pdata);
@@ -291,7 +291,7 @@ static BOOL demo_server_channel_data(proxyPlugin* plugin, proxyData* pdata, void
static BOOL demo_dynamic_channel_create(proxyPlugin* plugin, proxyData* pdata, void* param)
{
const proxyChannelDataEventInfo* channel = static_cast<const proxyChannelDataEventInfo*>(param);
const auto* channel = static_cast<const proxyChannelDataEventInfo*>(param);
WINPR_ASSERT(plugin);
WINPR_ASSERT(pdata);

View File

@@ -24,6 +24,7 @@
#include <fstream>
#include <iostream>
#include <regex>
#include <utility>
#include <vector>
#include <sstream>
#include <string>
@@ -59,7 +60,7 @@ static const std::vector<std::string>& plugin_static_intercept()
{
static std::vector<std::string> vec;
if (vec.empty())
vec.push_back(DRDYNVC_SVC_CHANNEL_NAME);
vec.emplace_back(DRDYNVC_SVC_CHANNEL_NAME);
return vec;
}
@@ -73,7 +74,7 @@ class PluginData
{
}
proxyPluginsManager* mgr() const
[[nodiscard]] proxyPluginsManager* mgr() const
{
return _mgr;
}
@@ -85,14 +86,14 @@ class PluginData
private:
proxyPluginsManager* _mgr;
uint64_t _sessionid;
uint64_t _sessionid{ 0 };
};
class ChannelData
{
public:
ChannelData(const std::string& base, const std::vector<std::string>& list, uint64_t sessionid)
: _base(base), _channels_to_dump(list), _session_id(sessionid)
ChannelData(const std::string& base, std::vector<std::string> list, uint64_t sessionid)
: _base(base), _channels_to_dump(std::move(list)), _session_id(sessionid)
{
char str[64] = {};
(void)_snprintf(str, sizeof(str), "session-%016" PRIx64, _session_id);
@@ -120,7 +121,7 @@ class ChannelData
return std::ofstream(path);
}
bool dump_enabled(const std::string& name) const
[[nodiscard]] bool dump_enabled(const std::string& name) const
{
if (name.empty())
{
@@ -166,13 +167,13 @@ class ChannelData
return true;
}
uint64_t session() const
[[nodiscard]] uint64_t session() const
{
return _session_id;
}
private:
fs::path filepath(const std::string& channel, bool back, uint64_t count) const
[[nodiscard]] fs::path filepath(const std::string& channel, bool back, uint64_t count) const
{
auto name = idstr(channel, back);
char cstr[32] = {};
@@ -183,7 +184,7 @@ class ChannelData
return path;
}
std::string idstr(const std::string& name, bool back) const
[[nodiscard]] static std::string idstr(const std::string& name, bool back)
{
std::stringstream ss;
ss << name << ".";
@@ -194,7 +195,6 @@ class ChannelData
return ss.str();
}
private:
fs::path _base;
std::vector<std::string> _channels_to_dump;
@@ -353,7 +353,7 @@ static std::vector<std::string> split(const std::string& input, const std::strin
return { first, last };
}
static BOOL dump_session_started(proxyPlugin* plugin, proxyData* pdata, void*)
static BOOL dump_session_started(proxyPlugin* plugin, proxyData* pdata, void* /*unused*/)
{
WINPR_ASSERT(plugin);
WINPR_ASSERT(pdata);
@@ -395,7 +395,7 @@ static BOOL dump_session_started(proxyPlugin* plugin, proxyData* pdata, void*)
return TRUE;
}
static BOOL dump_session_end(proxyPlugin* plugin, proxyData* pdata, void*)
static BOOL dump_session_end(proxyPlugin* plugin, proxyData* pdata, void* /*unused*/)
{
WINPR_ASSERT(plugin);
WINPR_ASSERT(pdata);

View File

@@ -50,12 +50,12 @@
#define CONFIG_PRINT_SECTION(section) WLog_INFO(TAG, "\t%s:", section)
#define CONFIG_PRINT_SECTION_KEY(section, key) WLog_INFO(TAG, "\t%s/%s:", section, key)
#define CONFIG_PRINT_STR(config, key) WLog_INFO(TAG, "\t\t%s: %s", #key, config->key)
#define CONFIG_PRINT_STR(config, key) WLog_INFO(TAG, "\t\t%s: %s", #key, (config)->key)
#define CONFIG_PRINT_STR_CONTENT(config, key) \
WLog_INFO(TAG, "\t\t%s: %s", #key, config->key ? "set" : NULL)
#define CONFIG_PRINT_BOOL(config, key) WLog_INFO(TAG, "\t\t%s: %s", #key, boolstr(config->key))
#define CONFIG_PRINT_UINT16(config, key) WLog_INFO(TAG, "\t\t%s: %" PRIu16 "", #key, config->key)
#define CONFIG_PRINT_UINT32(config, key) WLog_INFO(TAG, "\t\t%s: %" PRIu32 "", #key, config->key)
WLog_INFO(TAG, "\t\t%s: %s", #key, (config)->key ? "set" : NULL)
#define CONFIG_PRINT_BOOL(config, key) WLog_INFO(TAG, "\t\t%s: %s", #key, boolstr((config)->key))
#define CONFIG_PRINT_UINT16(config, key) WLog_INFO(TAG, "\t\t%s: %" PRIu16 "", #key, (config)->key)
#define CONFIG_PRINT_UINT32(config, key) WLog_INFO(TAG, "\t\t%s: %" PRIu32 "", #key, (config)->key)
static const char* bool_str_true = "true";
static const char* bool_str_false = "false";

View File

@@ -102,11 +102,9 @@ void shadow_multiclient_free(rdpShadowMultiClientEvent* event)
CloseHandle(event->barrierEvent);
CloseHandle(event->event);
free(event);
return;
}
static void _Publish(rdpShadowMultiClientEvent* event)
static void Publish(rdpShadowMultiClientEvent* event)
{
wArrayList* subscribers = NULL;
struct rdp_shadow_multiclient_subscriber* subscriber = NULL;
@@ -133,11 +131,9 @@ static void _Publish(rdpShadowMultiClientEvent* event)
ResetEvent(event->doneEvent);
SetEvent(event->event);
}
return;
}
static void _WaitForSubscribers(rdpShadowMultiClientEvent* event)
static void WaitForSubscribers(rdpShadowMultiClientEvent* event)
{
if (event->consuming > 0)
{
@@ -151,8 +147,6 @@ static void _WaitForSubscribers(rdpShadowMultiClientEvent* event)
/* Last subscriber should have already reset the event */
WINPR_ASSERT(WaitForSingleObject(event->event, 0) != WAIT_OBJECT_0);
return;
}
void shadow_multiclient_publish(rdpShadowMultiClientEvent* event)
@@ -161,10 +155,8 @@ void shadow_multiclient_publish(rdpShadowMultiClientEvent* event)
return;
EnterCriticalSection(&(event->lock));
_Publish(event);
Publish(event);
LeaveCriticalSection(&(event->lock));
return;
}
void shadow_multiclient_wait(rdpShadowMultiClientEvent* event)
{
@@ -172,10 +164,8 @@ void shadow_multiclient_wait(rdpShadowMultiClientEvent* event)
return;
EnterCriticalSection(&(event->lock));
_WaitForSubscribers(event);
WaitForSubscribers(event);
LeaveCriticalSection(&(event->lock));
return;
}
void shadow_multiclient_publish_and_wait(rdpShadowMultiClientEvent* event)
{
@@ -183,14 +173,12 @@ void shadow_multiclient_publish_and_wait(rdpShadowMultiClientEvent* event)
return;
EnterCriticalSection(&(event->lock));
_Publish(event);
_WaitForSubscribers(event);
Publish(event);
WaitForSubscribers(event);
LeaveCriticalSection(&(event->lock));
return;
}
static BOOL _Consume(struct rdp_shadow_multiclient_subscriber* subscriber, BOOL wait)
static BOOL Consume(struct rdp_shadow_multiclient_subscriber* subscriber, BOOL wait)
{
rdpShadowMultiClientEvent* event = subscriber->ref;
BOOL ret = FALSE;
@@ -272,7 +260,7 @@ void* shadow_multiclient_get_subscriber(rdpShadowMultiClientEvent* event)
WLog_VRB(TAG, "Get subscriber %p. Wait event %d. %d clients.\n", (void*)subscriber,
event->eventid, event->consuming);
(void)_Consume(subscriber, TRUE);
(void)Consume(subscriber, TRUE);
WLog_VRB(TAG, "Get subscriber %p. Quit event %d. %d clients.\n", (void*)subscriber,
event->eventid, event->consuming);
@@ -308,7 +296,7 @@ void shadow_multiclient_release_subscriber(void* subscriber)
WLog_VRB(TAG, "Release Subscriber %p. Drop event %d. %d clients.\n", subscriber, event->eventid,
event->consuming);
(void)_Consume(s, FALSE);
(void)Consume(s, FALSE);
WLog_VRB(TAG, "Release Subscriber %p. Quit event %d. %d clients.\n", subscriber, event->eventid,
event->consuming);
@@ -317,8 +305,6 @@ void shadow_multiclient_release_subscriber(void* subscriber)
LeaveCriticalSection(&(event->lock));
free(subscriber);
return;
}
BOOL shadow_multiclient_consume(void* subscriber)
@@ -337,7 +323,7 @@ BOOL shadow_multiclient_consume(void* subscriber)
WLog_VRB(TAG, "Subscriber %p wait event %d. %d clients.\n", subscriber, event->eventid,
event->consuming);
ret = _Consume(s, TRUE);
ret = Consume(s, TRUE);
WLog_VRB(TAG, "Subscriber %p quit event %d. %d clients.\n", subscriber, event->eventid,
event->consuming);

View File

@@ -70,6 +70,4 @@ void shadow_subsystem_set_entry_builtin(const char* name)
if (entry)
shadow_subsystem_set_entry(entry);
return;
}