[Spice-devel] [spice-common 7/8] coverity: remove structurally dead code

Fabiano FidĂȘncio fidencio at redhat.com
Mon Apr 4 08:03:38 UTC 2016


The loop (for (;;)) will be executed only once, so, no reason for
keeping it.
---
 common/lz_compress_tmpl.c | 19 ++++++++-----------
 1 file changed, 8 insertions(+), 11 deletions(-)

diff --git a/common/lz_compress_tmpl.c b/common/lz_compress_tmpl.c
index e316c4b..0305278 100644
--- a/common/lz_compress_tmpl.c
+++ b/common/lz_compress_tmpl.c
@@ -323,18 +323,15 @@ match:        // RLE or dictionary (both are encoded by distance from ref (-1) a
             // TODO: maybe separate a run from the same seg or from different ones in order
             //       to spare ref < ref_limit and that way we can also perform 8 calls of
             //       (ref++ != ip++) outside a loop
-            for (;;) {
-                while ((ip < ip_bound) && (ref < ref_limit)) {
-                    if (!SAME_PIXEL(*ref, *ip)) {
-                        ref++;
-                        ip++;
-                        break;
-                    } else {
-                        ref++;
-                        ip++;
-                    }
+            while ((ip < ip_bound) && (ref < ref_limit)) {
+                if (!SAME_PIXEL(*ref, *ip)) {
+                    ref++;
+                    ip++;
+                    break;
+                } else {
+                    ref++;
+                    ip++;
                 }
-                break;
             }
         }
 
-- 
2.7.3



More information about the Spice-devel mailing list