Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Fix issues enabling -Werror=implicit-int-conversion
  • Loading branch information
AaronRobinsonMSFT committed Jun 1, 2022
commit adcceba169090b4688e302a00e13d955c1d7cd10
1 change: 0 additions & 1 deletion src/mono/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -507,7 +507,6 @@ if(GCC)

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")
set(WERROR "${WERROR} -Werror=shorten-64-to-32")
endif()

check_c_compiler_flag("-Werror=incompatible-pointer-types" WERROR_INCOMPATIBLE_POINTER_TYPES)
Expand Down
2 changes: 1 addition & 1 deletion src/mono/mono/component/debugger-agent.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 ++;
Expand Down
2 changes: 1 addition & 1 deletion src/mono/mono/eglib/gdir-unix.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions src/mono/mono/eglib/giconv.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
18 changes: 9 additions & 9 deletions src/mono/mono/eventpipe/ep-rt-mono.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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);
}

Expand Down Expand Up @@ -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;
}
Expand Down
4 changes: 2 additions & 2 deletions src/mono/mono/metadata/icall-eventpipe.c
Original file line number Diff line number Diff line change
Expand Up @@ -212,15 +212,15 @@ 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 (MonoBoolean) mono_component_event_pipe()->signal_session ((EventPipeSessionID)session_id);
}

MonoBoolean
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 (MonoBoolean) mono_component_event_pipe()->wait_for_session_signal ((EventPipeSessionID)session_id, (uint32_t)timeout);
}

void
Expand Down
2 changes: 1 addition & 1 deletion src/mono/mono/mini/cfgdump.c
Original file line number Diff line number Diff line change
Expand Up @@ -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' + (char)i;
write_byte (cfg, 0);
write_pool (cfg, create_cp_entry (cfg, (void *) str, PT_STRING));
}
Expand Down
2 changes: 1 addition & 1 deletion src/mono/mono/mini/dwarfwriter.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
14 changes: 7 additions & 7 deletions src/mono/mono/mini/mini-arm64.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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 = (gint8)res;
break;
case MONO_TYPE_U1:
*(guint8*)ret = res;
*(guint8*)ret = (guint8)res;
break;
case MONO_TYPE_I2:
*(gint16*)ret = res;
*(gint16*)ret = (gint16)res;
break;
case MONO_TYPE_U2:
*(guint16*)ret = res;
*(guint16*)ret = (guint16)res;
break;
case MONO_TYPE_I4:
*(gint32*)ret = res;
Expand Down Expand Up @@ -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 = (guint16)mono_op_imm_to_op (ins->opcode);
}
break;
case OP_ICOMPARE_IMM:
Expand Down Expand Up @@ -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, (guint16)(i + j), (- cfa_offset) + offset + ((pos + j) * 8));
}

i += nregs - 1;
Expand Down
2 changes: 1 addition & 1 deletion src/mono/mono/profiler/aot.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down
2 changes: 1 addition & 1 deletion src/mono/mono/utils/mono-rand.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down