Fix problems in the sim sources discovered by running the cppcheck static analysis...
authorNick Clifton <nickc@redhat.com>
Wed, 29 Apr 2015 15:02:02 +0000 (16:02 +0100)
committerNick Clifton <nickc@redhat.com>
Wed, 29 Apr 2015 15:02:02 +0000 (16:02 +0100)
erc32 PR 18273
* sis.c (main): Remove unreachable code.

m68hc11 * gencode.c (gen_fetch_operands): Remove unreachable code.

ppc * hw_htab.c (htab_map_binary): Fix overlap check.

common * sim-fpu.c (INLINE_SIM_FPU): Fix static analysis warning by
increasing parenthesis around casts to signed values.

sim/common/ChangeLog
sim/common/sim-fpu.c
sim/erc32/ChangeLog
sim/erc32/sis.c
sim/m68hc11/ChangeLog
sim/m68hc11/gencode.c
sim/ppc/ChangeLog
sim/ppc/hw_htab.c

index 3c4428f677b40615ca8e62175680a28be789e95e..ebf8618d98a268214023ce2f0570ed17cc6d8c3c 100644 (file)
@@ -1,3 +1,10 @@
+2015-04-29  Nick Clifton  <nickc@redhat.com>
+
+       PR 18273
+       * sim-fpu.c (INLINE_SIM_FPU): Fix static analysis warning by
+       increasing parenthesis around casts to signed values.
+       
+
 2015-04-21  Mike Frysinger  <vapier@gentoo.org>
 
        * gennltvals.sh: Add mcore support.
index f3e7f96805ec6302b62d38d6b449322c152f3ead..b6d35d12b14a3de13a3c1302a30df85e2a1a089d 100644 (file)
@@ -1107,7 +1107,7 @@ sim_fpu_add (sim_fpu *f,
 
     /* sign? */
     f->class = sim_fpu_class_number;
-    if ((signed64) f->fraction >= 0)
+    if (((signed64) f->fraction) >= 0)
       f->sign = 0;
     else
       {
@@ -1261,7 +1261,7 @@ sim_fpu_sub (sim_fpu *f,
 
     /* sign? */
     f->class = sim_fpu_class_number;
-    if ((signed64) f->fraction >= 0)
+    if (((signed64) f->fraction) >= 0)
       f->sign = 0;
     else
       {
index 4f9b502857f8b01ad32120de32360138cfc44744..688dc648596464d61fee9bb2566b12c1ec98ddf4 100644 (file)
@@ -1,3 +1,8 @@
+2015-04-29  Nick Clifton  <nickc@redhat.com>
+
+       PR 18273
+       * sis.c (main): Remove unreachable code.
+
 2015-04-24  David Binderman  <dcb314@hotmail.com>
            Nick Clifton  <nickc@redhat.com>
 
index 92880e14c0bb959ba9417fc1fbeba81d5eec3697..180d97ea598ea15caa7d2e441efd0aa96e1de550 100644 (file)
@@ -169,7 +169,7 @@ main(argc, argv)
     while (stat < argc) {
        if (argv[stat][0] == '-') {
            if (strcmp(argv[stat], "-v") == 0) {
-               sis_verbose = 1;
+               sis_verbose += 1;
            } else if (strcmp(argv[stat], "-c") == 0) {
                if ((stat + 1) < argc) {
                    copt = 1;
@@ -202,8 +202,6 @@ main(argc, argv)
 #endif
             } else if (strcmp(argv[stat], "-dumbio") == 0) {
                dumbio = 1;
-            } else if (strcmp(argv[stat], "-v") == 0) {
-               sis_verbose += 1;
            } else {
                printf("unknown option %s\n", argv[stat]);
                usage();
index 957abb58a159e342c44b99f4eedf6310858f419d..f87aedf849698e2c58a6cd4cde639b734516b577 100644 (file)
@@ -1,3 +1,8 @@
+2015-04-29  Nick Clifton  <nickc@redhat.com>
+
+       PR 18273
+       * gencode.c (gen_fetch_operands): Remove unreachable code.
+
 2015-04-18  Mike Frysinger  <vapier@gentoo.org>
 
        * sim-main.h (SIM_CPU): Delete.
index dd9aa5f200187a4bdacf73829c866d60f6ba333b..ffc285cf8c28d1a6612148dd8dc558360ec5d1e1 100644 (file)
@@ -1466,6 +1466,8 @@ gen_fetch_operands (FILE *fp, int col,
                     vars[cur_var], operand_size, operand_size);
              operands += 1;
            }
+#if 0 /* This code is never executed (see strncmp above), but it has not been
+        removed because it may be that there is a typo in strncmp test below.  */
          else if (strncmp (operands, "]", 1) == 0)
            {
              current_insn_size += 1;
@@ -1473,6 +1475,7 @@ gen_fetch_operands (FILE *fp, int col,
                     vars[cur_var], operand_size, operand_size);
              operands += 1;
            }
+#endif
          else
            {
              fatal_error (opcode, "Unknown operand");
index cd185ba5e6a066572b27a9b479e06848d097b31d..1297df17a23491f40f9eb2be5f30a314c1e16a9a 100644 (file)
@@ -1,3 +1,8 @@
+2015-04-29  Nick Clifton  <nickc@redhat.com>
+
+       PR 18273
+       * hw_htab.c (htab_map_binary): Fix overlap check.
+
 2015-04-13  Mike Frysinger  <vapier@gentoo.org>
 
        * Makefile.in (version.o): Change to using create-version.sh from gdb.
index c49b3231ffeaf7ba232578422ddf782f5944b44d..cf275ff7025616185401cf89451a5967f280b3b6 100644 (file)
@@ -549,7 +549,7 @@ htab_map_binary(device *me,
   if ((sizes.text_base <= sizes.data_base
        && sizes.text_bound >= sizes.data_bound)
       || (sizes.data_base <= sizes.text_base
-         && sizes.data_bound >= sizes.data_bound)
+         && sizes.data_bound >= sizes.text_bound)
       || (sizes.text_bound > sizes.data_base
          && sizes.text_bound <= sizes.data_bound)
       || (sizes.text_base >= sizes.data_base
This page took 0.0346 seconds and 4 git commands to generate.