[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

@@ -440,7 +440,7 @@ static inline void* base64_decode(const signed char* WINPR_RESTRICT alphabet, si
const char* WINPR_RESTRICT s, size_t length,
size_t* WINPR_RESTRICT data_len, BOOL pad)
{
int n[4] = { 0 };
int n[4] = WINPR_C_ARRAY_INIT;
BYTE* data = NULL;
const size_t remainder = length % 4;

View File

@@ -87,7 +87,7 @@ BOOL read_bignum(BYTE** dst, DWORD* length, const BIGNUM* num, BOOL alloc)
BOOL cert_info_create(rdpCertInfo* dst, const BIGNUM* rsa, const BIGNUM* rsa_e)
{
const rdpCertInfo empty = { 0 };
const rdpCertInfo empty = WINPR_C_ARRAY_INIT;
WINPR_ASSERT(dst);
WINPR_ASSERT(rsa);

View File

@@ -293,7 +293,7 @@ static BOOL is_rsa_key(const X509* x509)
static BOOL certificate_read_x509_certificate(const rdpCertBlob* cert, rdpCertInfo* info)
{
wStream sbuffer = { 0 };
wStream sbuffer = WINPR_C_ARRAY_INIT;
wStream* s = NULL;
size_t length = 0;
BYTE padding = 0;
@@ -441,7 +441,7 @@ error:
static rdpX509CertChain certificate_new_x509_certificate_chain(UINT32 count)
{
rdpX509CertChain x509_cert_chain = { 0 };
rdpX509CertChain x509_cert_chain = WINPR_C_ARRAY_INIT;
x509_cert_chain.array = (rdpCertBlob*)calloc(count, sizeof(rdpCertBlob));
@@ -661,7 +661,7 @@ fail:
static BOOL certificate_process_server_public_key(rdpCertificate* cert, wStream* s,
WINPR_ATTR_UNUSED UINT32 length)
{
char magic[sizeof(rsa_magic)] = { 0 };
char magic[sizeof(rsa_magic)] = WINPR_C_ARRAY_INIT;
UINT32 keylen = 0;
UINT32 bitlen = 0;
UINT32 datalen = 0;
@@ -919,8 +919,8 @@ static BOOL cert_write_rsa_public_key(wStream* s, const rdpCertificate* cert)
static BOOL cert_write_rsa_signature(wStream* s, const void* sigData, size_t sigDataLen)
{
BYTE encryptedSignature[TSSK_KEY_LENGTH] = { 0 };
BYTE signature[sizeof(initial_signature)] = { 0 };
BYTE encryptedSignature[TSSK_KEY_LENGTH] = WINPR_C_ARRAY_INIT;
BYTE signature[sizeof(initial_signature)] = WINPR_C_ARRAY_INIT;
memcpy(signature, initial_signature, sizeof(initial_signature));
if (!winpr_Digest(WINPR_MD_MD5, sigData, sigDataLen, signature, sizeof(signature)))

View File

@@ -305,7 +305,7 @@ const char* freerdp_certificate_data_get_hash(const rdpCertificateData* cert)
char* freerdp_certificate_data_hash(const char* hostname, UINT16 port)
{
char name[MAX_PATH + 10] = { 0 };
char name[MAX_PATH + 10] = WINPR_C_ARRAY_INIT;
freerdp_certificate_data_hash_(hostname, port, name, sizeof(name));
return strndup(name, sizeof(name));
}

View File

@@ -235,7 +235,7 @@ char* crypto_read_pem(const char* WINPR_RESTRICT filename, size_t* WINPR_RESTRIC
fail:
{
char buffer[8192] = { 0 };
char buffer[8192] = WINPR_C_ARRAY_INIT;
WLog_WARN(TAG, "Failed to read PEM from file '%s' [%s]", filename,
winpr_strerror(errno, buffer, sizeof(buffer)));
}
@@ -264,7 +264,7 @@ BOOL crypto_write_pem(const char* WINPR_RESTRICT filename, const char* WINPR_RES
fail:
if (rc == 0)
{
char buffer[8192] = { 0 };
char buffer[8192] = WINPR_C_ARRAY_INIT;
WLog_WARN(TAG, "Failed to write PEM [%" PRIuz "] to file '%s' [%s]", length, filename,
winpr_strerror(errno, buffer, sizeof(buffer)));
}

View File

@@ -419,7 +419,7 @@ BOOL per_read_object_identifier(wStream* s, const BYTE oid[6])
{
BYTE t12 = 0;
UINT16 length = 0;
BYTE a_oid[6] = { 0 };
BYTE a_oid[6] = WINPR_C_ARRAY_INIT;
if (!per_read_length(s, &length))
return FALSE;

View File

@@ -162,7 +162,7 @@ static BOOL key_read_private(rdpPrivateKey* key)
RSA* rsa = evp_pkey_to_rsa(key);
if (!rsa)
{
char ebuffer[256] = { 0 };
char ebuffer[256] = WINPR_C_ARRAY_INIT;
WLog_ERR(TAG, "unable to load RSA key: %s.",
winpr_strerror(errno, ebuffer, sizeof(ebuffer)));
goto fail;
@@ -180,7 +180,7 @@ static BOOL key_read_private(rdpPrivateKey* key)
default:
{
char ebuffer[256] = { 0 };
char ebuffer[256] = WINPR_C_ARRAY_INIT;
WLog_ERR(TAG, "unexpected error when checking RSA key: %s.",
winpr_strerror(errno, ebuffer, sizeof(ebuffer)));
goto fail;
@@ -408,7 +408,7 @@ BOOL freerdp_key_generate(rdpPrivateKey* key, const char* type, size_t count, ..
WLog_ERR(TAG, "Argument type=%s requires count=1, got %" PRIuz ", aborting", type, count);
return FALSE;
}
va_list ap = { 0 };
va_list ap = WINPR_C_ARRAY_INIT;
va_start(ap, count);
const int key_length = va_arg(ap, int);
va_end(ap);

View File

@@ -132,7 +132,7 @@ static const char* general_name_type_label(int general_name_type)
}
else
{
static char buffer[80] = { 0 };
static char buffer[80] = WINPR_C_ARRAY_INIT;
(void)snprintf(buffer, sizeof(buffer), "Unknown general name type (%d)", general_name_type);
return buffer;
}
@@ -456,7 +456,7 @@ char* x509_utils_get_email(const X509* x509)
char* x509_utils_get_upn(const X509* x509)
{
char* result = 0;
object_list list = { 0 };
object_list list = WINPR_C_ARRAY_INIT;
object_list_initialize(&list);
list.type_id = OBJ_nid2obj(NID_ms_upn);
list.maximum = 1;
@@ -521,7 +521,7 @@ void x509_utils_dns_names_free(size_t count, size_t* lengths, char** dns_names)
char** x509_utils_get_dns_names(const X509* x509, size_t* count, size_t** lengths)
{
char** result = 0;
string_list list = { 0 };
string_list list = WINPR_C_ARRAY_INIT;
string_list_initialize(&list);
map_subject_alt_name(x509, GEN_DNS, extract_string, &list);
(*count) = list.count;