public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
* [PATCH v2] MdeModulePkg BrotliLib: Fix the regression logic issue in loop
@ 2017-04-14  1:59 Liming Gao
  2017-04-14  2:48 ` Song, BinX
  0 siblings, 1 reply; 2+ messages in thread
From: Liming Gao @ 2017-04-14  1:59 UTC (permalink / raw)
  To: edk2-devel

In V2, change logic to avoid use mtf[-1] style to get value.

Roll back to previous logic, and use point + offset to get byte value.

Cc: Bell Song <binx.song@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Liming Gao <liming.gao@intel.com>
---
 MdeModulePkg/Library/BrotliCustomDecompressLib/dec/decode.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/MdeModulePkg/Library/BrotliCustomDecompressLib/dec/decode.c b/MdeModulePkg/Library/BrotliCustomDecompressLib/dec/decode.c
index 67f0ff2..6557ba6 100644
--- a/MdeModulePkg/Library/BrotliCustomDecompressLib/dec/decode.c
+++ b/MdeModulePkg/Library/BrotliCustomDecompressLib/dec/decode.c
@@ -855,6 +855,7 @@ static BROTLI_NOINLINE void InverseMoveToFrontTransform(
   uint32_t i = 4;
   uint32_t upper_bound = state->mtf_upper_bound;
   uint8_t* mtf = &state->mtf[4];  /* Make mtf[-1] addressable. */
+  uint8_t* mtft = &state->mtf[3];
   /* Load endian-aware constant. */
   const uint8_t b0123[4] = {0, 1, 2, 3};
   uint32_t pattern;
@@ -875,10 +876,10 @@ static BROTLI_NOINLINE void InverseMoveToFrontTransform(
     uint8_t value = mtf[index];
     upper_bound |= (uint32_t)v[i];
     v[i] = value;
-    mtf[-1] = value;
-    while (index > 0) {
+    mtft[0] = value;
+    while (index >= 0) {
+      mtft[index + 1] = mtft[index];
       index--;
-      mtf[index + 1] = mtf[index];
     }
   }
   /* Remember amount of elements to be reinitialized. */
-- 
2.8.0.windows.1



^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH v2] MdeModulePkg BrotliLib: Fix the regression logic issue in loop
  2017-04-14  1:59 [PATCH v2] MdeModulePkg BrotliLib: Fix the regression logic issue in loop Liming Gao
@ 2017-04-14  2:48 ` Song, BinX
  0 siblings, 0 replies; 2+ messages in thread
From: Song, BinX @ 2017-04-14  2:48 UTC (permalink / raw)
  To: Gao, Liming, edk2-devel@lists.01.org

Reviewed-by:  Bell Song <binx.song@intel.com>

Best Regards,
Bell Song

> -----Original Message-----
> From: Gao, Liming
> Sent: Friday, April 14, 2017 10:00 AM
> To: edk2-devel@lists.01.org
> Cc: Song, BinX <binx.song@intel.com>
> Subject: [PATCH v2] MdeModulePkg BrotliLib: Fix the regression logic issue in
> loop
> 
> In V2, change logic to avoid use mtf[-1] style to get value.
> 
> Roll back to previous logic, and use point + offset to get byte value.
> 
> Cc: Bell Song <binx.song@intel.com>
> Contributed-under: TianoCore Contribution Agreement 1.0
> Signed-off-by: Liming Gao <liming.gao@intel.com>
> ---
>  MdeModulePkg/Library/BrotliCustomDecompressLib/dec/decode.c | 7 ++++---
>  1 file changed, 4 insertions(+), 3 deletions(-)
> 
> diff --git a/MdeModulePkg/Library/BrotliCustomDecompressLib/dec/decode.c
> b/MdeModulePkg/Library/BrotliCustomDecompressLib/dec/decode.c
> index 67f0ff2..6557ba6 100644
> --- a/MdeModulePkg/Library/BrotliCustomDecompressLib/dec/decode.c
> +++ b/MdeModulePkg/Library/BrotliCustomDecompressLib/dec/decode.c
> @@ -855,6 +855,7 @@ static BROTLI_NOINLINE void
> InverseMoveToFrontTransform(
>    uint32_t i = 4;
>    uint32_t upper_bound = state->mtf_upper_bound;
>    uint8_t* mtf = &state->mtf[4];  /* Make mtf[-1] addressable. */
> +  uint8_t* mtft = &state->mtf[3];
>    /* Load endian-aware constant. */
>    const uint8_t b0123[4] = {0, 1, 2, 3};
>    uint32_t pattern;
> @@ -875,10 +876,10 @@ static BROTLI_NOINLINE void
> InverseMoveToFrontTransform(
>      uint8_t value = mtf[index];
>      upper_bound |= (uint32_t)v[i];
>      v[i] = value;
> -    mtf[-1] = value;
> -    while (index > 0) {
> +    mtft[0] = value;
> +    while (index >= 0) {
> +      mtft[index + 1] = mtft[index];
>        index--;
> -      mtf[index + 1] = mtf[index];
>      }
>    }
>    /* Remember amount of elements to be reinitialized. */
> --
> 2.8.0.windows.1



^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2017-04-14  2:48 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-04-14  1:59 [PATCH v2] MdeModulePkg BrotliLib: Fix the regression logic issue in loop Liming Gao
2017-04-14  2:48 ` Song, BinX

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox