[spice-server] glz-encode: Remove obsolete reference segment

Submitted by Frediano Ziglio on Aug. 12, 2019, 7:14 a.m.

Details

Message ID 20190812071458.8946-1-fziglio@redhat.com
State Accepted
Commit 461288534fc58d794e2c10f780fca43f1f352985
Headers show
Series "glz-encode: Remove obsolete reference segment" ( rev: 1 ) in Spice

Not browsing as part of any series.

Commit Message

Frediano Ziglio Aug. 12, 2019, 7:14 a.m.
The GLZ code is basically LZ code sharing image segments between
multiple images.
The code for RLE check in LZ is dealing with both RLE and dictionary
matches being:

    if (!distance) {
        /* zero distance means a run */
        PIXEL x = *ref;
        while ((ip < ip_bound) && (ref < ref_limit)) { // TODO: maybe separate a run from
                                                       //       the same seg or from different
                                                       //       ones in order to spare
                                                       //       ref < ref_limit

in GLZ that part was copied to RLE part removing the need for the
second segment ("ref"). However the comment and setting ref variables
were not removed. Remove the old code to avoid confusions.

This also remove a Coverity warning as ref_limit was set not not used
(reported by Uri Lublin).
The warning was:

CLANG warning: "Value stored to 'ref_limit' is never read"

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
---
 server/glz-encode.tmpl.c | 10 +++-------
 1 file changed, 3 insertions(+), 7 deletions(-)

Patch hide | download patch | download mbox

diff --git a/server/glz-encode.tmpl.c b/server/glz-encode.tmpl.c
index 48bab50bc..92deb0e12 100644
--- a/server/glz-encode.tmpl.c
+++ b/server/glz-encode.tmpl.c
@@ -276,19 +276,15 @@  static void FNAME(compress_seg)(Encoder *encoder, uint32_t seg_idx, PIXEL *from,
 
         if (LZ_EXPECT_CONDITIONAL(ip > (PIXEL *)(seg->lines))) {
             if (SAME_PIXEL(ip[-1], ip[0]) && SAME_PIXEL(ip[0], ip[1]) && SAME_PIXEL(ip[1], ip[2])) {
-                PIXEL x;
+                PIXEL x = ip[2];
+
                 pix_dist = 1;
                 image_dist = 0;
 
                 ip += 3;
-                ref = anchor + 2;
-                ref_limit = (PIXEL *)(seg->lines_end);
                 len = 3;
 
-                x = *ref;
-
-                while (ip < ip_bound) { // TODO: maybe separate a run from the same seg or from
-                                       // different ones in order to spare ref < ref_limit
+                while (ip < ip_bound) {
                     if (!SAME_PIXEL(*ip, x)) {
                         ip++;
                         break;

Comments

On 8/12/19 10:14 AM, Frediano Ziglio wrote:
> The GLZ code is basically LZ code sharing image segments between
> multiple images.
> The code for RLE check in LZ is dealing with both RLE and dictionary
> matches being: >
>      if (!distance) {
>          /* zero distance means a run */
>          PIXEL x = *ref;
>          while ((ip < ip_bound) && (ref < ref_limit)) { // TODO: maybe separate a run from
>                                                         //       the same seg or from different
>                                                         //       ones in order to spare
>                                                         //       ref < ref_limit
> 
> in GLZ that part was copied to RLE part removing the need for the
> second segment ("ref"). However the comment and setting ref variables
> were not removed. Remove the old code to avoid confusions.
> 
> This also remove a Coverity warning as ref_limit was set not not used
> (reported by Uri Lublin).
> The warning was:
> 
> CLANG warning: "Value stored to 'ref_limit' is never read"
> 
> Signed-off-by: Frediano Ziglio <fziglio@redhat.com>

Ack.

Uri.

> ---
>   server/glz-encode.tmpl.c | 10 +++-------
>   1 file changed, 3 insertions(+), 7 deletions(-)
> 
> diff --git a/server/glz-encode.tmpl.c b/server/glz-encode.tmpl.c
> index 48bab50bc..92deb0e12 100644
> --- a/server/glz-encode.tmpl.c
> +++ b/server/glz-encode.tmpl.c
> @@ -276,19 +276,15 @@ static void FNAME(compress_seg)(Encoder *encoder, uint32_t seg_idx, PIXEL *from,
>   
>           if (LZ_EXPECT_CONDITIONAL(ip > (PIXEL *)(seg->lines))) {
>               if (SAME_PIXEL(ip[-1], ip[0]) && SAME_PIXEL(ip[0], ip[1]) && SAME_PIXEL(ip[1], ip[2])) {
> -                PIXEL x;
> +                PIXEL x = ip[2];
> +
>                   pix_dist = 1;
>                   image_dist = 0;
>   
>                   ip += 3;
> -                ref = anchor + 2;
> -                ref_limit = (PIXEL *)(seg->lines_end);
>                   len = 3;
>   
> -                x = *ref;
> -
> -                while (ip < ip_bound) { // TODO: maybe separate a run from the same seg or from
> -                                       // different ones in order to spare ref < ref_limit
> +                while (ip < ip_bound) {
>                       if (!SAME_PIXEL(*ip, x)) {
>                           ip++;
>                           break;
>