From: Thomas Huth Date: Sat, 1 Dec 2018 11:53:59 +0000 (+0100) Subject: Silence compiler warnings when compiling with GCC's -Wsign-compare X-Git-Tag: 4200~98^2~1 X-Git-Url: https://git.unchartedbackwaters.co.uk/w/?a=commitdiff_plain;h=7521d35c06808a598799b80909d0456c1dee4967;p=francis%2Fwinuae.git Silence compiler warnings when compiling with GCC's -Wsign-compare When compiling the CPU files with the -Wsign-compare compiler flag, there are a couple of harmless warnings, e.g.: cpummu030.c: In function 'm68k_do_rte_mmu030': cpummu030.c:2745:48: warning: operand of ?: changes signedness from 'int' to 'uae_u32' {aka 'unsigned int'} due to unsignedness of other operand [-Wsign-compare] uae_u32 mmu030_opcode_v = (ps & 0x80000000) ? -1 : (oc & 0xffff); ^~ cpummu030.c:2792:24: warning: comparison of integer expressions of different signedness: 'uae_u32' {aka 'unsigned int'} and 'int' [-Wsign-compare] if (mmu030_opcode_v == -1) { ^~ cpummu030.c: In function 'm68k_do_rte_mmu030c': cpummu030.c:3133:48: warning: operand of ?: changes signedness from 'int' to 'uae_u32' {aka 'unsigned int'} due to unsignedness of other operand [-Wsign-compare] uae_u32 mmu030_opcode_v = (ps & 0x80000000) ? -1 : (oc & 0xffff); ^~ cpummu030.c:3185:50: warning: operand of ?: changes signedness from 'int' to 'uae_u32' {aka 'unsigned int'} due to unsignedness of other operand [-Wsign-compare] regs.pipeline_stop = ((ps >> 20) & 15) == 15 ? -1 : (ps >> 20) & 15; ^~ fpp.c: In function 'fp_unimp_datatype': fpp.c:998:54: warning: operand of ?: changes signedness from 'int' to 'uae_u32' {aka 'unsigned int'} due to unsignedness of other operand [-Wsign-compare] fsave_data.stag = get_ftag(src, (opclass == 0) ? -1 : size); ^~ Let's make sure to use the correct signedness of the target variable to silence these warnings. --- diff --git a/cpummu30.cpp b/cpummu30.cpp index ebe50f6f..50c1dc39 100644 --- a/cpummu30.cpp +++ b/cpummu30.cpp @@ -2724,7 +2724,7 @@ void m68k_do_rte_mmu030 (uaecptr a7) // Data buffer uae_u32 mmu030_data_buffer_in_v = get_long_mmu030(a7 + 0x2c);; - uae_u32 mmu030_opcode_v = (ps & 0x80000000) ? -1 : (oc & 0xffff); + uae_u32 mmu030_opcode_v = (ps & 0x80000000) ? -1U : (oc & 0xffff); // Misc state data uae_u32 mmu030_state_0 = get_word_mmu030(a7 + 0x30); uae_u32 mmu030_state_1 = get_word_mmu030(a7 + 0x32); @@ -2771,7 +2771,7 @@ void m68k_do_rte_mmu030 (uaecptr a7) // did we have ins fault and RB bit cleared? if ((ssw & MMU030_SSW_FB) && !(ssw & MMU030_SSW_RB)) { uae_u16 stageb = get_word_mmu030 (a7 + 0x0e); - if (mmu030_opcode_v == -1) { + if (mmu030_opcode_v == -1U) { mmu030_opcode_stageb = stageb; write_log (_T("Software fixed stage B! opcode = %04x\n"), stageb); } else { @@ -3112,7 +3112,7 @@ void m68k_do_rte_mmu030c (uaecptr a7) // Data buffer uae_u32 mmu030_data_buffer_in_v = get_long_mmu030c(a7 + 0x2c);; - uae_u32 mmu030_opcode_v = (ps & 0x80000000) ? -1 : (oc & 0xffff); + uae_u32 mmu030_opcode_v = (ps & 0x80000000) ? -1U : (oc & 0xffff); // Misc state data uae_u32 mmu030_state_0 = get_word_mmu030c(a7 + 0x30); uae_u32 mmu030_state_1 = get_word_mmu030c(a7 + 0x32); @@ -3164,7 +3164,7 @@ void m68k_do_rte_mmu030c (uaecptr a7) regs.pipeline_r8[0] = (ps >> 8) & 7; regs.pipeline_r8[1] = (ps >> 11) & 7; regs.pipeline_pos = (ps >> 16) & 15; - regs.pipeline_stop = ((ps >> 20) & 15) == 15 ? -1 : (ps >> 20) & 15; + regs.pipeline_stop = ((ps >> 20) & 15) == 15 ? -1 : (int)(ps >> 20) & 15; regs.prefetch020[2] = stagesbc; regs.prefetch020[1] = stagesbc >> 16; diff --git a/fpp.cpp b/fpp.cpp index cb3d082e..54d285a1 100644 --- a/fpp.cpp +++ b/fpp.cpp @@ -989,7 +989,7 @@ static void fp_unimp_datatype(uae_u16 opcode, uae_u16 extra, uae_u32 ea, uaecptr fsave_data.stag = 7; // undocumented } else { fpp_from_exten_fmovem(src, &fsave_data.et[0], &fsave_data.et[1], &fsave_data.et[2]); - fsave_data.stag = get_ftag(src, (opclass == 0) ? -1 : size); + fsave_data.stag = get_ftag(src, (opclass == 0) ? -1U : size); if (fsave_data.stag == 5) { fsave_data.et[0] = (size == 1) ? 0x3f800000 : 0x3c000000; // exponent for denormalized single and double }