diff --git a/src/coreclr/inc/corhlprpriv.h b/src/coreclr/inc/corhlprpriv.h index 38faa6f6ef8be7..2c8372860ba2e2 100644 --- a/src/coreclr/inc/corhlprpriv.h +++ b/src/coreclr/inc/corhlprpriv.h @@ -605,7 +605,7 @@ class RidBitmap HRESULT hr = S_OK; mdToken rid = RidFromToken(token); SIZE_T index = rid / 8; - BYTE bit = (1 << (rid % 8)); + BYTE bit = (BYTE)(1 << (rid % 8)); if (index >= buffer.Size()) { @@ -623,7 +623,7 @@ class RidBitmap { mdToken rid = RidFromToken(token); SIZE_T index = rid / 8; - BYTE bit = (1 << (rid % 8)); + BYTE bit = (BYTE)(1 << (rid % 8)); return ((index < buffer.Size()) && (buffer[index] & bit)); } diff --git a/src/coreclr/inc/llvm/ELF.h b/src/coreclr/inc/llvm/ELF.h index 9e89b48b514a3c..b38ecf9eba73a7 100644 --- a/src/coreclr/inc/llvm/ELF.h +++ b/src/coreclr/inc/llvm/ELF.h @@ -829,7 +829,7 @@ struct Elf32_Sym { void setBinding(unsigned char b) { setBindingAndType(b, getType()); } void setType(unsigned char t) { setBindingAndType(getBinding(), t); } void setBindingAndType(unsigned char b, unsigned char t) { - st_info = (b << 4) + (t & 0x0f); + st_info = (unsigned char)((b << 4) + (t & 0x0f)); } }; @@ -849,7 +849,7 @@ struct Elf64_Sym { void setBinding(unsigned char b) { setBindingAndType(b, getType()); } void setType(unsigned char t) { setBindingAndType(getBinding(), t); } void setBindingAndType(unsigned char b, unsigned char t) { - st_info = (b << 4) + (t & 0x0f); + st_info = (unsigned char)((b << 4) + (t & 0x0f)); } }; diff --git a/src/coreclr/pal/inc/pal_endian.h b/src/coreclr/pal/inc/pal_endian.h index 6822b004ddaafe..43a8167562eeee 100644 --- a/src/coreclr/pal/inc/pal_endian.h +++ b/src/coreclr/pal/inc/pal_endian.h @@ -16,7 +16,7 @@ extern "C++" { inline UINT16 SWAP16(UINT16 x) { - return (x >> 8) | (x << 8); + return (UINT16)((x >> 8) | (x << 8)); } inline UINT32 SWAP32(UINT32 x) diff --git a/src/coreclr/pal/src/cruntime/file.cpp b/src/coreclr/pal/src/cruntime/file.cpp index eb2512c68e0e39..70462122c10a2e 100644 --- a/src/coreclr/pal/src/cruntime/file.cpp +++ b/src/coreclr/pal/src/cruntime/file.cpp @@ -522,7 +522,7 @@ PAL_fread(void * buffer, size_t size, size_t count, PAL_FILE * f) } else { - temp[nCount++]=nChar; + temp[nCount++]= (char)nChar; } } } diff --git a/src/coreclr/pal/src/cruntime/printf.cpp b/src/coreclr/pal/src/cruntime/printf.cpp index 00c7d70c8af58e..c312a935656f95 100644 --- a/src/coreclr/pal/src/cruntime/printf.cpp +++ b/src/coreclr/pal/src/cruntime/printf.cpp @@ -265,7 +265,7 @@ static BOOL Internal_ScanfExtractFormatW(LPCWSTR *Fmt, LPSTR Out, int iOutSize, if (*Fmt && **Fmt == '%') { - *Out++ = *(*Fmt)++; + *Out++ = (CHAR)*(*Fmt)++; } else { @@ -285,7 +285,7 @@ static BOOL Internal_ScanfExtractFormatW(LPCWSTR *Fmt, LPSTR Out, int iOutSize, if (**Fmt == '*') { *Store = FALSE; - *Out++ = *(*Fmt)++; + *Out++ = (CHAR)*(*Fmt)++; } /* grab width specifier */ @@ -294,8 +294,8 @@ static BOOL Internal_ScanfExtractFormatW(LPCWSTR *Fmt, LPSTR Out, int iOutSize, TempStrPtr = TempStr; while (isdigit(**Fmt)) { - *TempStrPtr++ = **Fmt; - *Out++ = *(*Fmt)++; + *TempStrPtr++ = (CHAR)**Fmt; + *Out++ = (CHAR)*(*Fmt)++; } *TempStrPtr = 0; /* end string */ *Width = atoi(TempStr); @@ -406,7 +406,7 @@ static BOOL Internal_ScanfExtractFormatW(LPCWSTR *Fmt, LPSTR Out, int iOutSize, Out += strlen(scanf_longlongfmt); } - *Out++ = *(*Fmt)++; + *Out++ = (CHAR)*(*Fmt)++; Result = TRUE; } else if (**Fmt == 'e' || **Fmt == 'E' || **Fmt == 'f' || @@ -416,7 +416,7 @@ static BOOL Internal_ScanfExtractFormatW(LPCWSTR *Fmt, LPSTR Out, int iOutSize, *Type = SCANF_TYPE_FLOAT; /* this gets rid of %E/%G since they're they're the same when scanning */ - *Out++ = tolower( *(*Fmt)++ ); + *Out++ = (CHAR)tolower( *(*Fmt)++ ); Result = TRUE; } else if (**Fmt == 'n') @@ -425,7 +425,7 @@ static BOOL Internal_ScanfExtractFormatW(LPCWSTR *Fmt, LPSTR Out, int iOutSize, { *Out++ = 'h'; } - *Out++ = *(*Fmt)++; + *Out++ = (CHAR)*(*Fmt)++; *Type = SCANF_TYPE_N; Result = TRUE; } @@ -489,8 +489,8 @@ static BOOL Internal_ScanfExtractFormatW(LPCWSTR *Fmt, LPSTR Out, int iOutSize, unsigned char prev, next; /* get the interval boundaries */ - prev = (*Fmt)[-1]; - next = (*Fmt)[1]; + prev = (unsigned char)(*Fmt)[-1]; + next = (unsigned char)(*Fmt)[1]; /* if boundaries were inverted, replace the already-copied low boundary by the 'real' low boundary */ @@ -514,7 +514,7 @@ static BOOL Internal_ScanfExtractFormatW(LPCWSTR *Fmt, LPSTR Out, int iOutSize, else { /* plain character; just copy it */ - *Out++ = **Fmt; + *Out++ = (CHAR)**Fmt; (*Fmt)++; } } @@ -625,7 +625,7 @@ int PAL_wvsscanf(LPCWSTR Buffer, LPCWSTR Format, va_list ap) { if (Prefix == SCANF_PREFIX_SHORT) { - *(va_arg(ap, short *)) = Buff - Buffer; + *(va_arg(ap, short *)) = (short)(Buff - Buffer); } else { diff --git a/src/coreclr/pal/src/cruntime/printfcpp.cpp b/src/coreclr/pal/src/cruntime/printfcpp.cpp index e014fe015e21f9..ae37ffbf1a27a2 100644 --- a/src/coreclr/pal/src/cruntime/printfcpp.cpp +++ b/src/coreclr/pal/src/cruntime/printfcpp.cpp @@ -706,7 +706,7 @@ BOOL Internal_ExtractFormatW(CPalThread *pthrCurrent, LPCWSTR *Fmt, LPSTR Out, L *Out++ = 'l'; *Out++ = 'l'; } - *Out++ = *(*Fmt)++; + *Out++ = (CHAR)*(*Fmt)++; Result = TRUE; } else if (**Fmt == 'e' || **Fmt == 'E' || **Fmt == 'f' || @@ -719,7 +719,7 @@ BOOL Internal_ExtractFormatW(CPalThread *pthrCurrent, LPCWSTR *Fmt, LPSTR Out, L } *Type = PFF_TYPE_FLOAT; - *Out++ = *(*Fmt)++; + *Out++ = (CHAR)*(*Fmt)++; Result = TRUE; } else if (**Fmt == 'n') @@ -733,7 +733,7 @@ BOOL Internal_ExtractFormatW(CPalThread *pthrCurrent, LPCWSTR *Fmt, LPSTR Out, L { *Out++ = 'h'; } - *Out++ = *(*Fmt)++; + *Out++ = (CHAR)*(*Fmt)++; *Type = PFF_TYPE_N; Result = TRUE; } @@ -1220,8 +1220,8 @@ int CoreVfwprintf(CPalThread *pthrCurrent, PAL_FILE *stream, const wchar_16 *for TempInt = va_arg(ap, INT); /* value not used */ } - TempWChar[0] = va_arg(ap, int); - TempWChar[1] = 0; + TempWChar[0] = (WCHAR)va_arg(ap, int); + TempWChar[1] = W('\0'); /* do the padding (if needed)*/ paddingReturnValue = @@ -1254,7 +1254,7 @@ int CoreVfwprintf(CPalThread *pthrCurrent, PAL_FILE *stream, const wchar_16 *for if (Prefix == PFF_PREFIX_SHORT) { - *(va_arg(ap, short *)) = written; + *(va_arg(ap, short *)) = (short)written; } else { @@ -1605,7 +1605,7 @@ int CoreVfprintf(CPalThread *pthrCurrent, PAL_FILE *stream, const char *format, TempInt = va_arg(ap, INT); /* value not used */ } - TempWChar = va_arg(ap, int); + TempWChar = (WCHAR)va_arg(ap, int); Length = WideCharToMultiByte(CP_ACP, 0, &TempWChar, 1, TempBuffer, sizeof(TempBuffer), 0, 0); @@ -1617,7 +1617,7 @@ int CoreVfprintf(CPalThread *pthrCurrent, PAL_FILE *stream, const char *format, va_end(ap); return -1; } - TempBuffer[Length] = 0; + TempBuffer[Length] = W('\0'); /* do the padding (if needed)*/ paddingReturnValue = @@ -1648,7 +1648,7 @@ int CoreVfprintf(CPalThread *pthrCurrent, PAL_FILE *stream, const char *format, if (Prefix == PFF_PREFIX_SHORT) { - *(va_arg(ap, short *)) = written; + *(va_arg(ap, short *)) = (short)written; } else { diff --git a/src/coreclr/pal/src/cruntime/silent_printf.cpp b/src/coreclr/pal/src/cruntime/silent_printf.cpp index 17e3007c762fc2..05a0e85906c811 100644 --- a/src/coreclr/pal/src/cruntime/silent_printf.cpp +++ b/src/coreclr/pal/src/cruntime/silent_printf.cpp @@ -168,7 +168,7 @@ int Silent_PAL_vfprintf(PAL_FILE *stream, const char *format, va_list aparg) TempInt = va_arg(ap, INT); /* value not used */ } - TempWChar = va_arg(ap, int); + TempWChar = (WCHAR)va_arg(ap, int); Length = Silent_WideCharToMultiByte(&TempWChar, 1, TempBuffer, 4); if (!Length) { @@ -204,7 +204,7 @@ int Silent_PAL_vfprintf(PAL_FILE *stream, const char *format, va_list aparg) if (Prefix == PFF_PREFIX_SHORT) { - *(va_arg(ap, short *)) = written; + *(va_arg(ap, short *)) = (short)written; } else { diff --git a/src/coreclr/pal/src/file/filetime.cpp b/src/coreclr/pal/src/file/filetime.cpp index 768ee426c4dbfa..ea8ca6bd0535ad 100644 --- a/src/coreclr/pal/src/file/filetime.cpp +++ b/src/coreclr/pal/src/file/filetime.cpp @@ -294,16 +294,16 @@ BOOL PALAPI FileTimeToSystemTime( CONST FILETIME * lpFileTime, #endif /* HAVE_GMTIME_R */ /* Convert unix system time to Windows system time. */ - lpSystemTime->wDay = UnixSystemTime->tm_mday; + lpSystemTime->wDay = (WORD)UnixSystemTime->tm_mday; /* Unix time counts January as a 0, under Windows it is 1*/ - lpSystemTime->wMonth = UnixSystemTime->tm_mon + 1; + lpSystemTime->wMonth = (WORD)UnixSystemTime->tm_mon + 1; /* Unix time returns the year - 1900, Windows returns the current year*/ - lpSystemTime->wYear = UnixSystemTime->tm_year + 1900; + lpSystemTime->wYear = (WORD)UnixSystemTime->tm_year + 1900; - lpSystemTime->wSecond = UnixSystemTime->tm_sec; - lpSystemTime->wMinute = UnixSystemTime->tm_min; - lpSystemTime->wHour = UnixSystemTime->tm_hour; + lpSystemTime->wSecond = (WORD)UnixSystemTime->tm_sec; + lpSystemTime->wMinute = (WORD)UnixSystemTime->tm_min; + lpSystemTime->wHour = (WORD)UnixSystemTime->tm_hour; return TRUE; } else diff --git a/src/coreclr/pal/src/locale/utf8.cpp b/src/coreclr/pal/src/locale/utf8.cpp index 8ff3229fcbabad..c0cf19dba5d7f4 100644 --- a/src/coreclr/pal/src/locale/utf8.cpp +++ b/src/coreclr/pal/src/locale/utf8.cpp @@ -1075,7 +1075,7 @@ class UTF8Encoding DecoderReplacementFallback decoderReplacementFallback; DecoderExceptionFallback decoderExceptionFallback; - bool InRange(WCHAR c, WCHAR begin, WCHAR end) + bool InRange(int c, int begin, int end) { return begin <= c && c <= end; } diff --git a/src/coreclr/pal/src/misc/time.cpp b/src/coreclr/pal/src/misc/time.cpp index ec71e5c72b06cf..7d78ae930c3979 100644 --- a/src/coreclr/pal/src/misc/time.cpp +++ b/src/coreclr/pal/src/misc/time.cpp @@ -82,13 +82,13 @@ GetSystemTime( goto EXIT; } - lpSystemTime->wYear = 1900 + utPtr->tm_year; - lpSystemTime->wMonth = utPtr->tm_mon + 1; - lpSystemTime->wDayOfWeek = utPtr->tm_wday; - lpSystemTime->wDay = utPtr->tm_mday; - lpSystemTime->wHour = utPtr->tm_hour; - lpSystemTime->wMinute = utPtr->tm_min; - lpSystemTime->wSecond = utPtr->tm_sec; + lpSystemTime->wYear = (WORD)(1900 + utPtr->tm_year); + lpSystemTime->wMonth = (WORD)(utPtr->tm_mon + 1); + lpSystemTime->wDayOfWeek = (WORD)utPtr->tm_wday; + lpSystemTime->wDay = (WORD)utPtr->tm_mday; + lpSystemTime->wHour = (WORD)utPtr->tm_hour; + lpSystemTime->wMinute = (WORD)utPtr->tm_min; + lpSystemTime->wSecond = (WORD)utPtr->tm_sec; if(-1 == timeofday_retval) { @@ -101,7 +101,7 @@ GetSystemTime( int old_seconds; int new_seconds; - lpSystemTime->wMilliseconds = timeval.tv_usec/tccMillieSecondsToMicroSeconds; + lpSystemTime->wMilliseconds = (WORD)(timeval.tv_usec/tccMillieSecondsToMicroSeconds); old_seconds = utPtr->tm_sec; new_seconds = timeval.tv_sec%60; diff --git a/src/coreclr/pal/src/safecrt/input.inl b/src/coreclr/pal/src/safecrt/input.inl index 3f415d695833ae..e68dc42f01614c 100644 --- a/src/coreclr/pal/src/safecrt/input.inl +++ b/src/coreclr/pal/src/safecrt/input.inl @@ -665,7 +665,7 @@ scanit: } else #else /* _UNICODE */ if (fl_wchar_arg) { - *(char16_t UNALIGNED *)pointer = ch; + *(char16_t UNALIGNED *)pointer = (char16_t)ch; pointer = (char16_t *)pointer + 1; #ifdef _SECURE_SCANF --array_width; @@ -867,7 +867,7 @@ getnum: if (_ISXDIGIT(ch)) { num64 <<= 4; - ch = _hextodec(ch); + ch = _hextodec((_TCHAR)ch); } else ++done_flag; @@ -910,7 +910,7 @@ getnum: if (_ISXDIGIT(ch)) { number = (number << 4); - ch = _hextodec(ch); + ch = _hextodec((_TCHAR)ch); } else ++done_flag; @@ -1262,7 +1262,7 @@ static int __cdecl _inc(miniFILE* fileptr) static void __cdecl _un_inc(int chr, miniFILE* fileptr) { if (_TEOF != chr) { - _ungettc_nolock(chr,fileptr); + _ungettc_nolock((char)chr,fileptr); } } diff --git a/src/coreclr/pal/src/safecrt/wcslwr_s.cpp b/src/coreclr/pal/src/safecrt/wcslwr_s.cpp index f80ff7bcf344a3..184776f21ee95f 100644 --- a/src/coreclr/pal/src/safecrt/wcslwr_s.cpp +++ b/src/coreclr/pal/src/safecrt/wcslwr_s.cpp @@ -30,7 +30,7 @@ DLLEXPORT errno_t __cdecl _wcslwr_s(char16_t *string, size_t sz) for (int i = 0; string[i] != 0; i++) { - string[i] = towlower(string[i]); + string[i] = (char16_t)towlower(string[i]); } _FILL_STRING(string, sz, length + 1); diff --git a/src/coreclr/utilcode/clrconfig.cpp b/src/coreclr/utilcode/clrconfig.cpp index caad3b594a6eaf..aaa33a6e4b03f2 100644 --- a/src/coreclr/utilcode/clrconfig.cpp +++ b/src/coreclr/utilcode/clrconfig.cpp @@ -634,8 +634,8 @@ void CLRConfig::Initialize() if (CLRConfig::GetConfigValue(CLRConfig::EXTERNAL_DisableConfigCache) != 0) return; - const WCHAR prefixC = towlower(COMPLUS_PREFIX[0]); - const WCHAR prefixD = towlower(DOTNET_PREFIX[0]); + const WCHAR prefixC = (WCHAR)towlower(COMPLUS_PREFIX[0]); + const WCHAR prefixD = (WCHAR)towlower(DOTNET_PREFIX[0]); // Create a cache of environment variables WCHAR* wszStrings = GetEnvironmentStringsW(); @@ -645,7 +645,7 @@ void CLRConfig::Initialize() // null terminated strings for(WCHAR *wszCurr = wszStrings; *wszCurr; wszCurr++) { - WCHAR wch = towlower(*wszCurr); + WCHAR wch = (WCHAR)towlower(*wszCurr); // Lets only cache env variables with targeted prefixes bool matchC = wch == prefixC; diff --git a/src/mono/CMakeLists.txt b/src/mono/CMakeLists.txt index bc3bc96caa1bef..50d04c9c1f06a6 100644 --- a/src/mono/CMakeLists.txt +++ b/src/mono/CMakeLists.txt @@ -502,13 +502,13 @@ if(GCC) set(WARNINGS "-Wall -Wunused -Wmissing-declarations -Wpointer-arith -Wno-cast-qual -Wwrite-strings -Wno-switch -Wno-switch-enum -Wno-unused-value -Wno-attributes -Wno-format-zero-length -Wno-unused-function") set(WARNINGS_C "-Wmissing-prototypes -Wstrict-prototypes -Wnested-externs") + set(WERROR "-Werror=return-type") + set(WERROR_C "-Werror=implicit-function-declaration") + if (CMAKE_C_COMPILER_ID MATCHES "Clang") set(WARNINGS "${WARNINGS} -Qunused-arguments -Wno-tautological-compare -Wno-parentheses-equality -Wno-self-assign -Wno-return-stack-address -Wno-constant-logical-operand -Wno-zero-length-array -Wno-asm-operand-widths") endif() - set(WERROR "-Werror=return-type") - set(WERROR_C "-Werror=implicit-function-declaration") - check_c_compiler_flag("-Werror=incompatible-pointer-types" WERROR_INCOMPATIBLE_POINTER_TYPES) if(WERROR_INCOMPATIBLE_POINTER_TYPES) set(WERROR_C "${WERROR_C} -Werror=incompatible-pointer-types") diff --git a/src/mono/cmake/config.h.in b/src/mono/cmake/config.h.in index b13b884f01c634..c6a79cdc0cfbf1 100644 --- a/src/mono/cmake/config.h.in +++ b/src/mono/cmake/config.h.in @@ -10,7 +10,6 @@ #pragma warning(disable:4152) // W4: nonstandard extension, function/data pointer conversion in expression #pragma warning(disable:4201) // W4: nonstandard extension used: nameless struct/union #pragma warning(disable:4210) // W4: nonstandard extension used: function given file scope -#pragma warning(disable:4244) // W2: integer conversion, possible loss of data #pragma warning(disable:4245) // W4: signed/unsigned mismatch #pragma warning(disable:4389) // W4: signed/unsigned mismatch #pragma warning(disable:4505) // W4: unreferenced function with internal linkage has been removed diff --git a/src/mono/mono/component/debugger-agent.c b/src/mono/mono/component/debugger-agent.c index 20518cf8a872c0..79c548cc9b85e6 100644 --- a/src/mono/mono/component/debugger-agent.c +++ b/src/mono/mono/component/debugger-agent.c @@ -3561,7 +3561,7 @@ process_event (EventKind event, gpointer arg, gint32 il_offset, MonoContext *ctx buffer_add_int (&buf, nevents); for (l = events; l; l = l->next) { - buffer_add_byte (&buf, event); // event kind + buffer_add_byte (&buf, GINT_TO_UINT8 (event)); // event kind buffer_add_int (&buf, GPOINTER_TO_INT (l->data)); // request id ecount ++; @@ -3635,7 +3635,7 @@ process_event (EventKind event, gpointer arg, gint32 il_offset, MonoContext *ctx EventInfo *ei = (EventInfo *)arg; buffer_add_objid (&buf, ei->exc); #ifdef TARGET_WASM - buffer_add_byte (&buf, ei->caught); + buffer_add_byte (&buf, GINT_TO_UINT8 (ei->caught)); #endif /* * We are not yet suspending, so get_objref () will not keep this object alive. So we need to do it @@ -7250,7 +7250,7 @@ event_commands (int command, guint8 *p, guint8 *end, Buffer *buf) if (!isBPOnManagedCode) { mono_de_cancel_all_ss (); } - buffer_add_byte (buf, isBPOnManagedCode); + buffer_add_byte (buf, GINT_TO_UINT8 (isBPOnManagedCode)); #endif } else if (req->event_kind == EVENT_KIND_METHOD_ENTRY) { req->info = mono_de_set_breakpoint (NULL, METHOD_ENTRY_IL_OFFSET, req, NULL); diff --git a/src/mono/mono/component/mini-wasm-debugger.c b/src/mono/mono/component/mini-wasm-debugger.c index e6e76f9e774d36..f719b1806d1159 100644 --- a/src/mono/mono/component/mini-wasm-debugger.c +++ b/src/mono/mono/component/mini-wasm-debugger.c @@ -232,7 +232,7 @@ write_value_to_buffer (MdbgProtBuffer *buf, MonoTypeEnum type, const char* varia char* endptr = NULL; const char *variableValueEnd = variableValue + strlen(variableValue); errno = 0; - buffer_add_byte (buf, type); + buffer_add_byte (buf, GINT_TO_UINT8 (type)); switch (type) { case MONO_TYPE_BOOLEAN: if (!strcasecmp (variableValue, "True")) diff --git a/src/mono/mono/eglib/gdir-unix.c b/src/mono/mono/eglib/gdir-unix.c index 10b15e7bc24e42..2ce5569c4be09e 100644 --- a/src/mono/mono/eglib/gdir-unix.c +++ b/src/mono/mono/eglib/gdir-unix.c @@ -126,7 +126,7 @@ g_mkdir_with_parents (const gchar *pathname, int mode) if (*d == '/' || *d == '\0') { char orig = *d; *d = '\0'; - rv = mkdir (path, mode); + rv = mkdir (path, (mode_t)mode); if (rv == -1 && errno != EEXIST) { g_free (path); return -1; diff --git a/src/mono/mono/eglib/giconv.c b/src/mono/mono/eglib/giconv.c index c944c8ecfb3586..f7ca5c3e3b8d29 100644 --- a/src/mono/mono/eglib/giconv.c +++ b/src/mono/mono/eglib/giconv.c @@ -158,8 +158,8 @@ static FORCE_INLINE (uint16_t) read_uint16_endian (unsigned char *inptr, unsigned endian) { if (endian == G_LITTLE_ENDIAN) - return (inptr[1] << 8) | inptr[0]; - return (inptr[0] << 8) | inptr[1]; + return (uint16_t)((inptr[1] << 8) | inptr[0]); + return (uint16_t)((inptr[0] << 8) | inptr[1]); } static FORCE_INLINE (int) diff --git a/src/mono/mono/eventpipe/ep-rt-mono.c b/src/mono/mono/eventpipe/ep-rt-mono.c index 57ae4f37e9a8c1..ff7b69ab4ea305 100644 --- a/src/mono/mono/eventpipe/ep-rt-mono.c +++ b/src/mono/mono/eventpipe/ep-rt-mono.c @@ -2511,7 +2511,7 @@ ep_rt_mono_system_time_get (EventPipeSystemTime *system_time) int old_seconds; int new_seconds; - milliseconds = time_val.tv_usec / MSECS_TO_MIS; + milliseconds = (uint16_t)(time_val.tv_usec / MSECS_TO_MIS); old_seconds = ut_ptr->tm_sec; new_seconds = time_val.tv_sec % 60; @@ -2523,13 +2523,13 @@ ep_rt_mono_system_time_get (EventPipeSystemTime *system_time) ep_system_time_set ( system_time, - 1900 + ut_ptr->tm_year, - ut_ptr->tm_mon + 1, - ut_ptr->tm_wday, - ut_ptr->tm_mday, - ut_ptr->tm_hour, - ut_ptr->tm_min, - ut_ptr->tm_sec, + (uint16_t)(1900 + ut_ptr->tm_year), + (uint16_t)ut_ptr->tm_mon + 1, + (uint16_t)ut_ptr->tm_wday, + (uint16_t)ut_ptr->tm_mday, + (uint16_t)ut_ptr->tm_hour, + (uint16_t)ut_ptr->tm_min, + (uint16_t)ut_ptr->tm_sec, milliseconds); } @@ -2609,7 +2609,7 @@ void ep_rt_mono_provider_config_init (EventPipeProviderConfiguration *provider_config) { if (!ep_rt_utf8_string_compare (ep_config_get_rundown_provider_name_utf8 (), ep_provider_config_get_provider_name (provider_config))) { - MICROSOFT_WINDOWS_DOTNETRUNTIME_RUNDOWN_PROVIDER_EVENTPIPE_Context.Level = ep_provider_config_get_logging_level (provider_config); + MICROSOFT_WINDOWS_DOTNETRUNTIME_RUNDOWN_PROVIDER_EVENTPIPE_Context.Level = (uint8_t)ep_provider_config_get_logging_level (provider_config); MICROSOFT_WINDOWS_DOTNETRUNTIME_RUNDOWN_PROVIDER_EVENTPIPE_Context.EnabledKeywordsBitmask = ep_provider_config_get_keywords (provider_config); MICROSOFT_WINDOWS_DOTNETRUNTIME_RUNDOWN_PROVIDER_EVENTPIPE_Context.IsEnabled = true; } @@ -3274,7 +3274,7 @@ ep_rt_mono_log_single_type ( // NOTE: If name is actively used, set it to NULL and relevant memory management to reduce byte count // This type is apparently so huge, it's too big to squeeze into an event, even // if it were the only type batched in the whole event. Bail - mono_trace (G_LOG_LEVEL_ERROR, MONO_TRACE_DIAGNOSTICS, "Failed to log single mono type %p with typeID %llu. Type is too large for the BulkType Event.\n", (gpointer)mono_type, val->fixed_sized_data.type_id); + mono_trace (G_LOG_LEVEL_ERROR, MONO_TRACE_DIAGNOSTICS, "Failed to log single mono type %p with typeID %llu. Type is too large for the BulkType Event.\n", (gpointer)mono_type, (unsigned long long)val->fixed_sized_data.type_id); return -1; } diff --git a/src/mono/mono/metadata/icall-eventpipe.c b/src/mono/mono/metadata/icall-eventpipe.c index f7ee2635e2a1d0..4d1604a808a340 100644 --- a/src/mono/mono/metadata/icall-eventpipe.c +++ b/src/mono/mono/metadata/icall-eventpipe.c @@ -212,7 +212,7 @@ ves_icall_System_Diagnostics_Tracing_EventPipeInternal_GetSessionInfo ( MonoBoolean ves_icall_System_Diagnostics_Tracing_EventPipeInternal_SignalSession (uint64_t session_id) { - return (intptr_t) mono_component_event_pipe()->signal_session ((EventPipeSessionID)session_id); + return mono_component_event_pipe()->signal_session ((EventPipeSessionID)session_id) ? TRUE : FALSE; } MonoBoolean @@ -220,7 +220,7 @@ ves_icall_System_Diagnostics_Tracing_EventPipeInternal_WaitForSessionSignal ( uint64_t session_id, int32_t timeout) { - return (intptr_t) mono_component_event_pipe()->wait_for_session_signal ((EventPipeSessionID)session_id, (uint32_t)timeout); + return mono_component_event_pipe()->wait_for_session_signal ((EventPipeSessionID)session_id, (uint32_t)timeout) ? TRUE : FALSE; } void diff --git a/src/mono/mono/mini/aot-compiler.c b/src/mono/mono/mini/aot-compiler.c index fe7d130eeb687e..ed61df17d817bd 100644 --- a/src/mono/mono/mini/aot-compiler.c +++ b/src/mono/mono/mini/aot-compiler.c @@ -3026,7 +3026,7 @@ encode_value (gint32 value, guint8 *buf, guint8 **endbuf) p [1] = value & 0xff; p += 2; } else if ((value >= 0) && (value <= 0x1fffffff)) { - p [0] = (value >> 24) | 0xc0; + p [0] = GINT32_TO_UINT8 ((value >> 24) | 0xc0); p [1] = (value >> 16) & 0xff; p [2] = (value >> 8) & 0xff; p [3] = value & 0xff; diff --git a/src/mono/mono/mini/cfgdump.c b/src/mono/mono/mini/cfgdump.c index bf97eeeac6f5ce..64e0377f45caa8 100644 --- a/src/mono/mono/mini/cfgdump.c +++ b/src/mono/mono/mini/cfgdump.c @@ -56,7 +56,7 @@ create_socket (const char *hostname, const int port) } serv_addr.sin_family = AF_INET; - serv_addr.sin_port = htons (port); + serv_addr.sin_port = htons (GINT_TO_UINT16 (port)); serv_addr.sin_addr.s_addr = inet_addr (hostname); if (connect (sockfd, (struct sockaddr *)&serv_addr, sizeof(serv_addr)) < 0) { @@ -175,7 +175,7 @@ add_pool_entry (MonoCompile *cfg, ConstantPoolEntry *entry) write_short (cfg, NUM_SUCCESSOR); for (int i = 0; i < NUM_SUCCESSOR; i++) { char *str = g_strdup ("successor1"); - str[9] = '0' + i; + str[9] = '0' + GINT_TO_CHAR (i); write_byte (cfg, 0); write_pool (cfg, create_cp_entry (cfg, (void *) str, PT_STRING)); } diff --git a/src/mono/mono/mini/debug-mini.c b/src/mono/mono/mini/debug-mini.c index bc289a0d99f046..ab20bc258ac1e5 100644 --- a/src/mono/mono/mini/debug-mini.c +++ b/src/mono/mono/mini/debug-mini.c @@ -370,7 +370,7 @@ encode_value (gint32 value, guint8 *buf, guint8 **endbuf) p [1] = value & 0xff; p += 2; } else if ((value >= 0) && (value <= 0x1fffffff)) { - p [0] = (value >> 24) | 0xc0; + p [0] = GINT32_TO_UINT8 ((value >> 24) | 0xc0); p [1] = (value >> 16) & 0xff; p [2] = (value >> 8) & 0xff; p [3] = value & 0xff; diff --git a/src/mono/mono/mini/dwarfwriter.c b/src/mono/mono/mini/dwarfwriter.c index fa7671544853c3..8ab1dfcb3eb72c 100644 --- a/src/mono/mono/mini/dwarfwriter.c +++ b/src/mono/mono/mini/dwarfwriter.c @@ -1290,7 +1290,7 @@ emit_loclist (MonoDwarfWriter *w, MonoInst *ins, emit_pointer_value (w, loclist_begin_addr); emit_pointer_value (w, loclist_end_addr); - emit_byte (w, expr_len % 256); + emit_byte (w, GUINT32_TO_UINT8 (expr_len % 256)); emit_byte (w, GUINT32_TO_UINT8 (expr_len / 256)); emit_bytes (w, expr, expr_len); diff --git a/src/mono/mono/mini/interp/transform.c b/src/mono/mono/mini/interp/transform.c index 5b5e110d6b7a93..10e00ec6ebb6d2 100644 --- a/src/mono/mono/mini/interp/transform.c +++ b/src/mono/mono/mini/interp/transform.c @@ -2839,7 +2839,7 @@ interp_inline_newobj (TransformData *td, MonoMethod *target_method, MonoMethodSi newobj_fast = interp_add_ins (td, MINT_NEWOBJ_VT_INLINED); interp_ins_set_dreg (newobj_fast, this_reg); interp_ins_set_sreg (newobj_fast, dreg); - newobj_fast->data [0] = ALIGN_TO (vtsize, MINT_STACK_SLOT_SIZE); + newobj_fast->data [0] = GUINTPTR_TO_UINT16 (ALIGN_TO (vtsize, MINT_STACK_SLOT_SIZE)); } else { MonoVTable *vtable = mono_class_vtable_checked (klass, error); goto_if_nok (error, fail); @@ -5638,7 +5638,7 @@ generate_code (TransformData *td, MonoMethod *method, MonoMethodHeader *header, if (is_vt) { newobj_fast = interp_add_ins (td, MINT_NEWOBJ_VT); interp_ins_set_dreg (newobj_fast, dreg); - newobj_fast->data [1] = ALIGN_TO (vtsize, MINT_STACK_SLOT_SIZE); + newobj_fast->data [1] = GUINTPTR_TO_UINT16 (ALIGN_TO (vtsize, MINT_STACK_SLOT_SIZE)); } else { MonoVTable *vtable = mono_class_vtable_checked (klass, error); goto_if_nok (error, exit); diff --git a/src/mono/mono/mini/mini-amd64.c b/src/mono/mono/mini/mini-amd64.c index ec63bcaf79bdf8..018f8a2c90281e 100644 --- a/src/mono/mono/mini/mini-amd64.c +++ b/src/mono/mono/mini/mini-amd64.c @@ -233,7 +233,7 @@ add_general (guint32 *gr, guint32 *stack_size, ArgInfo *ainfo) (*stack_size) += sizeof (target_mgreg_t); } else { ainfo->storage = ArgInIReg; - ainfo->reg = param_regs [*gr]; + ainfo->reg = GINT32_TO_UINT8 (param_regs [*gr]); (*gr) ++; } } @@ -676,7 +676,7 @@ add_valuetype (MonoMethodSignature *sig, ArgInfo *ainfo, MonoType *type, if (pass_on_stack) { /* Allways pass in memory */ - ainfo->offset = *stack_size; + ainfo->offset = GINT32_TO_INT16 (*stack_size); *stack_size += ALIGN_TO (size, 8); ainfo->storage = is_return ? ArgValuetypeAddrInIReg : ArgOnStack; if (!is_return) @@ -718,7 +718,7 @@ add_valuetype (MonoMethodSignature *sig, ArgInfo *ainfo, MonoType *type, } if (struct_size > 16) { - ainfo->offset = *stack_size; + ainfo->offset = GINT32_TO_INT16 (*stack_size); *stack_size += ALIGN_TO (struct_size, 8); ainfo->storage = is_return ? ArgValuetypeAddrInIReg : ArgOnStack; if (!is_return) @@ -793,9 +793,9 @@ add_valuetype (MonoMethodSignature *sig, ArgInfo *ainfo, MonoType *type, else { ainfo->pair_storage [quad] = ArgInIReg; if (is_return) - ainfo->pair_regs [quad] = return_regs [*gr]; + ainfo->pair_regs [quad] = GINT32_TO_UINT8 (return_regs [*gr]); else - ainfo->pair_regs [quad] = param_regs [*gr]; + ainfo->pair_regs [quad] = GINT32_TO_UINT8 (param_regs [*gr]); (*gr) ++; } break; @@ -805,8 +805,9 @@ add_valuetype (MonoMethodSignature *sig, ArgInfo *ainfo, MonoType *type, else { if (quadsize[quad] <= 4) ainfo->pair_storage [quad] = ArgInFloatSSEReg; - else ainfo->pair_storage [quad] = ArgInDoubleSSEReg; - ainfo->pair_regs [quad] = *fr; + else + ainfo->pair_storage [quad] = ArgInDoubleSSEReg; + ainfo->pair_regs [quad] = GINT32_TO_UINT8 (*fr); (*fr) ++; } break; @@ -825,7 +826,7 @@ add_valuetype (MonoMethodSignature *sig, ArgInfo *ainfo, MonoType *type, *gr = orig_gr; *fr = orig_fr; - ainfo->offset = *stack_size; + ainfo->offset = GINT32_TO_UINT16 (*stack_size); if (sig->pinvoke) arg_size = ALIGN_TO (struct_size, 8); else diff --git a/src/mono/mono/mini/mini-arm.c b/src/mono/mono/mini/mini-arm.c index fa1200e51ddbb4..31f580c500d033 100644 --- a/src/mono/mono/mini/mini-arm.c +++ b/src/mono/mono/mini/mini-arm.c @@ -598,14 +598,14 @@ mono_arch_get_argument_info (MonoMethodSignature *csig, int param_count, MonoJit offset += 4; } - arg_info [0].offset = offset; + arg_info [0].offset = GINT32_TO_UINT16 (offset); if (csig->hasthis) { frame_size += sizeof (target_mgreg_t); offset += 4; } - arg_info [0].size = frame_size; + arg_info [0].size = GINT32_TO_UINT16 (frame_size); for (k = 0; k < param_count; k++) { size = mini_type_stack_size_full (csig->params [k], &align, csig->pinvoke && !csig->marshalling_disabled); @@ -614,18 +614,18 @@ mono_arch_get_argument_info (MonoMethodSignature *csig, int param_count, MonoJit align = 1; frame_size += pad = (align - (frame_size & (align - 1))) & (align - 1); - arg_info [k].pad = pad; + arg_info [k].pad = GUINT32_TO_UINT8 (pad); frame_size += size; arg_info [k + 1].pad = 0; - arg_info [k + 1].size = size; + arg_info [k + 1].size = GINT32_TO_UINT16 (size); offset += pad; - arg_info [k + 1].offset = offset; + arg_info [k + 1].offset = GINT32_TO_UINT16 (offset); offset += size; } align = MONO_ARCH_FRAME_ALIGNMENT; frame_size += pad = (align - (frame_size & (align - 1))) & (align - 1); - arg_info [k].pad = pad; + arg_info [k].pad = GUINT32_TO_UINT8 (pad); return frame_size; } @@ -1083,7 +1083,7 @@ add_general (guint *gr, guint *stack_size, ArgInfo *ainfo, gboolean simple) *stack_size += 4; } else { ainfo->storage = RegTypeGeneral; - ainfo->reg = *gr; + ainfo->reg = GUINT32_TO_UINT8 (*gr); } } else { gboolean split; @@ -1118,7 +1118,7 @@ add_general (guint *gr, guint *stack_size, ArgInfo *ainfo, gboolean simple) (*gr) ++; } ainfo->storage = RegTypeIRegPair; - ainfo->reg = *gr; + ainfo->reg = GUINT32_TO_UINT8 (*gr); } (*gr) ++; } @@ -1170,7 +1170,7 @@ add_float (guint *fpr, guint *stack_size, ArgInfo *ainfo, gboolean is_double, gi * At this point, we have an even register * so we assign that and move along. */ - ainfo->reg = *fpr; + ainfo->reg = GUINT32_TO_UINT8 (*fpr); *fpr += 2; } else if (*float_spare >= 0) { /* @@ -1180,7 +1180,7 @@ add_float (guint *fpr, guint *stack_size, ArgInfo *ainfo, gboolean is_double, gi * use it. */ - ainfo->reg = *float_spare; + ainfo->reg = GINT32_TO_UINT8 (*float_spare); *float_spare = -1; } else { /* @@ -1189,7 +1189,7 @@ add_float (guint *fpr, guint *stack_size, ArgInfo *ainfo, gboolean is_double, gi * use the next available register. */ - ainfo->reg = *fpr; + ainfo->reg = GUINT32_TO_UINT8 (*fpr); (*fpr)++; } } else { @@ -1387,7 +1387,7 @@ get_call_info (MonoMemPool *mp, MonoMethodSignature *sig) pstart = 1; } n ++; - cinfo->ret.reg = gr; + cinfo->ret.reg = GUINT32_TO_UINT8 (gr); gr ++; cinfo->vret_arg_index = 1; } else { @@ -1397,7 +1397,7 @@ get_call_info (MonoMemPool *mp, MonoMethodSignature *sig) n ++; } if (vtype_retaddr) { - cinfo->ret.reg = gr; + cinfo->ret.reg = GUINT32_TO_UINT8 (gr); gr ++; } } @@ -1480,7 +1480,7 @@ get_call_info (MonoMemPool *mp, MonoMethodSignature *sig) if (IS_HARD_FLOAT && sig->pinvoke && is_hfa (t, &nfields, &esize)) { if (fpr + nfields < ARM_VFP_F16) { ainfo->storage = RegTypeHFA; - ainfo->reg = fpr; + ainfo->reg = GUINT32_TO_UINT8 (fpr); ainfo->nregs = nfields; ainfo->esize = esize; if (esize == 4) @@ -1540,14 +1540,14 @@ get_call_info (MonoMemPool *mp, MonoMethodSignature *sig) } if (gr > ARMREG_R3) { ainfo->size = 0; - ainfo->vtsize = nwords; + ainfo->vtsize = GINT32_TO_UINT16 (nwords); } else { int rest = ARMREG_R3 - gr + 1; int n_in_regs = rest >= nwords? nwords: rest; - ainfo->size = n_in_regs; - ainfo->vtsize = nwords - n_in_regs; - ainfo->reg = gr; + ainfo->size = GINT32_TO_UINT8 (n_in_regs); + ainfo->vtsize = GINT32_TO_UINT16 (nwords - n_in_regs); + ainfo->reg = GUINT32_TO_UINT8 (gr); gr += n_in_regs; nwords -= n_in_regs; } @@ -3100,16 +3100,16 @@ mono_arch_finish_dyn_call (MonoDynCallInfo *info, guint8 *buf) *(gpointer*)ret = (gpointer)(gsize)res; break; case MONO_TYPE_I1: - *(gint8*)ret = res; + *(gint8*)ret = GINT32_TO_INT8 (res); break; case MONO_TYPE_U1: - *(guint8*)ret = res; + *(guint8*)ret = GINT32_TO_UINT8 (res); break; case MONO_TYPE_I2: - *(gint16*)ret = res; + *(gint16*)ret = GINT32_TO_INT16 (res); break; case MONO_TYPE_U2: - *(guint16*)ret = res; + *(guint16*)ret = GINT32_TO_UINT16 (res); break; case MONO_TYPE_I4: *(gint32*)ret = res; @@ -3449,7 +3449,7 @@ mono_arch_lowering_pass (MonoCompile *cfg, MonoBasicBlock *bb) ins->sreg2 = temp->dreg; if (opcode2 == -1) g_error ("mono_op_imm_to_op failed for %s\n", mono_inst_name (ins->opcode)); - ins->opcode = opcode2; + ins->opcode = GUINT32_TO_OPCODE (opcode2); } if (ins->opcode == OP_SBB || ins->opcode == OP_ISBB || ins->opcode == OP_SUBCC) goto loop_start; @@ -3507,7 +3507,7 @@ mono_arch_lowering_pass (MonoCompile *cfg, MonoBasicBlock *bb) ins->sreg2 = temp->dreg; if (opcode2 == -1) g_error ("mono_op_imm_to_op failed for %s\n", mono_inst_name (ins->opcode)); - ins->opcode = opcode2; + ins->opcode = GINT32_TO_UINT16 (opcode2); break; } case OP_LOCALLOC_IMM: @@ -3532,7 +3532,7 @@ mono_arch_lowering_pass (MonoCompile *cfg, MonoBasicBlock *bb) temp->inst_c0 = ins->inst_offset; temp->dreg = mono_alloc_ireg (cfg); ins->sreg2 = temp->dreg; - ins->opcode = map_to_reg_reg_op (ins->opcode); + ins->opcode = GINT32_TO_UINT16 (map_to_reg_reg_op (ins->opcode)); break; case OP_LOADI2_MEMBASE: case OP_LOADU2_MEMBASE: @@ -3543,7 +3543,7 @@ mono_arch_lowering_pass (MonoCompile *cfg, MonoBasicBlock *bb) temp->inst_c0 = ins->inst_offset; temp->dreg = mono_alloc_ireg (cfg); ins->sreg2 = temp->dreg; - ins->opcode = map_to_reg_reg_op (ins->opcode); + ins->opcode = GINT32_TO_UINT16 (map_to_reg_reg_op (ins->opcode)); break; case OP_LOADR4_MEMBASE: case OP_LOADR8_MEMBASE: @@ -3582,7 +3582,7 @@ mono_arch_lowering_pass (MonoCompile *cfg, MonoBasicBlock *bb) temp->inst_c0 = ins->inst_offset; temp->dreg = mono_alloc_ireg (cfg); ins->sreg2 = temp->dreg; - ins->opcode = map_to_reg_reg_op (ins->opcode); + ins->opcode = GINT32_TO_UINT16 (map_to_reg_reg_op (ins->opcode)); break; case OP_STOREI2_MEMBASE_REG: if (arm_is_imm8 (ins->inst_offset)) @@ -3591,7 +3591,7 @@ mono_arch_lowering_pass (MonoCompile *cfg, MonoBasicBlock *bb) temp->inst_c0 = ins->inst_offset; temp->dreg = mono_alloc_ireg (cfg); ins->sreg2 = temp->dreg; - ins->opcode = map_to_reg_reg_op (ins->opcode); + ins->opcode = GINT32_TO_UINT16 (map_to_reg_reg_op (ins->opcode)); break; case OP_STORER4_MEMBASE_REG: case OP_STORER8_MEMBASE_REG: @@ -3629,7 +3629,7 @@ mono_arch_lowering_pass (MonoCompile *cfg, MonoBasicBlock *bb) temp->inst_c0 = ins->inst_imm; temp->dreg = mono_alloc_ireg (cfg); ins->sreg1 = temp->dreg; - ins->opcode = map_to_reg_reg_op (ins->opcode); + ins->opcode = GINT32_TO_UINT16 (map_to_reg_reg_op (ins->opcode)); last_ins = temp; goto loop_start; /* make it handle the possibly big ins->inst_offset */ case OP_FCOMPARE: diff --git a/src/mono/mono/mini/mini-arm64.c b/src/mono/mono/mini/mini-arm64.c index 4d2125c82247ef..77f594d21ba567 100644 --- a/src/mono/mono/mini/mini-arm64.c +++ b/src/mono/mono/mini/mini-arm64.c @@ -1226,7 +1226,7 @@ add_valuetype (CallInfo *cinfo, ArgInfo *ainfo, MonoType *t) ainfo->size = size; ainfo->esize = esize; for (i = 0; i < nfields; ++i) - ainfo->foffsets [i] = field_offsets [i]; + ainfo->foffsets [i] = GINT_TO_UINT8 (field_offsets [i]); cinfo->fr += ainfo->nregs; } else { ainfo->nfregs_to_skip = FP_PARAM_REGS > cinfo->fr ? FP_PARAM_REGS - cinfo->fr : 0; @@ -1984,16 +1984,16 @@ mono_arch_finish_dyn_call (MonoDynCallInfo *info, guint8 *buf) *(gpointer*)ret = (gpointer)res; break; case MONO_TYPE_I1: - *(gint8*)ret = res; + *(gint8*)ret = GHMREG_TO_UINT8 (res); break; case MONO_TYPE_U1: - *(guint8*)ret = res; + *(guint8*)ret = GHMREG_TO_UINT8 (res); break; case MONO_TYPE_I2: - *(gint16*)ret = res; + *(gint16*)ret = GHMREG_TO_INT16 (res); break; case MONO_TYPE_U2: - *(guint16*)ret = res; + *(guint16*)ret = GHMREG_TO_UINT16 (res); break; case MONO_TYPE_I4: *(gint32*)ret = res; @@ -2931,7 +2931,7 @@ mono_arch_lowering_pass (MonoCompile *cfg, MonoBasicBlock *bb) temp->inst_c0 = ins->inst_imm; temp->dreg = mono_alloc_ireg (cfg); ins->sreg1 = temp->dreg; - ins->opcode = mono_op_imm_to_op (ins->opcode); + ins->opcode = GINT_TO_OPCODE (mono_op_imm_to_op (ins->opcode)); } break; case OP_ICOMPARE_IMM: @@ -5041,7 +5041,7 @@ emit_store_regset_cfa (MonoCompile *cfg, guint8 *code, guint64 regs, int basereg for (j = 0; j < nregs; ++j) { if (cfa_regset & (1 << (i + j))) - mono_emit_unwind_op_offset (cfg, code, i + j, (- cfa_offset) + offset + ((pos + j) * 8)); + mono_emit_unwind_op_offset (cfg, code, (i + j), (- cfa_offset) + offset + ((pos + j) * 8)); } i += nregs - 1; diff --git a/src/mono/mono/mini/mini-llvm.c b/src/mono/mono/mini/mini-llvm.c index 038167827031f4..1482fceb64d506 100644 --- a/src/mono/mono/mini/mini-llvm.c +++ b/src/mono/mono/mini/mini-llvm.c @@ -1983,13 +1983,13 @@ get_aotconst_name (MonoJumpInfoType type, gconstpointer data, int got_offset) name = g_strdup_printf ("%s", mono_ji_type_to_string (type)); len = strlen (name); for (size_t i = 0; i < len; ++i) - name [i] = tolower (name [i]); + name [i] = GINT_TO_CHAR (tolower (name [i])); break; default: name = g_strdup_printf ("%s_%d", mono_ji_type_to_string (type), got_offset); len = strlen (name); for (size_t i = 0; i < len; ++i) - name [i] = tolower (name [i]); + name [i] = GINT_TO_CHAR (tolower (name [i])); break; } @@ -12508,7 +12508,7 @@ add_intrinsic (LLVMModuleRef module, int id) for (int vw = 0; vw < INTRIN_vectorwidths; ++vw) { for (int ew = 0; ew < INTRIN_elementwidths; ++ew) { llvm_ovr_tag_t vec_bit = INTRIN_vector128 >> ((INTRIN_vectorwidths - 1) - vw); - llvm_ovr_tag_t elem_bit = INTRIN_int8 << ew; + llvm_ovr_tag_t elem_bit = GINT_TO_UINT16 (INTRIN_int8 << ew); llvm_ovr_tag_t test = vec_bit | elem_bit; if ((spec & test) == test) { uint8_t kind = intrin_kind [id]; diff --git a/src/mono/mono/mini/mini-unwind.h b/src/mono/mono/mini/mini-unwind.h index 3db2f45e9cb2b9..98e0db4e7fc4f8 100644 --- a/src/mono/mono/mini/mini-unwind.h +++ b/src/mono/mono/mini/mini-unwind.h @@ -98,13 +98,13 @@ typedef struct { /* Set cfa to reg+offset */ #define mono_emit_unwind_op_def_cfa(cfg,ip,reg,offset) do { mono_emit_unwind_op (cfg, (ip) - (cfg)->native_code, DW_CFA_def_cfa, (reg), (offset)); (cfg)->cur_cfa_reg = (reg); (cfg)->cur_cfa_offset = (offset); } while (0) /* Set cfa to reg+existing offset */ -#define mono_emit_unwind_op_def_cfa_reg(cfg,ip,reg) do { mono_emit_unwind_op (cfg, (ip) - (cfg)->native_code, DW_CFA_def_cfa_register, (reg), (0)); (cfg)->cur_cfa_reg = (reg); } while (0) +#define mono_emit_unwind_op_def_cfa_reg(cfg,ip,reg) do { mono_emit_unwind_op (cfg, (ip) - (cfg)->native_code, DW_CFA_def_cfa_register, (uint16_t)(reg), (0)); (cfg)->cur_cfa_reg = (reg); } while (0) /* Set cfa to existing reg+offset */ #define mono_emit_unwind_op_def_cfa_offset(cfg,ip,offset) do { mono_emit_unwind_op (cfg, (ip) - (cfg)->native_code, DW_CFA_def_cfa_offset, (0), (offset)); (cfg)->cur_cfa_offset = (offset); } while (0) /* Reg is the same as it was on enter to the function */ -#define mono_emit_unwind_op_same_value(cfg,ip,reg) mono_emit_unwind_op (cfg, (ip) - (cfg)->native_code, DW_CFA_same_value, (reg), 0) +#define mono_emit_unwind_op_same_value(cfg,ip,reg) mono_emit_unwind_op (cfg, (ip) - (cfg)->native_code, DW_CFA_same_value, (uint16_t)(reg), 0) /* Reg is saved at cfa+offset */ -#define mono_emit_unwind_op_offset(cfg,ip,reg,offset) mono_emit_unwind_op (cfg, (ip) - (cfg)->native_code, DW_CFA_offset, (reg), (offset)) +#define mono_emit_unwind_op_offset(cfg,ip,reg,offset) mono_emit_unwind_op (cfg, (ip) - (cfg)->native_code, DW_CFA_offset, (uint16_t)(reg), (offset)) /* Save the unwind state into an implicit stack */ #define mono_emit_unwind_op_remember_state(cfg,ip) mono_emit_unwind_op (cfg, (ip) - (cfg)->native_code, DW_CFA_remember_state, 0, 0) /* Restore the unwind state from the state stack */ @@ -125,15 +125,15 @@ typedef struct { #endif /* Similar macros usable when a cfg is not available, like for trampolines */ -#define mono_add_unwind_op_def_cfa(op_list,code,buf,reg,offset) do { (op_list) = g_slist_append ((op_list), mono_create_unwind_op ((code) - (buf), DW_CFA_def_cfa, (reg), (offset))); } while (0) -#define mono_add_unwind_op_def_cfa_reg(op_list,code,buf,reg) do { (op_list) = g_slist_append ((op_list), mono_create_unwind_op ((code) - (buf), DW_CFA_def_cfa_register, (reg), (0))); } while (0) +#define mono_add_unwind_op_def_cfa(op_list,code,buf,reg,offset) do { (op_list) = g_slist_append ((op_list), mono_create_unwind_op ((code) - (buf), DW_CFA_def_cfa, (uint16_t)(reg), (offset))); } while (0) +#define mono_add_unwind_op_def_cfa_reg(op_list,code,buf,reg) do { (op_list) = g_slist_append ((op_list), mono_create_unwind_op ((code) - (buf), DW_CFA_def_cfa_register, (uint16_t)(reg), (0))); } while (0) #define mono_add_unwind_op_def_cfa_offset(op_list,code,buf,offset) do { (op_list) = g_slist_append ((op_list), mono_create_unwind_op ((code) - (buf), DW_CFA_def_cfa_offset, 0, (offset))); } while (0) -#define mono_add_unwind_op_same_value(op_list,code,buf,reg) do { (op_list) = g_slist_append ((op_list), mono_create_unwind_op ((code) - (buf), DW_CFA_same_value, (reg), 0)); } while (0) -#define mono_add_unwind_op_offset(op_list,code,buf,reg,offset) do { (op_list) = g_slist_append ((op_list), mono_create_unwind_op ((code) - (buf), DW_CFA_offset, (reg), (offset))); } while (0) +#define mono_add_unwind_op_same_value(op_list,code,buf,reg) do { (op_list) = g_slist_append ((op_list), mono_create_unwind_op ((code) - (buf), DW_CFA_same_value, (uint16_t)(reg), 0)); } while (0) +#define mono_add_unwind_op_offset(op_list,code,buf,reg,offset) do { (op_list) = g_slist_append ((op_list), mono_create_unwind_op ((code) - (buf), DW_CFA_offset, (uint16_t)(reg), (offset))); } while (0) #if defined(TARGET_WIN32) && defined(TARGET_AMD64) #define mono_add_unwind_op_sp_alloc(op_list,code,buf,size) do { (op_list) = g_slist_append ((op_list), mono_create_unwind_op ((code) - (buf), DW_CFA_mono_sp_alloc_info_win64, 0, (size))); } while (0) -#define mono_add_unwind_op_fp_alloc(op_list,code,buf,reg,size) do { (op_list) = g_slist_append ((op_list), mono_create_unwind_op ((code) - (buf), DW_CFA_mono_fp_alloc_info_win64, (reg), (size))); } while (0) +#define mono_add_unwind_op_fp_alloc(op_list,code,buf,reg,size) do { (op_list) = g_slist_append ((op_list), mono_create_unwind_op ((code) - (buf), DW_CFA_mono_fp_alloc_info_win64, (uint16_t)(reg), (size))); } while (0) #else #define mono_add_unwind_op_sp_alloc(op_list,code,buf,size) #define mono_add_unwind_op_fp_alloc(op_list,code,buf,reg,size) diff --git a/src/mono/mono/mini/mini-x86.c b/src/mono/mono/mini/mini-x86.c index e3a9703888540c..567c759b22279d 100644 --- a/src/mono/mono/mini/mini-x86.c +++ b/src/mono/mono/mini/mini-x86.c @@ -281,10 +281,10 @@ add_valuetype (MonoMethodSignature *sig, ArgInfo *ainfo, MonoType *type, if ((info->native_size == 1) || (info->native_size == 2) || (info->native_size == 4) || (info->native_size == 8)) { ainfo->storage = ArgValuetypeInReg; ainfo->pair_storage [0] = ArgInIReg; - ainfo->pair_regs [0] = return_regs [0]; + ainfo->pair_regs [0] = GINT32_TO_UINT8 (return_regs [0]); if (info->native_size > 4) { ainfo->pair_storage [1] = ArgInIReg; - ainfo->pair_regs [1] = return_regs [1]; + ainfo->pair_regs [1] = GINT32_TO_UINT8 (return_regs [1]); } return; } diff --git a/src/mono/mono/profiler/aot.c b/src/mono/mono/profiler/aot.c index 278c3c05354c81..45bed109354cc3 100644 --- a/src/mono/mono/profiler/aot.c +++ b/src/mono/mono/profiler/aot.c @@ -454,7 +454,7 @@ emit_string (MonoProfiler *prof, const char *str) static void emit_record (MonoProfiler *prof, AotProfRecordType type, int id) { - emit_byte (prof, type); + emit_byte (prof, (guint8)type); emit_int32 (prof, id); } diff --git a/src/mono/mono/profiler/log.c b/src/mono/mono/profiler/log.c index a3e5de6ba37958..110253833a97bb 100644 --- a/src/mono/mono/profiler/log.c +++ b/src/mono/mono/profiler/log.c @@ -793,7 +793,7 @@ encode_sleb128 (intptr_t value, uint8_t *buf, uint8_t **endbuf) static void emit_byte (LogBuffer *logbuffer, int value) { - logbuffer->cursor [0] = value; + logbuffer->cursor [0] = GINT_TO_UINT8 (value); logbuffer->cursor++; g_assert (logbuffer->cursor <= logbuffer->buf_end && "Why are we writing past the buffer end?"); @@ -956,7 +956,7 @@ write_int16 (char *buf, int32_t value) { int i; for (i = 0; i < 2; ++i) { - buf [i] = value; + buf [i] = GINT32_TO_UINT8 (value); value >>= 8; } return buf + 2; @@ -967,7 +967,7 @@ write_int32 (char *buf, int32_t value) { int i; for (i = 0; i < 4; ++i) { - buf [i] = value; + buf [i] = GINT_TO_UINT8 (value); value >>= 8; } return buf + 4; @@ -978,7 +978,7 @@ write_int64 (char *buf, int64_t value) { int i; for (i = 0; i < 8; ++i) { - buf [i] = value; + buf [i] = GINT_TO_UINT8 (value); value >>= 8; } return buf + 8; @@ -3271,7 +3271,7 @@ proflog_icall_SetSampleMode (MonoProfilerSampleMode mode, gint32 frequency) mono_coop_mutex_unlock (&log_profiler.api_mutex); - return result; + return !!result; } ICALL_EXPORT MonoBoolean diff --git a/src/mono/mono/utils/mono-rand.c b/src/mono/mono/utils/mono-rand.c index 88b3fed1b3a4ef..cb78275d75677d 100644 --- a/src/mono/mono/utils/mono-rand.c +++ b/src/mono/mono/utils/mono-rand.c @@ -157,7 +157,7 @@ get_entropy_from_egd (const char *path, guchar *buffer, gssize buffer_size, Mono /* block until daemon can return enough entropy */ request [0] = 2; - request [1] = buffer_size < 255 ? buffer_size : 255; + request [1] = buffer_size < 255 ? (guchar)buffer_size : 255; while (count < 2) { int sent = write (socket_fd, request + count, 2 - count); err = errno; diff --git a/src/native/eventpipe/ds-ipc-pal-socket.c b/src/native/eventpipe/ds-ipc-pal-socket.c index 20e3f11c52383e..df42c024e81ad9 100644 --- a/src/native/eventpipe/ds-ipc-pal-socket.c +++ b/src/native/eventpipe/ds-ipc-pal-socket.c @@ -848,7 +848,7 @@ ipc_alloc_tcp_address ( const ep_char8_t *host_address = address; const ep_char8_t *host_port = strrchr (address, ':'); - + if (host_port && host_port != host_address) { size_t host_address_len = host_port - address; address [host_address_len] = 0; @@ -884,7 +884,7 @@ ipc_alloc_tcp_address ( if (!ipc->server_address && info->ai_family == AF_INET) { server_address = ep_rt_object_alloc (struct sockaddr_in); if (server_address) { - server_address->sin_family = info->ai_family; + server_address->sin_family = (uint8_t) info->ai_family; server_address->sin_port = htons (port); server_address->sin_addr = ((struct sockaddr_in*)info->ai_addr)->sin_addr; ipc->server_address = (ds_ipc_socket_address_t *)server_address; @@ -898,7 +898,7 @@ ipc_alloc_tcp_address ( if (!ipc->server_address && info->ai_family == AF_INET6) { server_address6 = ep_rt_object_alloc (struct sockaddr_in6); if (server_address6) { - server_address6->sin6_family = info->ai_family; + server_address6->sin6_family = (uint8_t) info->ai_family; server_address6->sin6_port = htons (port); server_address6->sin6_addr = ((struct sockaddr_in6*)info->ai_addr)->sin6_addr; ipc->server_address = (ds_ipc_socket_address_t *)server_address6; diff --git a/src/native/external/libunwind.cmake b/src/native/external/libunwind.cmake index 0d767ccccdbabe..c304fd1523b721 100644 --- a/src/native/external/libunwind.cmake +++ b/src/native/external/libunwind.cmake @@ -435,4 +435,8 @@ else(CLR_CMAKE_HOST_UNIX) ) endif(CLR_CMAKE_HOST_UNIX) +if(CMAKE_C_COMPILER_ID MATCHES "Clang") + add_compile_options($<$:-Wno-implicit-int-conversion>) +endif() + addprefix(LIBUNWIND_SOURCES "${CMAKE_CURRENT_LIST_DIR}/libunwind/src" "${LIBUNWIND_SOURCES_BASE}") diff --git a/src/native/external/zlib-intel.cmake b/src/native/external/zlib-intel.cmake index c8352de35f2fc7..a9d0be1fa4b059 100644 --- a/src/native/external/zlib-intel.cmake +++ b/src/native/external/zlib-intel.cmake @@ -1,6 +1,8 @@ if(MSVC) add_compile_options($<$:/wd4244>) # conversion from 'type1' to 'type2', possible loss of data -endif(MSVC) +else(CMAKE_C_COMPILER_ID MATCHES "Clang") + add_compile_options($<$:-Wno-implicit-int-conversion>) +endif() set(ZLIB_SOURCES_BASE adler32.c diff --git a/src/native/external/zlib.cmake b/src/native/external/zlib.cmake index ef8a1e1a635b22..80b5f7b1a54387 100644 --- a/src/native/external/zlib.cmake +++ b/src/native/external/zlib.cmake @@ -1,6 +1,8 @@ if(MSVC) add_compile_options($<$:/wd4244>) # conversion from 'type1' to 'type2', possible loss of data -endif(MSVC) +else(CMAKE_C_COMPILER_ID MATCHES "Clang") + add_compile_options($<$:-Wno-implicit-int-conversion>) +endif() set(ZLIB_SOURCES_BASE adler32.c