[winpr] add WINPR_C_ARRAY_INIT

since C23 allows c++ style initializing replace direct use with this
macro
This commit is contained in:
Armin Novak
2026-02-24 20:18:25 +01:00
parent a5609b929e
commit 48267edf2f
434 changed files with 2204 additions and 2195 deletions

View File

@@ -136,7 +136,7 @@ static void dyn_log_(wLog* log, DWORD level, const pServerDynamicChannelContext*
getDirection(isBackData), channelName, drdynvc_get_packet_type(cmd),
channelId);
va_list ap = { 0 };
va_list ap = WINPR_C_ARRAY_INIT;
va_start(ap, fmt);
(void)winpr_vasprintf(&msg, &msglen, fmt, ap);
va_end(ap);
@@ -374,7 +374,7 @@ static PfChannelResult DynvcTrackerHandleCreateBack(ChannelStateTracker* tracker
DynChannelContext* dynChannelContext,
UINT64 dynChannelId)
{
proxyChannelDataEventInfo dev = { 0 };
proxyChannelDataEventInfo dev = WINPR_C_ARRAY_INIT;
const char* name = Stream_ConstPointer(s);
const size_t nameLen = Stream_GetRemainingLength(s);
const size_t len = strnlen(name, nameLen);
@@ -383,7 +383,7 @@ static PfChannelResult DynvcTrackerHandleCreateBack(ChannelStateTracker* tracker
if ((len == 0) || (len == nameLen) || (dynChannelId > UINT16_MAX))
{
char namebuffer[64] = { 0 };
char namebuffer[64] = WINPR_C_ARRAY_INIT;
(void)_snprintf(namebuffer, sizeof(namebuffer) - 1, "%s", name);
DynvcTrackerLog(dynChannelContext->log, WLOG_ERROR, dynChannel, cmd, isBackData,

View File

@@ -607,7 +607,7 @@ static UINT rdpdr_process_server_core_capability_request(pf_channel_client_conte
for (UINT16 i = 0; i < numCapabilities; i++)
{
RDPDR_CAPABILITY_HEADER header = { 0 };
RDPDR_CAPABILITY_HEADER header = WINPR_C_ARRAY_INIT;
UINT error = rdpdr_read_capset_header(rdpdr->log, s, &header);
if (error != CHANNEL_RC_OK)
return error;
@@ -777,7 +777,7 @@ static UINT rdpdr_process_client_capability_response(pf_channel_server_context*
for (UINT16 x = 0; x < numCapabilities; x++)
{
RDPDR_CAPABILITY_HEADER header = { 0 };
RDPDR_CAPABILITY_HEADER header = WINPR_C_ARRAY_INIT;
UINT error = rdpdr_read_capset_header(rdpdr->log, s, &header);
if (error != CHANNEL_RC_OK)
return error;
@@ -1092,7 +1092,7 @@ static BOOL pf_channel_rdpdr_rewrite_device_list_to(wStream* s, UINT32 fromVersi
for (UINT32 x = 0; x < count; x++)
{
RdpdrDevice device = { 0 };
RdpdrDevice device = WINPR_C_ARRAY_INIT;
const size_t charCount = ARRAYSIZE(device.PreferredDosName);
if (Stream_GetRemainingLength(clone) < 20)
goto fail;

View File

@@ -172,7 +172,7 @@ BOOL pf_channel_smartcard_client_handle(wLog* log, pClientContext* pc, wStream*
UINT32 FileId = 0;
UINT32 CompletionId = 0;
NTSTATUS ioStatus = 0;
pf_channel_client_queue_element e = { 0 };
pf_channel_client_queue_element e = WINPR_C_ARRAY_INIT;
pf_channel_client_context* scard = scard_get_client_context(pc);
WINPR_ASSERT(log);

View File

@@ -201,7 +201,7 @@ PfChannelResult channelTracker_flushCurrent(ChannelStateTracker* t, BOOL first,
if (toBack)
{
proxyChannelDataEventInfo ev = { 0 };
proxyChannelDataEventInfo ev = WINPR_C_ARRAY_INIT;
ev.channel_id = WINPR_ASSERTING_INT_CAST(UINT16, channel->front_channel_id);
ev.channel_name = channel->channel_name;
@@ -231,7 +231,7 @@ static PfChannelResult pf_channel_generic_back_data(proxyData* pdata,
const BYTE* xdata, size_t xsize, UINT32 flags,
size_t totalSize)
{
proxyChannelDataEventInfo ev = { 0 };
proxyChannelDataEventInfo ev = WINPR_C_ARRAY_INIT;
WINPR_ASSERT(pdata);
WINPR_ASSERT(channel);
@@ -266,7 +266,7 @@ static PfChannelResult pf_channel_generic_front_data(proxyData* pdata,
const BYTE* xdata, size_t xsize, UINT32 flags,
size_t totalSize)
{
proxyChannelDataEventInfo ev = { 0 };
proxyChannelDataEventInfo ev = WINPR_C_ARRAY_INIT;
WINPR_ASSERT(pdata);
WINPR_ASSERT(channel);

View File

@@ -397,7 +397,7 @@ static BOOL pf_client_load_channels(freerdp* instance)
for (; x < size;)
{
CHANNEL_DEF* cur = &channels[x];
proxyChannelDataEventInfo dev = { 0 };
proxyChannelDataEventInfo dev = WINPR_C_ARRAY_INIT;
dev.channel_name = cur->name;
dev.flags = cur->options;
@@ -800,7 +800,7 @@ static DWORD WINAPI pf_client_thread_proc(pClientContext* pc)
proxyData* pdata = NULL;
DWORD nCount = 0;
DWORD status = 0;
HANDLE handles[MAXIMUM_WAIT_OBJECTS] = { 0 };
HANDLE handles[MAXIMUM_WAIT_OBJECTS] = WINPR_C_ARRAY_INIT;
WINPR_ASSERT(pc);

View File

@@ -417,7 +417,7 @@ static char* pf_config_decode_base64(const char* data, const char* name, size_t*
/* Extract header for log message
* expected format is '----- SOMETEXT -----'
*/
char hdr[128] = { 0 };
char hdr[128] = WINPR_C_ARRAY_INIT;
const char* end = strchr(&data[5], '-');
if (end)
{
@@ -1326,7 +1326,7 @@ static BOOL config_plugin_channel_create(proxyPlugin* plugin, WINPR_ATTR_UNUSED
BOOL pf_config_plugin(proxyPluginsManager* plugins_manager, void* userdata)
{
struct config_plugin_data* custom = NULL;
proxyPlugin plugin = { 0 };
proxyPlugin plugin = WINPR_C_ARRAY_INIT;
plugin.name = config_plugin_name;
plugin.description = config_plugin_desc;

View File

@@ -306,7 +306,7 @@ out_fail:
pClientContext* pf_context_create_client_context(const rdpSettings* clientSettings)
{
RDP_CLIENT_ENTRY_POINTS clientEntryPoints = { 0 };
RDP_CLIENT_ENTRY_POINTS clientEntryPoints = WINPR_C_ARRAY_INIT;
WINPR_ASSERT(clientSettings);

View File

@@ -69,7 +69,7 @@ WINPR_ATTR_NODISCARD
static BOOL pf_server_keyboard_event(rdpInput* input, UINT16 flags, UINT8 code)
{
const proxyConfig* config = NULL;
proxyKeyboardEventInfo event = { 0 };
proxyKeyboardEventInfo event = WINPR_C_ARRAY_INIT;
pServerContext* ps = NULL;
pClientContext* pc = NULL;
@@ -103,7 +103,7 @@ WINPR_ATTR_NODISCARD
static BOOL pf_server_unicode_keyboard_event(rdpInput* input, UINT16 flags, UINT16 code)
{
const proxyConfig* config = NULL;
proxyUnicodeEventInfo event = { 0 };
proxyUnicodeEventInfo event = WINPR_C_ARRAY_INIT;
pServerContext* ps = NULL;
pClientContext* pc = NULL;
@@ -134,7 +134,7 @@ static BOOL pf_server_unicode_keyboard_event(rdpInput* input, UINT16 flags, UINT
WINPR_ATTR_NODISCARD
static BOOL pf_server_mouse_event(rdpInput* input, UINT16 flags, UINT16 x, UINT16 y)
{
proxyMouseEventInfo event = { 0 };
proxyMouseEventInfo event = WINPR_C_ARRAY_INIT;
const proxyConfig* config = NULL;
pServerContext* ps = NULL;
pClientContext* pc = NULL;
@@ -170,7 +170,7 @@ WINPR_ATTR_NODISCARD
static BOOL pf_server_extended_mouse_event(rdpInput* input, UINT16 flags, UINT16 x, UINT16 y)
{
const proxyConfig* config = NULL;
proxyMouseExEventInfo event = { 0 };
proxyMouseExEventInfo event = WINPR_C_ARRAY_INIT;
pServerContext* ps = NULL;
pClientContext* pc = NULL;

View File

@@ -419,7 +419,7 @@ WINPR_ATTR_NODISCARD
static BOOL pf_modules_register_plugin(proxyPluginsManager* mgr,
const proxyPlugin* plugin_to_register)
{
proxyPlugin internal = { 0 };
proxyPlugin internal = WINPR_C_ARRAY_INIT;
proxyModule* module = (proxyModule*)mgr;
WINPR_ASSERT(module);
@@ -512,7 +512,7 @@ static BOOL pf_modules_load_static_module(const char* module_name, proxyModule*
return FALSE;
}
char name[256] = { 0 };
char name[256] = WINPR_C_ARRAY_INIT;
(void)_snprintf(name, sizeof(name), "%s_%s", module_name, MODULE_ENTRY_POINT);
for (size_t x = 0; x < strnlen(name, sizeof(name)); x++)
{
@@ -604,7 +604,7 @@ static BOOL pf_modules_load_module(const char* module_path, const char* module_n
if (pf_modules_load_static_module(module_name, module, userdata))
return TRUE;
char names[5][MAX_PATH] = { 0 };
char names[5][MAX_PATH] = WINPR_C_ARRAY_INIT;
(void)_snprintf(names[0], sizeof(names[0]), "proxy-%s-plugin%s", module_name,
FREERDP_SHARED_LIBRARY_SUFFIX);
(void)_snprintf(names[1], sizeof(names[1]), "%sproxy-%s-plugin%s",

View File

@@ -114,7 +114,7 @@ static BOOL pf_server_get_target_info(rdpContext* context, rdpSettings* settings
const proxyConfig* config)
{
pServerContext* ps = (pServerContext*)context;
proxyFetchTargetEventInfo ev = { 0 };
proxyFetchTargetEventInfo ev = WINPR_C_ARRAY_INIT;
WINPR_ASSERT(settings);
WINPR_ASSERT(ps);
@@ -380,7 +380,7 @@ static BOOL pf_server_logon(freerdp_peer* peer, const SEC_WINNT_AUTH_IDENTITY* i
{
pServerContext* ps = NULL;
proxyData* pdata = NULL;
proxyServerPeerLogon info = { 0 };
proxyServerPeerLogon info = WINPR_C_ARRAY_INIT;
WINPR_ASSERT(peer);
@@ -446,7 +446,7 @@ static BOOL pf_server_receive_channel_data_hook(freerdp_peer* peer, UINT16 chann
{
case PF_CHANNEL_RESULT_PASS:
{
proxyChannelDataEventInfo ev = { 0 };
proxyChannelDataEventInfo ev = WINPR_C_ARRAY_INIT;
ev.channel_id = channelId;
ev.channel_name = channel->channel_name;
@@ -584,7 +584,7 @@ static BOOL pf_server_initialize_peer_connection(freerdp_peer* peer)
WINPR_ATTR_NODISCARD
static DWORD WINAPI pf_server_handle_peer(LPVOID arg)
{
HANDLE eventHandles[MAXIMUM_WAIT_OBJECTS] = { 0 };
HANDLE eventHandles[MAXIMUM_WAIT_OBJECTS] = WINPR_C_ARRAY_INIT;
pServerContext* ps = NULL;
proxyData* pdata = NULL;
peer_thread_args* args = arg;
@@ -1007,7 +1007,7 @@ out:
BOOL pf_server_run(proxyServer* server)
{
BOOL rc = TRUE;
HANDLE eventHandles[MAXIMUM_WAIT_OBJECTS] = { 0 };
HANDLE eventHandles[MAXIMUM_WAIT_OBJECTS] = WINPR_C_ARRAY_INIT;
DWORD eventCount = 0;
DWORD status = 0;
freerdp_listener* listener = NULL;