Re: [PATCH 26/29] lib: zstd: Avoid comma separated statements

2021-01-30 Thread Joe Perches
On Mon, 2020-08-24 at 21:56 -0700, Joe Perches wrote:
> Use semicolons and braces.

ping?

> Signed-off-by: Joe Perches 
> ---
>  lib/zstd/compress.c | 120 ++--
>  lib/zstd/fse_compress.c |  24 +---
>  lib/zstd/huf_compress.c |   6 +-
>  3 files changed, 100 insertions(+), 50 deletions(-)
> 
> diff --git a/lib/zstd/compress.c b/lib/zstd/compress.c
> index b080264ed3ad..d8587e458665 100644
> --- a/lib/zstd/compress.c
> +++ b/lib/zstd/compress.c
> @@ -629,12 +629,17 @@ ZSTD_STATIC size_t 
> ZSTD_compressSequences_internal(ZSTD_CCtx *zc, void *dst, siz
>   /* Sequences Header */
>   if ((oend - op) < 3 /*max nbSeq Size*/ + 1 /*seqHead */)
>   return ERROR(dstSize_tooSmall);
> - if (nbSeq < 0x7F)
> + if (nbSeq < 0x7F) {
>   *op++ = (BYTE)nbSeq;
> - else if (nbSeq < LONGNBSEQ)
> - op[0] = (BYTE)((nbSeq >> 8) + 0x80), op[1] = (BYTE)nbSeq, op += 
> 2;
> - else
> - op[0] = 0xFF, ZSTD_writeLE16(op + 1, (U16)(nbSeq - LONGNBSEQ)), 
> op += 3;
> + } else if (nbSeq < LONGNBSEQ) {
> + op[0] = (BYTE)((nbSeq >> 8) + 0x80);
> + op[1] = (BYTE)nbSeq;
> + op += 2;
> + } else {
> + op[0] = 0xFF;
> + ZSTD_writeLE16(op + 1, (U16)(nbSeq - LONGNBSEQ));
> + op += 3;
> + }
>   if (nbSeq == 0)
>   return op - ostart;
>  
> 
> @@ -1025,10 +1030,13 @@ void ZSTD_compressBlock_fast_generic(ZSTD_CCtx *cctx, 
> const void *src, size_t sr
>   ip += (ip == lowest);
>   {
>   U32 const maxRep = (U32)(ip - lowest);
> - if (offset_2 > maxRep)
> - offsetSaved = offset_2, offset_2 = 0;
> - if (offset_1 > maxRep)
> - offsetSaved = offset_1, offset_1 = 0;
> + if (offset_2 > maxRep) {
> + offsetSaved = offset_2;
> + offset_2 = 0;
> + }
> + if (offset_1 > maxRep) {
> + offsetSaved = offset_1; offset_1 = 0;
> + }
>   }
>  
> 
>   /* Main Search Loop */
> @@ -1273,10 +1281,14 @@ void ZSTD_compressBlock_doubleFast_generic(ZSTD_CCtx 
> *cctx, const void *src, siz
>   ip += (ip == lowest);
>   {
>   U32 const maxRep = (U32)(ip - lowest);
> - if (offset_2 > maxRep)
> - offsetSaved = offset_2, offset_2 = 0;
> - if (offset_1 > maxRep)
> - offsetSaved = offset_1, offset_1 = 0;
> + if (offset_2 > maxRep) {
> + offsetSaved = offset_2;
> + offset_2 = 0;
> + }
> + if (offset_1 > maxRep) {
> + offsetSaved = offset_1;
> + offset_1 = 0;
> + }
>   }
>  
> 
>   /* Main Search Loop */
> @@ -1686,8 +1698,10 @@ static size_t ZSTD_insertBtAndFindBestMatch(ZSTD_CCtx 
> *zc, const BYTE *const ip,
>   if (matchLength > bestLength) {
>   if (matchLength > matchEndIdx - matchIndex)
>   matchEndIdx = matchIndex + (U32)matchLength;
> - if ((4 * (int)(matchLength - bestLength)) > 
> (int)(ZSTD_highbit32(curr - matchIndex + 1) - 
> ZSTD_highbit32((U32)offsetPtr[0] + 1)))
> - bestLength = matchLength, *offsetPtr = 
> ZSTD_REP_MOVE + curr - matchIndex;
> + if ((4 * (int)(matchLength - bestLength)) > 
> (int)(ZSTD_highbit32(curr - matchIndex + 1) - 
> ZSTD_highbit32((U32)offsetPtr[0] + 1))) {
> + bestLength = matchLength;
> + *offsetPtr = ZSTD_REP_MOVE + curr - matchIndex;
> + }
>   if (ip + matchLength == iend) /* equal : no way to know 
> if inf or sup */
>   break;/* drop, to guarantee 
> consistency (miss a little bit of compression) */
>   }
> @@ -1916,10 +1930,14 @@ void ZSTD_compressBlock_lazy_generic(ZSTD_CCtx *ctx, 
> const void *src, size_t src
>   ctx->nextToUpdate3 = ctx->nextToUpdate;
>   {
>   U32 const maxRep = (U32)(ip - base);
> - if (offset_2 > maxRep)
> - savedOffset = offset_2, offset_2 = 0;
> - if (offset_1 > maxRep)
> - savedOffset = offset_1, offset_1 = 0;
> + if (offset_2 > maxRep) {
> + savedOffset = offset_2;
> + offset_2 = 0;
> + }
> + if (offset_1 > maxRep) {
> + savedOffset = offset_1;
> + offset_1 = 0;
> + }
>   }
>  
> 
>   /* Match Loop */
> @@ -1940,8 +1958,11 @@ void ZSTD_compressBlock_lazy_generic(ZSTD_CCtx *ctx, 
> const void *src, size_t src
>   {
>   size_t offsetFound = ;
>   

[PATCH 26/29] lib: zstd: Avoid comma separated statements

2020-08-24 Thread Joe Perches
Use semicolons and braces.

Signed-off-by: Joe Perches 
---
 lib/zstd/compress.c | 120 ++--
 lib/zstd/fse_compress.c |  24 +---
 lib/zstd/huf_compress.c |   6 +-
 3 files changed, 100 insertions(+), 50 deletions(-)

diff --git a/lib/zstd/compress.c b/lib/zstd/compress.c
index b080264ed3ad..d8587e458665 100644
--- a/lib/zstd/compress.c
+++ b/lib/zstd/compress.c
@@ -629,12 +629,17 @@ ZSTD_STATIC size_t 
ZSTD_compressSequences_internal(ZSTD_CCtx *zc, void *dst, siz
/* Sequences Header */
if ((oend - op) < 3 /*max nbSeq Size*/ + 1 /*seqHead */)
return ERROR(dstSize_tooSmall);
-   if (nbSeq < 0x7F)
+   if (nbSeq < 0x7F) {
*op++ = (BYTE)nbSeq;
-   else if (nbSeq < LONGNBSEQ)
-   op[0] = (BYTE)((nbSeq >> 8) + 0x80), op[1] = (BYTE)nbSeq, op += 
2;
-   else
-   op[0] = 0xFF, ZSTD_writeLE16(op + 1, (U16)(nbSeq - LONGNBSEQ)), 
op += 3;
+   } else if (nbSeq < LONGNBSEQ) {
+   op[0] = (BYTE)((nbSeq >> 8) + 0x80);
+   op[1] = (BYTE)nbSeq;
+   op += 2;
+   } else {
+   op[0] = 0xFF;
+   ZSTD_writeLE16(op + 1, (U16)(nbSeq - LONGNBSEQ));
+   op += 3;
+   }
if (nbSeq == 0)
return op - ostart;
 
@@ -1025,10 +1030,13 @@ void ZSTD_compressBlock_fast_generic(ZSTD_CCtx *cctx, 
const void *src, size_t sr
ip += (ip == lowest);
{
U32 const maxRep = (U32)(ip - lowest);
-   if (offset_2 > maxRep)
-   offsetSaved = offset_2, offset_2 = 0;
-   if (offset_1 > maxRep)
-   offsetSaved = offset_1, offset_1 = 0;
+   if (offset_2 > maxRep) {
+   offsetSaved = offset_2;
+   offset_2 = 0;
+   }
+   if (offset_1 > maxRep) {
+   offsetSaved = offset_1; offset_1 = 0;
+   }
}
 
/* Main Search Loop */
@@ -1273,10 +1281,14 @@ void ZSTD_compressBlock_doubleFast_generic(ZSTD_CCtx 
*cctx, const void *src, siz
ip += (ip == lowest);
{
U32 const maxRep = (U32)(ip - lowest);
-   if (offset_2 > maxRep)
-   offsetSaved = offset_2, offset_2 = 0;
-   if (offset_1 > maxRep)
-   offsetSaved = offset_1, offset_1 = 0;
+   if (offset_2 > maxRep) {
+   offsetSaved = offset_2;
+   offset_2 = 0;
+   }
+   if (offset_1 > maxRep) {
+   offsetSaved = offset_1;
+   offset_1 = 0;
+   }
}
 
/* Main Search Loop */
@@ -1686,8 +1698,10 @@ static size_t ZSTD_insertBtAndFindBestMatch(ZSTD_CCtx 
*zc, const BYTE *const ip,
if (matchLength > bestLength) {
if (matchLength > matchEndIdx - matchIndex)
matchEndIdx = matchIndex + (U32)matchLength;
-   if ((4 * (int)(matchLength - bestLength)) > 
(int)(ZSTD_highbit32(curr - matchIndex + 1) - ZSTD_highbit32((U32)offsetPtr[0] 
+ 1)))
-   bestLength = matchLength, *offsetPtr = 
ZSTD_REP_MOVE + curr - matchIndex;
+   if ((4 * (int)(matchLength - bestLength)) > 
(int)(ZSTD_highbit32(curr - matchIndex + 1) - ZSTD_highbit32((U32)offsetPtr[0] 
+ 1))) {
+   bestLength = matchLength;
+   *offsetPtr = ZSTD_REP_MOVE + curr - matchIndex;
+   }
if (ip + matchLength == iend) /* equal : no way to know 
if inf or sup */
break;/* drop, to guarantee 
consistency (miss a little bit of compression) */
}
@@ -1916,10 +1930,14 @@ void ZSTD_compressBlock_lazy_generic(ZSTD_CCtx *ctx, 
const void *src, size_t src
ctx->nextToUpdate3 = ctx->nextToUpdate;
{
U32 const maxRep = (U32)(ip - base);
-   if (offset_2 > maxRep)
-   savedOffset = offset_2, offset_2 = 0;
-   if (offset_1 > maxRep)
-   savedOffset = offset_1, offset_1 = 0;
+   if (offset_2 > maxRep) {
+   savedOffset = offset_2;
+   offset_2 = 0;
+   }
+   if (offset_1 > maxRep) {
+   savedOffset = offset_1;
+   offset_1 = 0;
+   }
}
 
/* Match Loop */
@@ -1940,8 +1958,11 @@ void ZSTD_compressBlock_lazy_generic(ZSTD_CCtx *ctx, 
const void *src, size_t src
{
size_t offsetFound = ;
size_t const ml2 = searchMax(ctx, ip, iend, 
, maxSearches, mls);
-   if (ml2 > matchLength)
-