]> git.unchartedbackwaters.co.uk Git - francis/winuae.git/commitdiff
Silence compiler warnings when compiling with GCC's -Wsign-compare
authorThomas Huth <huth@tuxfamily.org>
Sat, 1 Dec 2018 11:53:59 +0000 (12:53 +0100)
committerThomas Huth <huth@tuxfamily.org>
Sat, 1 Dec 2018 12:03:21 +0000 (13:03 +0100)
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.

cpummu30.cpp
fpp.cpp

index ebe50f6f1e1b4018148495fa5c98103f42fee57c..50c1dc39664a914290ac7dd6227dfbd9cbe1e351 100644 (file)
@@ -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 cb3d082e813c1cb93df0814a337c756022b39987..54d285a1881ceee6fb77e84a4a300da05ef28e35 100644 (file)
--- 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
                                }