Skip to content

Commit f8f5980

Browse files
jkotasAaronRobinsonMSFT
authored andcommitted
Fix build breaks with clang 21 (#120644)
Contributes to #119706
1 parent 60629d1 commit f8f5980

File tree

18 files changed

+226
-196
lines changed

18 files changed

+226
-196
lines changed

src/coreclr/debug/di/rspriv.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6397,8 +6397,8 @@ class CordbThread : public CordbBase, public ICorDebugThread,
63976397
// Lazily initialized.
63986398
EXCEPTION_RECORD * m_pExceptionRecord;
63996399

6400-
static const CorDebugUserState kInvalidUserState = CorDebugUserState(-1);
6401-
CorDebugUserState m_userState; // This is the current state of the
6400+
static const int kInvalidUserState = -1;
6401+
int m_userState; // This is the current state of the
64026402
// thread, at the time that the
64036403
// left side synchronized
64046404

src/coreclr/debug/di/rsthread.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -782,7 +782,7 @@ CorDebugUserState CordbThread::GetUserState()
782782
m_userState = pDAC->GetUserState(m_vmThreadToken);
783783
}
784784

785-
return m_userState;
785+
return (CorDebugUserState)m_userState;
786786
}
787787

788788

@@ -886,7 +886,7 @@ HRESULT CordbThread::CreateStepper(ICorDebugStepper ** ppStepper)
886886
//Returns true if current user state of a thread is USER_WAIT_SLEEP_JOIN
887887
bool CordbThread::IsThreadWaitingOrSleeping()
888888
{
889-
CorDebugUserState userState = m_userState;
889+
int userState = m_userState;
890890
if (userState == kInvalidUserState)
891891
{
892892
//If m_userState is not ready, we'll read from DAC only part of it which

src/native/libs/System.Native/pal_networking.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -407,8 +407,10 @@ int32_t SystemNative_GetHostEntryForName(const uint8_t* address, int32_t address
407407
char name[_POSIX_HOST_NAME_MAX];
408408
result = gethostname((char*)name, _POSIX_HOST_NAME_MAX);
409409

410-
bool includeIPv4Loopback = true;
411-
bool includeIPv6Loopback = true;
410+
bool includeIPv4Loopback;
411+
bool includeIPv6Loopback;
412+
includeIPv4Loopback = true;
413+
includeIPv6Loopback = true;
412414

413415
if (result == 0 && strcasecmp((const char*)address, name) == 0)
414416
{
@@ -1526,7 +1528,7 @@ int32_t SystemNative_ReceiveSocketError(intptr_t socket, MessageHeader* messageH
15261528
#if HAVE_LINUX_ERRQUEUE_H
15271529
char buffer[sizeof(struct sock_extended_err) + sizeof(struct sockaddr_storage)];
15281530
messageHeader->ControlBufferLen = sizeof(buffer);
1529-
messageHeader->ControlBuffer = (void*)buffer;
1531+
messageHeader->ControlBuffer = (uint8_t*)buffer;
15301532

15311533
struct msghdr header;
15321534
struct icmphdr icmph;

src/native/libs/System.Native/pal_process.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,7 @@ int32_t SystemNative_ForkAndExecProcess(const char* filename,
254254

255255
if (setCredentials && groupsLength > 0)
256256
{
257-
getGroupsBuffer = malloc(sizeof(uint32_t) * Int32ToSizeT(groupsLength));
257+
getGroupsBuffer = (uint32_t*)(malloc(sizeof(uint32_t) * Int32ToSizeT(groupsLength)));
258258
if (getGroupsBuffer == NULL)
259259
{
260260
success = false;

src/native/libs/System.Native/pal_signal.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ static bool TryConvertSignalCodeToPosixSignal(int signalCode, PosixSignal* posix
130130
return true;
131131

132132
default:
133-
*posixSignal = signalCode;
133+
*posixSignal = (PosixSignal)signalCode;
134134
return false;
135135
}
136136
}

src/native/libs/System.Native/pal_threading.c

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -81,9 +81,9 @@ LowLevelMonitor* SystemNative_LowLevelMonitor_Create(void)
8181

8282
error = pthread_cond_init(&monitor->Condition, &conditionAttributes);
8383

84-
int condAttrDestroyError = pthread_condattr_destroy(&conditionAttributes);
84+
int condAttrDestroyError;
85+
condAttrDestroyError = pthread_condattr_destroy(&conditionAttributes);
8586
assert(condAttrDestroyError == 0);
86-
(void)condAttrDestroyError; // unused in release build
8787
#else
8888
error = pthread_cond_init(&monitor->Condition, NULL);
8989
#endif
@@ -117,18 +117,17 @@ void SystemNative_LowLevelMonitor_Destroy(LowLevelMonitor* monitor)
117117
error = pthread_mutex_destroy(&monitor->Mutex);
118118
assert(error == 0);
119119

120-
(void)error; // unused in release build
121-
122120
free(monitor);
123121
}
124122

125123
void SystemNative_LowLevelMonitor_Acquire(LowLevelMonitor* monitor)
126124
{
127125
assert(monitor != NULL);
128126

129-
int error = pthread_mutex_lock(&monitor->Mutex);
127+
int error;
128+
129+
error = pthread_mutex_lock(&monitor->Mutex);
130130
assert(error == 0);
131-
(void)error; // unused in release build
132131

133132
SetIsLocked(monitor, true);
134133
}
@@ -139,9 +138,10 @@ void SystemNative_LowLevelMonitor_Release(LowLevelMonitor* monitor)
139138

140139
SetIsLocked(monitor, false);
141140

142-
int error = pthread_mutex_unlock(&monitor->Mutex);
141+
int error;
142+
143+
error = pthread_mutex_unlock(&monitor->Mutex);
143144
assert(error == 0);
144-
(void)error; // unused in release build
145145
}
146146

147147
void SystemNative_LowLevelMonitor_Wait(LowLevelMonitor* monitor)
@@ -150,9 +150,10 @@ void SystemNative_LowLevelMonitor_Wait(LowLevelMonitor* monitor)
150150

151151
SetIsLocked(monitor, false);
152152

153-
int error = pthread_cond_wait(&monitor->Condition, &monitor->Mutex);
153+
int error;
154+
155+
error = pthread_cond_wait(&monitor->Condition, &monitor->Mutex);
154156
assert(error == 0);
155-
(void)error; // unused in release build
156157

157158
SetIsLocked(monitor, true);
158159
}
@@ -212,8 +213,6 @@ void SystemNative_LowLevelMonitor_Signal_Release(LowLevelMonitor* monitor)
212213

213214
error = pthread_mutex_unlock(&monitor->Mutex);
214215
assert(error == 0);
215-
216-
(void)error; // unused in release build
217216
}
218217

219218
int32_t SystemNative_CreateThread(uintptr_t stackSize, void *(*startAddress)(void*), void *parameter)

src/native/libs/System.Net.Security.Native/pal_gssapi.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,7 @@ uint32_t NetSecurityNative_ImportPrincipalName(uint32_t* minorStatus,
244244
// Principal name will usually be in the form SERVICE/HOST. But SPNEGO protocol prefers
245245
// GSS_C_NT_HOSTBASED_SERVICE format. That format uses '@' separator instead of '/' between
246246
// service name and host name. So convert input string into that format.
247-
char* ptrSlash = memchr(inputName, '/', inputNameLen);
247+
char* ptrSlash = (char*)memchr(inputName, '/', inputNameLen);
248248
char* inputNameCopy = NULL;
249249
if (ptrSlash != NULL)
250250
{

src/native/libs/System.Security.Cryptography.Native/memory_debug.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ static void do_track_entry(header_t* entry, int32_t add)
164164

165165
static void* mallocFunction(size_t size, const char *file, int line)
166166
{
167-
header_t* entry = malloc(size + sizeof(header_t));
167+
header_t* entry = (header_t*)malloc(size + sizeof(header_t));
168168
if (entry != NULL)
169169
{
170170
init_memory_entry(entry, size, file, line);
@@ -187,7 +187,7 @@ static void* reallocFunction (void *ptr, size_t size, const char *file, int line
187187
}
188188

189189
void* toReturn = NULL;
190-
header_t* newEntry = (header_t*) realloc((void*)entry, size + sizeof(header_t));
190+
header_t* newEntry = (header_t*)realloc((void*)entry, size + sizeof(header_t));
191191
if (newEntry != NULL)
192192
{
193193
entry = newEntry;
@@ -279,7 +279,7 @@ void CryptoNative_ForEachTrackedAllocation(void (*callback)(void* ptr, uint64_t
279279

280280
static void init_tracking_lists(void)
281281
{
282-
g_trackedMemory = malloc(kPartitionCount * sizeof(list_t));
282+
g_trackedMemory = (list_t*)malloc(kPartitionCount * sizeof(list_t));
283283
for (uint32_t i = 0; i < kPartitionCount; i++)
284284
{
285285
list_init(&g_trackedMemory[i]);

src/native/libs/System.Security.Cryptography.Native/openssl.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1371,6 +1371,7 @@ static int32_t EnsureOpenSsl10Initialized(void)
13711371
int numLocks = 0;
13721372
int locksInitialized = 0;
13731373
int randPollResult = 0;
1374+
size_t allocationSize = 0;
13741375

13751376
pthread_mutex_lock(&g_initLock);
13761377

@@ -1390,7 +1391,6 @@ static int32_t EnsureOpenSsl10Initialized(void)
13901391
}
13911392

13921393
// Create the locks array
1393-
size_t allocationSize = 0;
13941394
if (!multiply_s(sizeof(pthread_mutex_t), (size_t)numLocks, &allocationSize))
13951395
{
13961396
ret = 2;

src/native/libs/System.Security.Cryptography.Native/pal_ecc_import_export.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -790,6 +790,8 @@ int32_t CryptoNative_EvpPKeyGetEcCurveParameters(
790790
EC_GROUP* group = NULL;
791791
size_t generatorBufferSize = 0;
792792
unsigned char* generatorBuffer = NULL;
793+
int curveTypeNID;
794+
int fieldTypeNID;
793795

794796
// Exit if CryptoNative_EvpPKeyGetEcKeyParameters failed
795797
if (rc != 1)
@@ -798,7 +800,6 @@ int32_t CryptoNative_EvpPKeyGetEcCurveParameters(
798800
if (!xBn || !yBn)
799801
goto error;
800802

801-
int curveTypeNID;
802803
if (!CryptoNative_EvpPKeyGetEcGroupNid(pkey, &curveTypeNID) || !curveTypeNID)
803804
goto error;
804805

@@ -819,7 +820,7 @@ int32_t CryptoNative_EvpPKeyGetEcCurveParameters(
819820
// and some providers seem to be ignoring OSSL_PKEY_PARAM_EC_FIELD_TYPE.
820821
// This is specifically true for tpm2 provider.
821822
// We can reliably get the field type from the EC_GROUP.
822-
int fieldTypeNID = EC_GROUP_get_field_type(group);
823+
fieldTypeNID = EC_GROUP_get_field_type(group);
823824

824825
*curveType = NIDToCurveType(fieldTypeNID);
825826
if (*curveType == Unspecified)

0 commit comments

Comments
 (0)