Changeset 37211


Ignore:
Timestamp:
2013-07-09T14:52:04+02:00 (5 years ago)
Author:
nbd
Message:

kernel: debloat the lzma compress/decompress code some more

Signed-off-by: Felix Fietkau <nbd@…>

Location:
trunk/target/linux/generic
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/target/linux/generic/patches-3.10/531-debloat_lzma.patch

    r36663 r37211  
    125125--- a/lib/lzma/LzmaDec.c 
    126126+++ b/lib/lzma/LzmaDec.c 
    127 @@ -682,7 +682,7 @@ static void LzmaDec_InitRc(CLzmaDec *p, 
     127@@ -682,7 +682,7 @@ static void LzmaDec_InitRc(CLzmaDec *p,  
    128128   p->needFlush = 0; 
    129129 } 
     
    152152 { 
    153153   SizeT inSize = *srcLen; 
    154 @@ -837,7 +837,7 @@ SRes LzmaDec_DecodeToDic(CLzmaDec *p, Si 
     154@@ -837,65 +837,13 @@ SRes LzmaDec_DecodeToDic(CLzmaDec *p, Si 
    155155   return (p->code == 0) ? SZ_OK : SZ_ERROR_DATA; 
    156156 } 
    157157  
    158158-SRes LzmaDec_DecodeToBuf(CLzmaDec *p, Byte *dest, SizeT *destLen, const Byte *src, SizeT *srcLen, ELzmaFinishMode finishMode, ELzmaStatus *status) 
    159 +static __maybe_unused SRes LzmaDec_DecodeToBuf(CLzmaDec *p, Byte *dest, SizeT *destLen, const Byte *src, SizeT *srcLen, ELzmaFinishMode finishMode, ELzmaStatus *status) 
    160  { 
    161    SizeT outSize = *destLen; 
    162    SizeT inSize = *srcLen; 
    163 @@ -877,7 +877,7 @@ SRes LzmaDec_DecodeToBuf(CLzmaDec *p, By 
    164    } 
    165  } 
    166   
     159-{ 
     160-  SizeT outSize = *destLen; 
     161-  SizeT inSize = *srcLen; 
     162-  *srcLen = *destLen = 0; 
     163-  for (;;) 
     164-  { 
     165-    SizeT inSizeCur = inSize, outSizeCur, dicPos; 
     166-    ELzmaFinishMode curFinishMode; 
     167-    SRes res; 
     168-    if (p->dicPos == p->dicBufSize) 
     169-      p->dicPos = 0; 
     170-    dicPos = p->dicPos; 
     171-    if (outSize > p->dicBufSize - dicPos) 
     172-    { 
     173-      outSizeCur = p->dicBufSize; 
     174-      curFinishMode = LZMA_FINISH_ANY; 
     175-    } 
     176-    else 
     177-    { 
     178-      outSizeCur = dicPos + outSize; 
     179-      curFinishMode = finishMode; 
     180-    } 
     181- 
     182-    res = LzmaDec_DecodeToDic(p, outSizeCur, src, &inSizeCur, curFinishMode, status); 
     183-    src += inSizeCur; 
     184-    inSize -= inSizeCur; 
     185-    *srcLen += inSizeCur; 
     186-    outSizeCur = p->dicPos - dicPos; 
     187-    memcpy(dest, p->dic + dicPos, outSizeCur); 
     188-    dest += outSizeCur; 
     189-    outSize -= outSizeCur; 
     190-    *destLen += outSizeCur; 
     191-    if (res != 0) 
     192-      return res; 
     193-    if (outSizeCur == 0 || outSize == 0) 
     194-      return SZ_OK; 
     195-  } 
     196-} 
     197- 
    167198-void LzmaDec_FreeProbs(CLzmaDec *p, ISzAlloc *alloc) 
    168199+static void LzmaDec_FreeProbs(CLzmaDec *p, ISzAlloc *alloc) 
     
    170201   alloc->Free(alloc, p->probs); 
    171202   p->probs = 0; 
    172 @@ -889,13 +889,13 @@ static void LzmaDec_FreeDict(CLzmaDec *p 
    173    p->dic = 0; 
    174  } 
    175   
     203 } 
     204  
     205-static void LzmaDec_FreeDict(CLzmaDec *p, ISzAlloc *alloc) 
     206-{ 
     207-  alloc->Free(alloc, p->dic); 
     208-  p->dic = 0; 
     209-} 
     210- 
    176211-void LzmaDec_Free(CLzmaDec *p, ISzAlloc *alloc) 
    177 +static void __maybe_unused LzmaDec_Free(CLzmaDec *p, ISzAlloc *alloc) 
    178  { 
    179    LzmaDec_FreeProbs(p, alloc); 
    180    LzmaDec_FreeDict(p, alloc); 
    181  } 
    182   
     212-{ 
     213-  LzmaDec_FreeProbs(p, alloc); 
     214-  LzmaDec_FreeDict(p, alloc); 
     215-} 
     216- 
    183217-SRes LzmaProps_Decode(CLzmaProps *p, const Byte *data, unsigned size) 
    184218+static SRes LzmaProps_Decode(CLzmaProps *p, const Byte *data, unsigned size) 
     
    186220   UInt32 dicSize; 
    187221   Byte d; 
    188 @@ -935,7 +935,7 @@ static SRes LzmaDec_AllocateProbs2(CLzma 
     222@@ -935,33 +883,11 @@ static SRes LzmaDec_AllocateProbs2(CLzma 
    189223   return SZ_OK; 
    190224 } 
    191225  
    192226-SRes LzmaDec_AllocateProbs(CLzmaDec *p, const Byte *props, unsigned propsSize, ISzAlloc *alloc) 
    193 +static SRes __maybe_unused LzmaDec_AllocateProbs(CLzmaDec *p, const Byte *props, unsigned propsSize, ISzAlloc *alloc) 
     227-{ 
     228-  CLzmaProps propNew; 
     229-  RINOK(LzmaProps_Decode(&propNew, props, propsSize)); 
     230-  RINOK(LzmaDec_AllocateProbs2(p, &propNew, alloc)); 
     231-  p->prop = propNew; 
     232-  return SZ_OK; 
     233-} 
     234- 
     235-SRes LzmaDec_Allocate(CLzmaDec *p, const Byte *props, unsigned propsSize, ISzAlloc *alloc) 
     236+static SRes LzmaDec_AllocateProbs(CLzmaDec *p, const Byte *props, unsigned propsSize, ISzAlloc *alloc) 
    194237 { 
    195238   CLzmaProps propNew; 
     239-  SizeT dicBufSize; 
    196240   RINOK(LzmaProps_Decode(&propNew, props, propsSize)); 
    197 @@ -944,7 +944,7 @@ SRes LzmaDec_AllocateProbs(CLzmaDec *p, 
     241   RINOK(LzmaDec_AllocateProbs2(p, &propNew, alloc)); 
     242-  dicBufSize = propNew.dicSize; 
     243-  if (p->dic == 0 || dicBufSize != p->dicBufSize) 
     244-  { 
     245-    LzmaDec_FreeDict(p, alloc); 
     246-    p->dic = (Byte *)alloc->Alloc(alloc, dicBufSize); 
     247-    if (p->dic == 0) 
     248-    { 
     249-      LzmaDec_FreeProbs(p, alloc); 
     250-      return SZ_ERROR_MEM; 
     251-    } 
     252-  } 
     253-  p->dicBufSize = dicBufSize; 
     254   p->prop = propNew; 
    198255   return SZ_OK; 
    199256 } 
    200   
    201 -SRes LzmaDec_Allocate(CLzmaDec *p, const Byte *props, unsigned propsSize, ISzAlloc *alloc) 
    202 +static SRes __maybe_unused LzmaDec_Allocate(CLzmaDec *p, const Byte *props, unsigned propsSize, ISzAlloc *alloc) 
    203  { 
    204    CLzmaProps propNew; 
    205    SizeT dicBufSize; 
    206257--- a/include/linux/lzma/LzmaEnc.h 
    207258+++ b/include/linux/lzma/LzmaEnc.h 
     
    281332   int c = 2, slotFast; 
    282333   g_FastPos[0] = 0; 
    283 @@ -339,7 +339,7 @@ typedef struct 
     334@@ -339,58 +339,6 @@ typedef struct 
    284335   CSaveState saveState; 
    285336 } CLzmaEnc; 
    286337  
    287338-void LzmaEnc_SaveState(CLzmaEncHandle pp) 
    288 +static void __maybe_unused LzmaEnc_SaveState(CLzmaEncHandle pp) 
     339-{ 
     340-  CLzmaEnc *p = (CLzmaEnc *)pp; 
     341-  CSaveState *dest = &p->saveState; 
     342-  int i; 
     343-  dest->lenEnc = p->lenEnc; 
     344-  dest->repLenEnc = p->repLenEnc; 
     345-  dest->state = p->state; 
     346- 
     347-  for (i = 0; i < kNumStates; i++) 
     348-  { 
     349-    memcpy(dest->isMatch[i], p->isMatch[i], sizeof(p->isMatch[i])); 
     350-    memcpy(dest->isRep0Long[i], p->isRep0Long[i], sizeof(p->isRep0Long[i])); 
     351-  } 
     352-  for (i = 0; i < kNumLenToPosStates; i++) 
     353-    memcpy(dest->posSlotEncoder[i], p->posSlotEncoder[i], sizeof(p->posSlotEncoder[i])); 
     354-  memcpy(dest->isRep, p->isRep, sizeof(p->isRep)); 
     355-  memcpy(dest->isRepG0, p->isRepG0, sizeof(p->isRepG0)); 
     356-  memcpy(dest->isRepG1, p->isRepG1, sizeof(p->isRepG1)); 
     357-  memcpy(dest->isRepG2, p->isRepG2, sizeof(p->isRepG2)); 
     358-  memcpy(dest->posEncoders, p->posEncoders, sizeof(p->posEncoders)); 
     359-  memcpy(dest->posAlignEncoder, p->posAlignEncoder, sizeof(p->posAlignEncoder)); 
     360-  memcpy(dest->reps, p->reps, sizeof(p->reps)); 
     361-  memcpy(dest->litProbs, p->litProbs, (0x300 << p->lclp) * sizeof(CLzmaProb)); 
     362-} 
     363- 
     364-void LzmaEnc_RestoreState(CLzmaEncHandle pp) 
     365-{ 
     366-  CLzmaEnc *dest = (CLzmaEnc *)pp; 
     367-  const CSaveState *p = &dest->saveState; 
     368-  int i; 
     369-  dest->lenEnc = p->lenEnc; 
     370-  dest->repLenEnc = p->repLenEnc; 
     371-  dest->state = p->state; 
     372- 
     373-  for (i = 0; i < kNumStates; i++) 
     374-  { 
     375-    memcpy(dest->isMatch[i], p->isMatch[i], sizeof(p->isMatch[i])); 
     376-    memcpy(dest->isRep0Long[i], p->isRep0Long[i], sizeof(p->isRep0Long[i])); 
     377-  } 
     378-  for (i = 0; i < kNumLenToPosStates; i++) 
     379-    memcpy(dest->posSlotEncoder[i], p->posSlotEncoder[i], sizeof(p->posSlotEncoder[i])); 
     380-  memcpy(dest->isRep, p->isRep, sizeof(p->isRep)); 
     381-  memcpy(dest->isRepG0, p->isRepG0, sizeof(p->isRepG0)); 
     382-  memcpy(dest->isRepG1, p->isRepG1, sizeof(p->isRepG1)); 
     383-  memcpy(dest->isRepG2, p->isRepG2, sizeof(p->isRepG2)); 
     384-  memcpy(dest->posEncoders, p->posEncoders, sizeof(p->posEncoders)); 
     385-  memcpy(dest->posAlignEncoder, p->posAlignEncoder, sizeof(p->posAlignEncoder)); 
     386-  memcpy(dest->reps, p->reps, sizeof(p->reps)); 
     387-  memcpy(dest->litProbs, p->litProbs, (0x300 << dest->lclp) * sizeof(CLzmaProb)); 
     388-} 
     389- 
     390 SRes LzmaEnc_SetProps(CLzmaEncHandle pp, const CLzmaEncProps *props2) 
    289391 { 
    290392   CLzmaEnc *p = (CLzmaEnc *)pp; 
    291    CSaveState *dest = &p->saveState; 
    292 @@ -365,7 +365,7 @@ void LzmaEnc_SaveState(CLzmaEncHandle pp 
    293    memcpy(dest->litProbs, p->litProbs, (0x300 << p->lclp) * sizeof(CLzmaProb)); 
    294  } 
    295   
    296 -void LzmaEnc_RestoreState(CLzmaEncHandle pp) 
    297 +static void __maybe_unused LzmaEnc_RestoreState(CLzmaEncHandle pp) 
    298  { 
    299    CLzmaEnc *dest = (CLzmaEnc *)pp; 
    300    const CSaveState *p = &dest->saveState; 
    301 @@ -600,7 +600,7 @@ static void LitEnc_EncodeMatched(CRangeE 
     393@@ -600,7 +548,7 @@ static void LitEnc_EncodeMatched(CRangeE 
    302394   while (symbol < 0x10000); 
    303395 } 
     
    308400   UInt32 i; 
    309401   for (i = (1 << kNumMoveReducingBits) / 2; i < kBitModelTotal; i += (1 << kNumMoveReducingBits)) 
    310 @@ -1676,7 +1676,7 @@ static void FillDistancesPrices(CLzmaEnc 
     402@@ -1676,7 +1624,7 @@ static void FillDistancesPrices(CLzmaEnc 
    311403   p->matchPriceCount = 0; 
    312404 } 
     
    317409   RangeEnc_Construct(&p->rc); 
    318410   MatchFinder_Construct(&p->matchFinderBase); 
    319 @@ -1709,7 +1709,7 @@ CLzmaEncHandle LzmaEnc_Create(ISzAlloc * 
     411@@ -1709,7 +1657,7 @@ CLzmaEncHandle LzmaEnc_Create(ISzAlloc * 
    320412   return p; 
    321413 } 
     
    326418   alloc->Free(alloc, p->litProbs); 
    327419   alloc->Free(alloc, p->saveState.litProbs); 
    328 @@ -2074,7 +2074,7 @@ SRes LzmaEnc_MemPrepare(CLzmaEncHandle p 
     420@@ -1717,7 +1665,7 @@ void LzmaEnc_FreeLits(CLzmaEnc *p, ISzAl 
     421   p->saveState.litProbs = 0; 
     422 } 
     423  
     424-void LzmaEnc_Destruct(CLzmaEnc *p, ISzAlloc *alloc, ISzAlloc *allocBig) 
     425+static void LzmaEnc_Destruct(CLzmaEnc *p, ISzAlloc *alloc, ISzAlloc *allocBig) 
     426 { 
     427   #ifndef _7ZIP_ST 
     428   MatchFinderMt_Destruct(&p->matchFinderMt, allocBig); 
     429@@ -1947,7 +1895,7 @@ static SRes LzmaEnc_Alloc(CLzmaEnc *p, U 
     430   return SZ_OK; 
     431 } 
     432  
     433-void LzmaEnc_Init(CLzmaEnc *p) 
     434+static void LzmaEnc_Init(CLzmaEnc *p) 
     435 { 
     436   UInt32 i; 
     437   p->state = 0; 
     438@@ -2005,7 +1953,7 @@ void LzmaEnc_Init(CLzmaEnc *p) 
     439   p->lpMask = (1 << p->lp) - 1; 
     440 } 
     441  
     442-void LzmaEnc_InitPrices(CLzmaEnc *p) 
     443+static void LzmaEnc_InitPrices(CLzmaEnc *p) 
     444 { 
     445   if (!p->fastMode) 
     446   { 
     447@@ -2037,26 +1985,6 @@ static SRes LzmaEnc_AllocAndInit(CLzmaEn 
     448   return SZ_OK; 
     449 } 
     450  
     451-static SRes LzmaEnc_Prepare(CLzmaEncHandle pp, ISeqOutStream *outStream, ISeqInStream *inStream, 
     452-    ISzAlloc *alloc, ISzAlloc *allocBig) 
     453-{ 
     454-  CLzmaEnc *p = (CLzmaEnc *)pp; 
     455-  p->matchFinderBase.stream = inStream; 
     456-  p->needInit = 1; 
     457-  p->rc.outStream = outStream; 
     458-  return LzmaEnc_AllocAndInit(p, 0, alloc, allocBig); 
     459-} 
     460- 
     461-SRes LzmaEnc_PrepareForLzma2(CLzmaEncHandle pp, 
     462-    ISeqInStream *inStream, UInt32 keepWindowSize, 
     463-    ISzAlloc *alloc, ISzAlloc *allocBig) 
     464-{ 
     465-  CLzmaEnc *p = (CLzmaEnc *)pp; 
     466-  p->matchFinderBase.stream = inStream; 
     467-  p->needInit = 1; 
     468-  return LzmaEnc_AllocAndInit(p, keepWindowSize, alloc, allocBig); 
     469-} 
     470- 
     471 static void LzmaEnc_SetInputBuf(CLzmaEnc *p, const Byte *src, SizeT srcLen) 
     472 { 
     473   p->matchFinderBase.directInput = 1; 
     474@@ -2064,7 +1992,7 @@ static void LzmaEnc_SetInputBuf(CLzmaEnc 
     475   p->matchFinderBase.directInputRem = srcLen; 
     476 } 
     477  
     478-SRes LzmaEnc_MemPrepare(CLzmaEncHandle pp, const Byte *src, SizeT srcLen, 
     479+static SRes LzmaEnc_MemPrepare(CLzmaEncHandle pp, const Byte *src, SizeT srcLen, 
     480     UInt32 keepWindowSize, ISzAlloc *alloc, ISzAlloc *allocBig) 
     481 { 
     482   CLzmaEnc *p = (CLzmaEnc *)pp; 
     483@@ -2074,7 +2002,7 @@ SRes LzmaEnc_MemPrepare(CLzmaEncHandle p 
    329484   return LzmaEnc_AllocAndInit(p, keepWindowSize, alloc, allocBig); 
    330485 } 
     
    335490   #ifndef _7ZIP_ST 
    336491   CLzmaEnc *p = (CLzmaEnc *)pp; 
    337 @@ -2108,7 +2108,7 @@ static size_t MyWrite(void *pp, const vo 
    338  } 
    339   
    340   
     492@@ -2107,53 +2035,6 @@ static size_t MyWrite(void *pp, const vo 
     493   return size; 
     494 } 
     495  
     496- 
    341497-UInt32 LzmaEnc_GetNumAvailableBytes(CLzmaEncHandle pp) 
    342 +static UInt32 __maybe_unused LzmaEnc_GetNumAvailableBytes(CLzmaEncHandle pp) 
    343  { 
    344    const CLzmaEnc *p = (CLzmaEnc *)pp; 
    345    return p->matchFinder.GetNumAvailableBytes(p->matchFinderObj); 
    346 @@ -2120,7 +2120,7 @@ const Byte *LzmaEnc_GetCurBuf(CLzmaEncHa 
    347    return p->matchFinder.GetPointerToCurrentPos(p->matchFinderObj) - p->additionalOffset; 
    348  } 
    349   
     498-{ 
     499-  const CLzmaEnc *p = (CLzmaEnc *)pp; 
     500-  return p->matchFinder.GetNumAvailableBytes(p->matchFinderObj); 
     501-} 
     502- 
     503-const Byte *LzmaEnc_GetCurBuf(CLzmaEncHandle pp) 
     504-{ 
     505-  const CLzmaEnc *p = (CLzmaEnc *)pp; 
     506-  return p->matchFinder.GetPointerToCurrentPos(p->matchFinderObj) - p->additionalOffset; 
     507-} 
     508- 
    350509-SRes LzmaEnc_CodeOneMemBlock(CLzmaEncHandle pp, Bool reInit, 
    351 +static SRes __maybe_unused LzmaEnc_CodeOneMemBlock(CLzmaEncHandle pp, Bool reInit, 
    352      Byte *dest, size_t *destLen, UInt32 desiredPackSize, UInt32 *unpackSize) 
     510-    Byte *dest, size_t *destLen, UInt32 desiredPackSize, UInt32 *unpackSize) 
     511-{ 
     512-  CLzmaEnc *p = (CLzmaEnc *)pp; 
     513-  UInt64 nowPos64; 
     514-  SRes res; 
     515-  CSeqOutStreamBuf outStream; 
     516- 
     517-  outStream.funcTable.Write = MyWrite; 
     518-  outStream.data = dest; 
     519-  outStream.rem = *destLen; 
     520-  outStream.overflow = False; 
     521- 
     522-  p->writeEndMark = False; 
     523-  p->finished = False; 
     524-  p->result = SZ_OK; 
     525- 
     526-  if (reInit) 
     527-    LzmaEnc_Init(p); 
     528-  LzmaEnc_InitPrices(p); 
     529-  nowPos64 = p->nowPos64; 
     530-  RangeEnc_Init(&p->rc); 
     531-  p->rc.outStream = &outStream.funcTable; 
     532- 
     533-  res = LzmaEnc_CodeOneBlock(p, True, desiredPackSize, *unpackSize); 
     534 
     535-  *unpackSize = (UInt32)(p->nowPos64 - nowPos64); 
     536-  *destLen -= outStream.rem; 
     537-  if (outStream.overflow) 
     538-    return SZ_ERROR_OUTPUT_EOF; 
     539- 
     540-  return res; 
     541-} 
     542- 
     543 static SRes LzmaEnc_Encode2(CLzmaEnc *p, ICompressProgress *progress) 
     544 { 
     545   SRes res = SZ_OK; 
     546@@ -2184,13 +2065,6 @@ static SRes LzmaEnc_Encode2(CLzmaEnc *p, 
     547   return res; 
     548 } 
     549  
     550-SRes LzmaEnc_Encode(CLzmaEncHandle pp, ISeqOutStream *outStream, ISeqInStream *inStream, ICompressProgress *progress, 
     551-    ISzAlloc *alloc, ISzAlloc *allocBig) 
     552-{ 
     553-  RINOK(LzmaEnc_Prepare(pp, outStream, inStream, alloc, allocBig)); 
     554-  return LzmaEnc_Encode2((CLzmaEnc *)pp, progress); 
     555-} 
     556- 
     557 SRes LzmaEnc_WriteProperties(CLzmaEncHandle pp, Byte *props, SizeT *size) 
    353558 { 
    354559   CLzmaEnc *p = (CLzmaEnc *)pp; 
    355 @@ -2248,7 +2248,7 @@ SRes LzmaEnc_MemEncode(CLzmaEncHandle pp 
     560@@ -2247,25 +2121,3 @@ SRes LzmaEnc_MemEncode(CLzmaEncHandle pp 
     561     return SZ_ERROR_OUTPUT_EOF; 
    356562   return res; 
    357563 } 
    358   
     564- 
    359565-SRes LzmaEncode(Byte *dest, SizeT *destLen, const Byte *src, SizeT srcLen, 
    360 +static __maybe_unused SRes LzmaEncode(Byte *dest, SizeT *destLen, const Byte *src, SizeT srcLen, 
    361      const CLzmaEncProps *props, Byte *propsEncoded, SizeT *propsSize, int writeEndMark, 
    362      ICompressProgress *progress, ISzAlloc *alloc, ISzAlloc *allocBig) 
    363  { 
     566-    const CLzmaEncProps *props, Byte *propsEncoded, SizeT *propsSize, int writeEndMark, 
     567-    ICompressProgress *progress, ISzAlloc *alloc, ISzAlloc *allocBig) 
     568-{ 
     569-  CLzmaEnc *p = (CLzmaEnc *)LzmaEnc_Create(alloc); 
     570-  SRes res; 
     571-  if (p == 0) 
     572-    return SZ_ERROR_MEM; 
     573- 
     574-  res = LzmaEnc_SetProps(p, props); 
     575-  if (res == SZ_OK) 
     576-  { 
     577-    res = LzmaEnc_WriteProperties(p, propsEncoded, propsSize); 
     578-    if (res == SZ_OK) 
     579-      res = LzmaEnc_MemEncode(p, dest, destLen, src, srcLen, 
     580-          writeEndMark, progress, alloc, allocBig); 
     581-  } 
     582- 
     583-  LzmaEnc_Destroy(p, alloc, allocBig); 
     584-  return res; 
     585-} 
    364586--- a/include/linux/lzma/LzFind.h 
    365587+++ b/include/linux/lzma/LzFind.h 
     
    376598  
    377599 /* Conditions: 
    378 @@ -70,12 +65,6 @@ int MatchFinder_Create(CMatchFinder *p, 
     600@@ -70,12 +65,6 @@ int MatchFinder_Create(CMatchFinder *p,  
    379601     UInt32 keepAddBufferBefore, UInt32 matchMaxLen, UInt32 keepAddBufferAfter, 
    380602     ISzAlloc *alloc); 
     
    404626--- a/lib/lzma/LzFind.c 
    405627+++ b/lib/lzma/LzFind.c 
    406 @@ -42,12 +42,12 @@ static int LzInWindow_Create(CMatchFinde 
     628@@ -14,9 +14,15 @@ 
     629  
     630 #define kStartMaxLen 3 
     631  
     632+#if 0 
     633+#define DIRECT_INPUT   p->directInput 
     634+#else 
     635+#define DIRECT_INPUT   1 
     636+#endif 
     637+ 
     638 static void LzInWindow_Free(CMatchFinder *p, ISzAlloc *alloc) 
     639 { 
     640-  if (!p->directInput) 
     641+  if (!DIRECT_INPUT) 
     642   { 
     643     alloc->Free(alloc, p->bufferBase); 
     644     p->bufferBase = 0; 
     645@@ -28,7 +34,7 @@ static void LzInWindow_Free(CMatchFinder 
     646 static int LzInWindow_Create(CMatchFinder *p, UInt32 keepSizeReserv, ISzAlloc *alloc) 
     647 { 
     648   UInt32 blockSize = p->keepSizeBefore + p->keepSizeAfter + keepSizeReserv; 
     649-  if (p->directInput) 
     650+  if (DIRECT_INPUT) 
     651   { 
     652     p->blockSize = blockSize; 
     653     return 1; 
     654@@ -42,12 +48,12 @@ static int LzInWindow_Create(CMatchFinde 
    407655   return (p->bufferBase != 0); 
    408656 } 
     
    421669   p->posLimit -= subValue; 
    422670   p->pos -= subValue; 
    423 @@ -268,7 +268,7 @@ static void MatchFinder_SetLimits(CMatch 
     671@@ -58,7 +64,7 @@ static void MatchFinder_ReadBlock(CMatch 
     672 { 
     673   if (p->streamEndWasReached || p->result != SZ_OK) 
     674     return; 
     675-  if (p->directInput) 
     676+  if (DIRECT_INPUT) 
     677   { 
     678     UInt32 curSize = 0xFFFFFFFF - p->streamPos; 
     679     if (curSize > p->directInputRem) 
     680@@ -89,7 +95,7 @@ static void MatchFinder_ReadBlock(CMatch 
     681   } 
     682 } 
     683  
     684-void MatchFinder_MoveBlock(CMatchFinder *p) 
     685+static void MatchFinder_MoveBlock(CMatchFinder *p) 
     686 { 
     687   memmove(p->bufferBase, 
     688     p->buffer - p->keepSizeBefore, 
     689@@ -97,22 +103,14 @@ void MatchFinder_MoveBlock(CMatchFinder  
     690   p->buffer = p->bufferBase + p->keepSizeBefore; 
     691 } 
     692  
     693-int MatchFinder_NeedMove(CMatchFinder *p) 
     694+static int MatchFinder_NeedMove(CMatchFinder *p) 
     695 { 
     696-  if (p->directInput) 
     697+  if (DIRECT_INPUT) 
     698     return 0; 
     699   /* if (p->streamEndWasReached) return 0; */ 
     700   return ((size_t)(p->bufferBase + p->blockSize - p->buffer) <= p->keepSizeAfter); 
     701 } 
     702  
     703-void MatchFinder_ReadIfRequired(CMatchFinder *p) 
     704-{ 
     705-  if (p->streamEndWasReached) 
     706-    return; 
     707-  if (p->keepSizeAfter >= p->streamPos - p->pos) 
     708-    MatchFinder_ReadBlock(p); 
     709-} 
     710- 
     711 static void MatchFinder_CheckAndMoveAndRead(CMatchFinder *p) 
     712 { 
     713   if (MatchFinder_NeedMove(p)) 
     714@@ -268,7 +266,7 @@ static void MatchFinder_SetLimits(CMatch 
    424715   p->posLimit = p->pos + limit; 
    425716 } 
     
    430721   UInt32 i; 
    431722   for (i = 0; i < p->hashSizeSum; i++) 
    432 @@ -287,7 +287,7 @@ static UInt32 MatchFinder_GetSubValue(CM 
     723@@ -287,7 +285,7 @@ static UInt32 MatchFinder_GetSubValue(CM 
    433724   return (p->pos - p->historySize - 1) & kNormalizeMask; 
    434725 } 
     
    439730   UInt32 i; 
    440731   for (i = 0; i < numItems; i++) 
    441 @@ -350,7 +350,7 @@ static UInt32 * Hc_GetMatchesSpec(UInt32 
    442    } 
    443  } 
    444   
     732@@ -319,38 +317,7 @@ static void MatchFinder_CheckLimits(CMat 
     733   MatchFinder_SetLimits(p); 
     734 } 
     735  
     736-static UInt32 * Hc_GetMatchesSpec(UInt32 lenLimit, UInt32 curMatch, UInt32 pos, const Byte *cur, CLzRef *son, 
     737-    UInt32 _cyclicBufferPos, UInt32 _cyclicBufferSize, UInt32 cutValue, 
     738-    UInt32 *distances, UInt32 maxLen) 
     739-{ 
     740-  son[_cyclicBufferPos] = curMatch; 
     741-  for (;;) 
     742-  { 
     743-    UInt32 delta = pos - curMatch; 
     744-    if (cutValue-- == 0 || delta >= _cyclicBufferSize) 
     745-      return distances; 
     746-    { 
     747-      const Byte *pb = cur - delta; 
     748-      curMatch = son[_cyclicBufferPos - delta + ((delta > _cyclicBufferPos) ? _cyclicBufferSize : 0)]; 
     749-      if (pb[maxLen] == cur[maxLen] && *pb == *cur) 
     750-      { 
     751-        UInt32 len = 0; 
     752-        while (++len != lenLimit) 
     753-          if (pb[len] != cur[len]) 
     754-            break; 
     755-        if (maxLen < len) 
     756-        { 
     757-          *distances++ = maxLen = len; 
     758-          *distances++ = delta - 1; 
     759-          if (len == lenLimit) 
     760-            return distances; 
     761-        } 
     762-      } 
     763-    } 
     764-  } 
     765-} 
     766- 
    445767-UInt32 * GetMatchesSpec1(UInt32 lenLimit, UInt32 curMatch, UInt32 pos, const Byte *cur, CLzRef *son, 
    446768+static UInt32 * GetMatchesSpec1(UInt32 lenLimit, UInt32 curMatch, UInt32 pos, const Byte *cur, CLzRef *son, 
     
    448770     UInt32 *distances, UInt32 maxLen) 
    449771 { 
    450 @@ -492,7 +492,7 @@ static UInt32 Bt2_MatchFinder_GetMatches 
    451    GET_MATCHES_FOOTER(offset, 1) 
    452  } 
    453   
     772@@ -460,10 +427,10 @@ static void SkipMatchesSpec(UInt32 lenLi 
     773   p->buffer++; \ 
     774   if (++p->pos == p->posLimit) MatchFinder_CheckLimits(p); 
     775  
     776-#define MOVE_POS_RET MOVE_POS return offset; 
     777- 
     778 static void MatchFinder_MovePos(CMatchFinder *p) { MOVE_POS; } 
     779  
     780+#define MOVE_POS_RET MatchFinder_MovePos(p); return offset; 
     781+ 
     782 #define GET_MATCHES_HEADER2(minLen, ret_op) \ 
     783   UInt32 lenLimit; UInt32 hashValue; const Byte *cur; UInt32 curMatch; \ 
     784   lenLimit = p->lenLimit; { if (lenLimit < minLen) { MatchFinder_MovePos(p); ret_op; }} \ 
     785@@ -479,62 +446,7 @@ static void MatchFinder_MovePos(CMatchFi 
     786   distances + offset, maxLen) - distances); MOVE_POS_RET; 
     787  
     788 #define SKIP_FOOTER \ 
     789-  SkipMatchesSpec(lenLimit, curMatch, MF_PARAMS(p)); MOVE_POS; 
     790- 
     791-static UInt32 Bt2_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances) 
     792-{ 
     793-  UInt32 offset; 
     794-  GET_MATCHES_HEADER(2) 
     795-  HASH2_CALC; 
     796-  curMatch = p->hash[hashValue]; 
     797-  p->hash[hashValue] = p->pos; 
     798-  offset = 0; 
     799-  GET_MATCHES_FOOTER(offset, 1) 
     800-} 
     801- 
    454802-UInt32 Bt3Zip_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances) 
    455 +static __maybe_unused UInt32 Bt3Zip_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances) 
    456  { 
    457    UInt32 offset; 
    458    GET_MATCHES_HEADER(3) 
    459 @@ -632,7 +632,7 @@ static UInt32 Hc4_MatchFinder_GetMatches 
    460    MOVE_POS_RET 
    461  } 
    462   
     803-{ 
     804-  UInt32 offset; 
     805-  GET_MATCHES_HEADER(3) 
     806-  HASH_ZIP_CALC; 
     807-  curMatch = p->hash[hashValue]; 
     808-  p->hash[hashValue] = p->pos; 
     809-  offset = 0; 
     810-  GET_MATCHES_FOOTER(offset, 2) 
     811-} 
     812- 
     813-static UInt32 Bt3_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances) 
     814-{ 
     815-  UInt32 hash2Value, delta2, maxLen, offset; 
     816-  GET_MATCHES_HEADER(3) 
     817- 
     818-  HASH3_CALC; 
     819- 
     820-  delta2 = p->pos - p->hash[hash2Value]; 
     821-  curMatch = p->hash[kFix3HashSize + hashValue]; 
     822 
     823-  p->hash[hash2Value] = 
     824-  p->hash[kFix3HashSize + hashValue] = p->pos; 
     825- 
     826- 
     827-  maxLen = 2; 
     828-  offset = 0; 
     829-  if (delta2 < p->cyclicBufferSize && *(cur - delta2) == *cur) 
     830-  { 
     831-    for (; maxLen != lenLimit; maxLen++) 
     832-      if (cur[(ptrdiff_t)maxLen - delta2] != cur[maxLen]) 
     833-        break; 
     834-    distances[0] = maxLen; 
     835-    distances[1] = delta2 - 1; 
     836-    offset = 2; 
     837-    if (maxLen == lenLimit) 
     838-    { 
     839-      SkipMatchesSpec(lenLimit, curMatch, MF_PARAMS(p)); 
     840-      MOVE_POS_RET; 
     841-    } 
     842-  } 
     843-  GET_MATCHES_FOOTER(offset, maxLen) 
     844-} 
     845+  SkipMatchesSpec(lenLimit, curMatch, MF_PARAMS(p)); MatchFinder_MovePos(p); 
     846  
     847 static UInt32 Bt4_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances) 
     848 { 
     849@@ -583,108 +495,6 @@ static UInt32 Bt4_MatchFinder_GetMatches 
     850   GET_MATCHES_FOOTER(offset, maxLen) 
     851 } 
     852  
     853-static UInt32 Hc4_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances) 
     854-{ 
     855-  UInt32 hash2Value, hash3Value, delta2, delta3, maxLen, offset; 
     856-  GET_MATCHES_HEADER(4) 
     857- 
     858-  HASH4_CALC; 
     859- 
     860-  delta2 = p->pos - p->hash[                hash2Value]; 
     861-  delta3 = p->pos - p->hash[kFix3HashSize + hash3Value]; 
     862-  curMatch = p->hash[kFix4HashSize + hashValue]; 
     863- 
     864-  p->hash[                hash2Value] = 
     865-  p->hash[kFix3HashSize + hash3Value] = 
     866-  p->hash[kFix4HashSize + hashValue] = p->pos; 
     867- 
     868-  maxLen = 1; 
     869-  offset = 0; 
     870-  if (delta2 < p->cyclicBufferSize && *(cur - delta2) == *cur) 
     871-  { 
     872-    distances[0] = maxLen = 2; 
     873-    distances[1] = delta2 - 1; 
     874-    offset = 2; 
     875-  } 
     876-  if (delta2 != delta3 && delta3 < p->cyclicBufferSize && *(cur - delta3) == *cur) 
     877-  { 
     878-    maxLen = 3; 
     879-    distances[offset + 1] = delta3 - 1; 
     880-    offset += 2; 
     881-    delta2 = delta3; 
     882-  } 
     883-  if (offset != 0) 
     884-  { 
     885-    for (; maxLen != lenLimit; maxLen++) 
     886-      if (cur[(ptrdiff_t)maxLen - delta2] != cur[maxLen]) 
     887-        break; 
     888-    distances[offset - 2] = maxLen; 
     889-    if (maxLen == lenLimit) 
     890-    { 
     891-      p->son[p->cyclicBufferPos] = curMatch; 
     892-      MOVE_POS_RET; 
     893-    } 
     894-  } 
     895-  if (maxLen < 3) 
     896-    maxLen = 3; 
     897-  offset = (UInt32)(Hc_GetMatchesSpec(lenLimit, curMatch, MF_PARAMS(p), 
     898-    distances + offset, maxLen) - (distances)); 
     899-  MOVE_POS_RET 
     900-} 
     901- 
    463902-UInt32 Hc3Zip_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances) 
    464 +static __maybe_unused UInt32 Hc3Zip_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances) 
    465  { 
    466    UInt32 offset; 
    467    GET_MATCHES_HEADER(3) 
    468 @@ -657,7 +657,7 @@ static void Bt2_MatchFinder_Skip(CMatchF 
     903-{ 
     904-  UInt32 offset; 
     905-  GET_MATCHES_HEADER(3) 
     906-  HASH_ZIP_CALC; 
     907-  curMatch = p->hash[hashValue]; 
     908-  p->hash[hashValue] = p->pos; 
     909-  offset = (UInt32)(Hc_GetMatchesSpec(lenLimit, curMatch, MF_PARAMS(p), 
     910-    distances, 2) - (distances)); 
     911-  MOVE_POS_RET 
     912-} 
     913- 
     914-static void Bt2_MatchFinder_Skip(CMatchFinder *p, UInt32 num) 
     915-{ 
     916-  do 
     917-  { 
     918-    SKIP_HEADER(2) 
     919-    HASH2_CALC; 
     920-    curMatch = p->hash[hashValue]; 
     921-    p->hash[hashValue] = p->pos; 
     922-    SKIP_FOOTER 
     923-  } 
     924-  while (--num != 0); 
     925-} 
     926- 
     927-void Bt3Zip_MatchFinder_Skip(CMatchFinder *p, UInt32 num) 
     928-{ 
     929-  do 
     930-  { 
     931-    SKIP_HEADER(3) 
     932-    HASH_ZIP_CALC; 
     933-    curMatch = p->hash[hashValue]; 
     934-    p->hash[hashValue] = p->pos; 
     935-    SKIP_FOOTER 
     936-  } 
     937-  while (--num != 0); 
     938-} 
     939- 
     940-static void Bt3_MatchFinder_Skip(CMatchFinder *p, UInt32 num) 
     941-{ 
     942-  do 
     943-  { 
     944-    UInt32 hash2Value; 
     945-    SKIP_HEADER(3) 
     946-    HASH3_CALC; 
     947-    curMatch = p->hash[kFix3HashSize + hashValue]; 
     948-    p->hash[hash2Value] = 
     949-    p->hash[kFix3HashSize + hashValue] = p->pos; 
     950-    SKIP_FOOTER 
     951-  } 
     952-  while (--num != 0); 
     953-} 
     954- 
     955 static void Bt4_MatchFinder_Skip(CMatchFinder *p, UInt32 num) 
     956 { 
     957   do 
     958@@ -701,61 +511,12 @@ static void Bt4_MatchFinder_Skip(CMatchF 
    469959   while (--num != 0); 
    470960 } 
    471961  
    472 -void Bt3Zip_MatchFinder_Skip(CMatchFinder *p, UInt32 num) 
    473 +static __maybe_unused void Bt3Zip_MatchFinder_Skip(CMatchFinder *p, UInt32 num) 
    474  { 
    475    do 
    476    { 
    477 @@ -718,7 +718,7 @@ static void Hc4_MatchFinder_Skip(CMatchF 
    478    while (--num != 0); 
    479  } 
    480   
     962-static void Hc4_MatchFinder_Skip(CMatchFinder *p, UInt32 num) 
     963-{ 
     964-  do 
     965-  { 
     966-    UInt32 hash2Value, hash3Value; 
     967-    SKIP_HEADER(4) 
     968-    HASH4_CALC; 
     969-    curMatch = p->hash[kFix4HashSize + hashValue]; 
     970-    p->hash[                hash2Value] = 
     971-    p->hash[kFix3HashSize + hash3Value] = 
     972-    p->hash[kFix4HashSize + hashValue] = p->pos; 
     973-    p->son[p->cyclicBufferPos] = curMatch; 
     974-    MOVE_POS 
     975-  } 
     976-  while (--num != 0); 
     977-} 
     978- 
    481979-void Hc3Zip_MatchFinder_Skip(CMatchFinder *p, UInt32 num) 
    482 +static __maybe_unused void Hc3Zip_MatchFinder_Skip(CMatchFinder *p, UInt32 num) 
    483  { 
    484    do 
    485    { 
     980-{ 
     981-  do 
     982-  { 
     983-    SKIP_HEADER(3) 
     984-    HASH_ZIP_CALC; 
     985-    curMatch = p->hash[hashValue]; 
     986-    p->hash[hashValue] = p->pos; 
     987-    p->son[p->cyclicBufferPos] = curMatch; 
     988-    MOVE_POS 
     989-  } 
     990-  while (--num != 0); 
     991-} 
     992- 
     993 void MatchFinder_CreateVTable(CMatchFinder *p, IMatchFinder *vTable) 
     994 { 
     995   vTable->Init = (Mf_Init_Func)MatchFinder_Init; 
     996   vTable->GetIndexByte = (Mf_GetIndexByte_Func)MatchFinder_GetIndexByte; 
     997   vTable->GetNumAvailableBytes = (Mf_GetNumAvailableBytes_Func)MatchFinder_GetNumAvailableBytes; 
     998   vTable->GetPointerToCurrentPos = (Mf_GetPointerToCurrentPos_Func)MatchFinder_GetPointerToCurrentPos; 
     999-  if (!p->btMode) 
     1000-  { 
     1001-    vTable->GetMatches = (Mf_GetMatches_Func)Hc4_MatchFinder_GetMatches; 
     1002-    vTable->Skip = (Mf_Skip_Func)Hc4_MatchFinder_Skip; 
     1003-  } 
     1004-  else if (p->numHashBytes == 2) 
     1005-  { 
     1006-    vTable->GetMatches = (Mf_GetMatches_Func)Bt2_MatchFinder_GetMatches; 
     1007-    vTable->Skip = (Mf_Skip_Func)Bt2_MatchFinder_Skip; 
     1008-  } 
     1009-  else if (p->numHashBytes == 3) 
     1010-  { 
     1011-    vTable->GetMatches = (Mf_GetMatches_Func)Bt3_MatchFinder_GetMatches; 
     1012-    vTable->Skip = (Mf_Skip_Func)Bt3_MatchFinder_Skip; 
     1013-  } 
     1014-  else 
     1015-  { 
     1016-    vTable->GetMatches = (Mf_GetMatches_Func)Bt4_MatchFinder_GetMatches; 
     1017-    vTable->Skip = (Mf_Skip_Func)Bt4_MatchFinder_Skip; 
     1018-  } 
     1019+  vTable->GetMatches = (Mf_GetMatches_Func)Bt4_MatchFinder_GetMatches; 
     1020+  vTable->Skip = (Mf_Skip_Func)Bt4_MatchFinder_Skip; 
     1021 } 
  • trunk/target/linux/generic/patches-3.8/531-debloat_lzma.patch

    r35478 r37211  
    125125--- a/lib/lzma/LzmaDec.c 
    126126+++ b/lib/lzma/LzmaDec.c 
    127 @@ -682,7 +682,7 @@ static void LzmaDec_InitRc(CLzmaDec *p, 
     127@@ -682,7 +682,7 @@ static void LzmaDec_InitRc(CLzmaDec *p,  
    128128   p->needFlush = 0; 
    129129 } 
     
    152152 { 
    153153   SizeT inSize = *srcLen; 
    154 @@ -837,7 +837,7 @@ SRes LzmaDec_DecodeToDic(CLzmaDec *p, Si 
     154@@ -837,65 +837,13 @@ SRes LzmaDec_DecodeToDic(CLzmaDec *p, Si 
    155155   return (p->code == 0) ? SZ_OK : SZ_ERROR_DATA; 
    156156 } 
    157157  
    158158-SRes LzmaDec_DecodeToBuf(CLzmaDec *p, Byte *dest, SizeT *destLen, const Byte *src, SizeT *srcLen, ELzmaFinishMode finishMode, ELzmaStatus *status) 
    159 +static __maybe_unused SRes LzmaDec_DecodeToBuf(CLzmaDec *p, Byte *dest, SizeT *destLen, const Byte *src, SizeT *srcLen, ELzmaFinishMode finishMode, ELzmaStatus *status) 
    160  { 
    161    SizeT outSize = *destLen; 
    162    SizeT inSize = *srcLen; 
    163 @@ -877,7 +877,7 @@ SRes LzmaDec_DecodeToBuf(CLzmaDec *p, By 
    164    } 
    165  } 
    166   
     159-{ 
     160-  SizeT outSize = *destLen; 
     161-  SizeT inSize = *srcLen; 
     162-  *srcLen = *destLen = 0; 
     163-  for (;;) 
     164-  { 
     165-    SizeT inSizeCur = inSize, outSizeCur, dicPos; 
     166-    ELzmaFinishMode curFinishMode; 
     167-    SRes res; 
     168-    if (p->dicPos == p->dicBufSize) 
     169-      p->dicPos = 0; 
     170-    dicPos = p->dicPos; 
     171-    if (outSize > p->dicBufSize - dicPos) 
     172-    { 
     173-      outSizeCur = p->dicBufSize; 
     174-      curFinishMode = LZMA_FINISH_ANY; 
     175-    } 
     176-    else 
     177-    { 
     178-      outSizeCur = dicPos + outSize; 
     179-      curFinishMode = finishMode; 
     180-    } 
     181- 
     182-    res = LzmaDec_DecodeToDic(p, outSizeCur, src, &inSizeCur, curFinishMode, status); 
     183-    src += inSizeCur; 
     184-    inSize -= inSizeCur; 
     185-    *srcLen += inSizeCur; 
     186-    outSizeCur = p->dicPos - dicPos; 
     187-    memcpy(dest, p->dic + dicPos, outSizeCur); 
     188-    dest += outSizeCur; 
     189-    outSize -= outSizeCur; 
     190-    *destLen += outSizeCur; 
     191-    if (res != 0) 
     192-      return res; 
     193-    if (outSizeCur == 0 || outSize == 0) 
     194-      return SZ_OK; 
     195-  } 
     196-} 
     197- 
    167198-void LzmaDec_FreeProbs(CLzmaDec *p, ISzAlloc *alloc) 
    168199+static void LzmaDec_FreeProbs(CLzmaDec *p, ISzAlloc *alloc) 
     
    170201   alloc->Free(alloc, p->probs); 
    171202   p->probs = 0; 
    172 @@ -889,13 +889,13 @@ static void LzmaDec_FreeDict(CLzmaDec *p 
    173    p->dic = 0; 
    174  } 
    175   
     203 } 
     204  
     205-static void LzmaDec_FreeDict(CLzmaDec *p, ISzAlloc *alloc) 
     206-{ 
     207-  alloc->Free(alloc, p->dic); 
     208-  p->dic = 0; 
     209-} 
     210- 
    176211-void LzmaDec_Free(CLzmaDec *p, ISzAlloc *alloc) 
    177 +static void __maybe_unused LzmaDec_Free(CLzmaDec *p, ISzAlloc *alloc) 
    178  { 
    179    LzmaDec_FreeProbs(p, alloc); 
    180    LzmaDec_FreeDict(p, alloc); 
    181  } 
    182   
     212-{ 
     213-  LzmaDec_FreeProbs(p, alloc); 
     214-  LzmaDec_FreeDict(p, alloc); 
     215-} 
     216- 
    183217-SRes LzmaProps_Decode(CLzmaProps *p, const Byte *data, unsigned size) 
    184218+static SRes LzmaProps_Decode(CLzmaProps *p, const Byte *data, unsigned size) 
     
    186220   UInt32 dicSize; 
    187221   Byte d; 
    188 @@ -935,7 +935,7 @@ static SRes LzmaDec_AllocateProbs2(CLzma 
     222@@ -935,33 +883,11 @@ static SRes LzmaDec_AllocateProbs2(CLzma 
    189223   return SZ_OK; 
    190224 } 
    191225  
    192226-SRes LzmaDec_AllocateProbs(CLzmaDec *p, const Byte *props, unsigned propsSize, ISzAlloc *alloc) 
    193 +static SRes __maybe_unused LzmaDec_AllocateProbs(CLzmaDec *p, const Byte *props, unsigned propsSize, ISzAlloc *alloc) 
     227-{ 
     228-  CLzmaProps propNew; 
     229-  RINOK(LzmaProps_Decode(&propNew, props, propsSize)); 
     230-  RINOK(LzmaDec_AllocateProbs2(p, &propNew, alloc)); 
     231-  p->prop = propNew; 
     232-  return SZ_OK; 
     233-} 
     234- 
     235-SRes LzmaDec_Allocate(CLzmaDec *p, const Byte *props, unsigned propsSize, ISzAlloc *alloc) 
     236+static SRes LzmaDec_AllocateProbs(CLzmaDec *p, const Byte *props, unsigned propsSize, ISzAlloc *alloc) 
    194237 { 
    195238   CLzmaProps propNew; 
     239-  SizeT dicBufSize; 
    196240   RINOK(LzmaProps_Decode(&propNew, props, propsSize)); 
    197 @@ -944,7 +944,7 @@ SRes LzmaDec_AllocateProbs(CLzmaDec *p, 
     241   RINOK(LzmaDec_AllocateProbs2(p, &propNew, alloc)); 
     242-  dicBufSize = propNew.dicSize; 
     243-  if (p->dic == 0 || dicBufSize != p->dicBufSize) 
     244-  { 
     245-    LzmaDec_FreeDict(p, alloc); 
     246-    p->dic = (Byte *)alloc->Alloc(alloc, dicBufSize); 
     247-    if (p->dic == 0) 
     248-    { 
     249-      LzmaDec_FreeProbs(p, alloc); 
     250-      return SZ_ERROR_MEM; 
     251-    } 
     252-  } 
     253-  p->dicBufSize = dicBufSize; 
     254   p->prop = propNew; 
    198255   return SZ_OK; 
    199256 } 
    200   
    201 -SRes LzmaDec_Allocate(CLzmaDec *p, const Byte *props, unsigned propsSize, ISzAlloc *alloc) 
    202 +static SRes __maybe_unused LzmaDec_Allocate(CLzmaDec *p, const Byte *props, unsigned propsSize, ISzAlloc *alloc) 
    203  { 
    204    CLzmaProps propNew; 
    205    SizeT dicBufSize; 
    206257--- a/include/linux/lzma/LzmaEnc.h 
    207258+++ b/include/linux/lzma/LzmaEnc.h 
     
    281332   int c = 2, slotFast; 
    282333   g_FastPos[0] = 0; 
    283 @@ -339,7 +339,7 @@ typedef struct 
     334@@ -339,58 +339,6 @@ typedef struct 
    284335   CSaveState saveState; 
    285336 } CLzmaEnc; 
    286337  
    287338-void LzmaEnc_SaveState(CLzmaEncHandle pp) 
    288 +static void __maybe_unused LzmaEnc_SaveState(CLzmaEncHandle pp) 
     339-{ 
     340-  CLzmaEnc *p = (CLzmaEnc *)pp; 
     341-  CSaveState *dest = &p->saveState; 
     342-  int i; 
     343-  dest->lenEnc = p->lenEnc; 
     344-  dest->repLenEnc = p->repLenEnc; 
     345-  dest->state = p->state; 
     346- 
     347-  for (i = 0; i < kNumStates; i++) 
     348-  { 
     349-    memcpy(dest->isMatch[i], p->isMatch[i], sizeof(p->isMatch[i])); 
     350-    memcpy(dest->isRep0Long[i], p->isRep0Long[i], sizeof(p->isRep0Long[i])); 
     351-  } 
     352-  for (i = 0; i < kNumLenToPosStates; i++) 
     353-    memcpy(dest->posSlotEncoder[i], p->posSlotEncoder[i], sizeof(p->posSlotEncoder[i])); 
     354-  memcpy(dest->isRep, p->isRep, sizeof(p->isRep)); 
     355-  memcpy(dest->isRepG0, p->isRepG0, sizeof(p->isRepG0)); 
     356-  memcpy(dest->isRepG1, p->isRepG1, sizeof(p->isRepG1)); 
     357-  memcpy(dest->isRepG2, p->isRepG2, sizeof(p->isRepG2)); 
     358-  memcpy(dest->posEncoders, p->posEncoders, sizeof(p->posEncoders)); 
     359-  memcpy(dest->posAlignEncoder, p->posAlignEncoder, sizeof(p->posAlignEncoder)); 
     360-  memcpy(dest->reps, p->reps, sizeof(p->reps)); 
     361-  memcpy(dest->litProbs, p->litProbs, (0x300 << p->lclp) * sizeof(CLzmaProb)); 
     362-} 
     363- 
     364-void LzmaEnc_RestoreState(CLzmaEncHandle pp) 
     365-{ 
     366-  CLzmaEnc *dest = (CLzmaEnc *)pp; 
     367-  const CSaveState *p = &dest->saveState; 
     368-  int i; 
     369-  dest->lenEnc = p->lenEnc; 
     370-  dest->repLenEnc = p->repLenEnc; 
     371-  dest->state = p->state; 
     372- 
     373-  for (i = 0; i < kNumStates; i++) 
     374-  { 
     375-    memcpy(dest->isMatch[i], p->isMatch[i], sizeof(p->isMatch[i])); 
     376-    memcpy(dest->isRep0Long[i], p->isRep0Long[i], sizeof(p->isRep0Long[i])); 
     377-  } 
     378-  for (i = 0; i < kNumLenToPosStates; i++) 
     379-    memcpy(dest->posSlotEncoder[i], p->posSlotEncoder[i], sizeof(p->posSlotEncoder[i])); 
     380-  memcpy(dest->isRep, p->isRep, sizeof(p->isRep)); 
     381-  memcpy(dest->isRepG0, p->isRepG0, sizeof(p->isRepG0)); 
     382-  memcpy(dest->isRepG1, p->isRepG1, sizeof(p->isRepG1)); 
     383-  memcpy(dest->isRepG2, p->isRepG2, sizeof(p->isRepG2)); 
     384-  memcpy(dest->posEncoders, p->posEncoders, sizeof(p->posEncoders)); 
     385-  memcpy(dest->posAlignEncoder, p->posAlignEncoder, sizeof(p->posAlignEncoder)); 
     386-  memcpy(dest->reps, p->reps, sizeof(p->reps)); 
     387-  memcpy(dest->litProbs, p->litProbs, (0x300 << dest->lclp) * sizeof(CLzmaProb)); 
     388-} 
     389- 
     390 SRes LzmaEnc_SetProps(CLzmaEncHandle pp, const CLzmaEncProps *props2) 
    289391 { 
    290392   CLzmaEnc *p = (CLzmaEnc *)pp; 
    291    CSaveState *dest = &p->saveState; 
    292 @@ -365,7 +365,7 @@ void LzmaEnc_SaveState(CLzmaEncHandle pp 
    293    memcpy(dest->litProbs, p->litProbs, (0x300 << p->lclp) * sizeof(CLzmaProb)); 
    294  } 
    295   
    296 -void LzmaEnc_RestoreState(CLzmaEncHandle pp) 
    297 +static void __maybe_unused LzmaEnc_RestoreState(CLzmaEncHandle pp) 
    298  { 
    299    CLzmaEnc *dest = (CLzmaEnc *)pp; 
    300    const CSaveState *p = &dest->saveState; 
    301 @@ -600,7 +600,7 @@ static void LitEnc_EncodeMatched(CRangeE 
     393@@ -600,7 +548,7 @@ static void LitEnc_EncodeMatched(CRangeE 
    302394   while (symbol < 0x10000); 
    303395 } 
     
    308400   UInt32 i; 
    309401   for (i = (1 << kNumMoveReducingBits) / 2; i < kBitModelTotal; i += (1 << kNumMoveReducingBits)) 
    310 @@ -1676,7 +1676,7 @@ static void FillDistancesPrices(CLzmaEnc 
     402@@ -1676,7 +1624,7 @@ static void FillDistancesPrices(CLzmaEnc 
    311403   p->matchPriceCount = 0; 
    312404 } 
     
    317409   RangeEnc_Construct(&p->rc); 
    318410   MatchFinder_Construct(&p->matchFinderBase); 
    319 @@ -1709,7 +1709,7 @@ CLzmaEncHandle LzmaEnc_Create(ISzAlloc * 
     411@@ -1709,7 +1657,7 @@ CLzmaEncHandle LzmaEnc_Create(ISzAlloc * 
    320412   return p; 
    321413 } 
     
    326418   alloc->Free(alloc, p->litProbs); 
    327419   alloc->Free(alloc, p->saveState.litProbs); 
    328 @@ -2074,7 +2074,7 @@ SRes LzmaEnc_MemPrepare(CLzmaEncHandle p 
     420@@ -1717,7 +1665,7 @@ void LzmaEnc_FreeLits(CLzmaEnc *p, ISzAl 
     421   p->saveState.litProbs = 0; 
     422 } 
     423  
     424-void LzmaEnc_Destruct(CLzmaEnc *p, ISzAlloc *alloc, ISzAlloc *allocBig) 
     425+static void LzmaEnc_Destruct(CLzmaEnc *p, ISzAlloc *alloc, ISzAlloc *allocBig) 
     426 { 
     427   #ifndef _7ZIP_ST 
     428   MatchFinderMt_Destruct(&p->matchFinderMt, allocBig); 
     429@@ -1947,7 +1895,7 @@ static SRes LzmaEnc_Alloc(CLzmaEnc *p, U 
     430   return SZ_OK; 
     431 } 
     432  
     433-void LzmaEnc_Init(CLzmaEnc *p) 
     434+static void LzmaEnc_Init(CLzmaEnc *p) 
     435 { 
     436   UInt32 i; 
     437   p->state = 0; 
     438@@ -2005,7 +1953,7 @@ void LzmaEnc_Init(CLzmaEnc *p) 
     439   p->lpMask = (1 << p->lp) - 1; 
     440 } 
     441  
     442-void LzmaEnc_InitPrices(CLzmaEnc *p) 
     443+static void LzmaEnc_InitPrices(CLzmaEnc *p) 
     444 { 
     445   if (!p->fastMode) 
     446   { 
     447@@ -2037,26 +1985,6 @@ static SRes LzmaEnc_AllocAndInit(CLzmaEn 
     448   return SZ_OK; 
     449 } 
     450  
     451-static SRes LzmaEnc_Prepare(CLzmaEncHandle pp, ISeqOutStream *outStream, ISeqInStream *inStream, 
     452-    ISzAlloc *alloc, ISzAlloc *allocBig) 
     453-{ 
     454-  CLzmaEnc *p = (CLzmaEnc *)pp; 
     455-  p->matchFinderBase.stream = inStream; 
     456-  p->needInit = 1; 
     457-  p->rc.outStream = outStream; 
     458-  return LzmaEnc_AllocAndInit(p, 0, alloc, allocBig); 
     459-} 
     460- 
     461-SRes LzmaEnc_PrepareForLzma2(CLzmaEncHandle pp, 
     462-    ISeqInStream *inStream, UInt32 keepWindowSize, 
     463-    ISzAlloc *alloc, ISzAlloc *allocBig) 
     464-{ 
     465-  CLzmaEnc *p = (CLzmaEnc *)pp; 
     466-  p->matchFinderBase.stream = inStream; 
     467-  p->needInit = 1; 
     468-  return LzmaEnc_AllocAndInit(p, keepWindowSize, alloc, allocBig); 
     469-} 
     470- 
     471 static void LzmaEnc_SetInputBuf(CLzmaEnc *p, const Byte *src, SizeT srcLen) 
     472 { 
     473   p->matchFinderBase.directInput = 1; 
     474@@ -2064,7 +1992,7 @@ static void LzmaEnc_SetInputBuf(CLzmaEnc 
     475   p->matchFinderBase.directInputRem = srcLen; 
     476 } 
     477  
     478-SRes LzmaEnc_MemPrepare(CLzmaEncHandle pp, const Byte *src, SizeT srcLen, 
     479+static SRes LzmaEnc_MemPrepare(CLzmaEncHandle pp, const Byte *src, SizeT srcLen, 
     480     UInt32 keepWindowSize, ISzAlloc *alloc, ISzAlloc *allocBig) 
     481 { 
     482   CLzmaEnc *p = (CLzmaEnc *)pp; 
     483@@ -2074,7 +2002,7 @@ SRes LzmaEnc_MemPrepare(CLzmaEncHandle p 
    329484   return LzmaEnc_AllocAndInit(p, keepWindowSize, alloc, allocBig); 
    330485 } 
     
    335490   #ifndef _7ZIP_ST 
    336491   CLzmaEnc *p = (CLzmaEnc *)pp; 
    337 @@ -2108,7 +2108,7 @@ static size_t MyWrite(void *pp, const vo 
    338  } 
    339   
    340   
     492@@ -2107,53 +2035,6 @@ static size_t MyWrite(void *pp, const vo 
     493   return size; 
     494 } 
     495  
     496- 
    341497-UInt32 LzmaEnc_GetNumAvailableBytes(CLzmaEncHandle pp) 
    342 +static UInt32 __maybe_unused LzmaEnc_GetNumAvailableBytes(CLzmaEncHandle pp) 
    343  { 
    344    const CLzmaEnc *p = (CLzmaEnc *)pp; 
    345    return p->matchFinder.GetNumAvailableBytes(p->matchFinderObj); 
    346 @@ -2120,7 +2120,7 @@ const Byte *LzmaEnc_GetCurBuf(CLzmaEncHa 
    347    return p->matchFinder.GetPointerToCurrentPos(p->matchFinderObj) - p->additionalOffset; 
    348  } 
    349   
     498-{ 
     499-  const CLzmaEnc *p = (CLzmaEnc *)pp; 
     500-  return p->matchFinder.GetNumAvailableBytes(p->matchFinderObj); 
     501-} 
     502- 
     503-const Byte *LzmaEnc_GetCurBuf(CLzmaEncHandle pp) 
     504-{ 
     505-  const CLzmaEnc *p = (CLzmaEnc *)pp; 
     506-  return p->matchFinder.GetPointerToCurrentPos(p->matchFinderObj) - p->additionalOffset; 
     507-} 
     508- 
    350509-SRes LzmaEnc_CodeOneMemBlock(CLzmaEncHandle pp, Bool reInit, 
    351 +static SRes __maybe_unused LzmaEnc_CodeOneMemBlock(CLzmaEncHandle pp, Bool reInit, 
    352      Byte *dest, size_t *destLen, UInt32 desiredPackSize, UInt32 *unpackSize) 
     510-    Byte *dest, size_t *destLen, UInt32 desiredPackSize, UInt32 *unpackSize) 
     511-{ 
     512-  CLzmaEnc *p = (CLzmaEnc *)pp; 
     513-  UInt64 nowPos64; 
     514-  SRes res; 
     515-  CSeqOutStreamBuf outStream; 
     516- 
     517-  outStream.funcTable.Write = MyWrite; 
     518-  outStream.data = dest; 
     519-  outStream.rem = *destLen; 
     520-  outStream.overflow = False; 
     521- 
     522-  p->writeEndMark = False; 
     523-  p->finished = False; 
     524-  p->result = SZ_OK; 
     525- 
     526-  if (reInit) 
     527-    LzmaEnc_Init(p); 
     528-  LzmaEnc_InitPrices(p); 
     529-  nowPos64 = p->nowPos64; 
     530-  RangeEnc_Init(&p->rc); 
     531-  p->rc.outStream = &outStream.funcTable; 
     532- 
     533-  res = LzmaEnc_CodeOneBlock(p, True, desiredPackSize, *unpackSize); 
     534 
     535-  *unpackSize = (UInt32)(p->nowPos64 - nowPos64); 
     536-  *destLen -= outStream.rem; 
     537-  if (outStream.overflow) 
     538-    return SZ_ERROR_OUTPUT_EOF; 
     539- 
     540-  return res; 
     541-} 
     542- 
     543 static SRes LzmaEnc_Encode2(CLzmaEnc *p, ICompressProgress *progress) 
     544 { 
     545   SRes res = SZ_OK; 
     546@@ -2184,13 +2065,6 @@ static SRes LzmaEnc_Encode2(CLzmaEnc *p, 
     547   return res; 
     548 } 
     549  
     550-SRes LzmaEnc_Encode(CLzmaEncHandle pp, ISeqOutStream *outStream, ISeqInStream *inStream, ICompressProgress *progress, 
     551-    ISzAlloc *alloc, ISzAlloc *allocBig) 
     552-{ 
     553-  RINOK(LzmaEnc_Prepare(pp, outStream, inStream, alloc, allocBig)); 
     554-  return LzmaEnc_Encode2((CLzmaEnc *)pp, progress); 
     555-} 
     556- 
     557 SRes LzmaEnc_WriteProperties(CLzmaEncHandle pp, Byte *props, SizeT *size) 
    353558 { 
    354559   CLzmaEnc *p = (CLzmaEnc *)pp; 
    355 @@ -2248,7 +2248,7 @@ SRes LzmaEnc_MemEncode(CLzmaEncHandle pp 
     560@@ -2247,25 +2121,3 @@ SRes LzmaEnc_MemEncode(CLzmaEncHandle pp 
     561     return SZ_ERROR_OUTPUT_EOF; 
    356562   return res; 
    357563 } 
    358   
     564- 
    359565-SRes LzmaEncode(Byte *dest, SizeT *destLen, const Byte *src, SizeT srcLen, 
    360 +static __maybe_unused SRes LzmaEncode(Byte *dest, SizeT *destLen, const Byte *src, SizeT srcLen, 
    361      const CLzmaEncProps *props, Byte *propsEncoded, SizeT *propsSize, int writeEndMark, 
    362      ICompressProgress *progress, ISzAlloc *alloc, ISzAlloc *allocBig) 
    363  { 
     566-    const CLzmaEncProps *props, Byte *propsEncoded, SizeT *propsSize, int writeEndMark, 
     567-    ICompressProgress *progress, ISzAlloc *alloc, ISzAlloc *allocBig) 
     568-{ 
     569-  CLzmaEnc *p = (CLzmaEnc *)LzmaEnc_Create(alloc); 
     570-  SRes res; 
     571-  if (p == 0) 
     572-    return SZ_ERROR_MEM; 
     573- 
     574-  res = LzmaEnc_SetProps(p, props); 
     575-  if (res == SZ_OK) 
     576-  { 
     577-    res = LzmaEnc_WriteProperties(p, propsEncoded, propsSize); 
     578-    if (res == SZ_OK) 
     579-      res = LzmaEnc_MemEncode(p, dest, destLen, src, srcLen, 
     580-          writeEndMark, progress, alloc, allocBig); 
     581-  } 
     582- 
     583-  LzmaEnc_Destroy(p, alloc, allocBig); 
     584-  return res; 
     585-} 
    364586--- a/include/linux/lzma/LzFind.h 
    365587+++ b/include/linux/lzma/LzFind.h 
     
    376598  
    377599 /* Conditions: 
    378 @@ -70,12 +65,6 @@ int MatchFinder_Create(CMatchFinder *p, 
     600@@ -70,12 +65,6 @@ int MatchFinder_Create(CMatchFinder *p,  
    379601     UInt32 keepAddBufferBefore, UInt32 matchMaxLen, UInt32 keepAddBufferAfter, 
    380602     ISzAlloc *alloc); 
     
    404626--- a/lib/lzma/LzFind.c 
    405627+++ b/lib/lzma/LzFind.c 
    406 @@ -42,12 +42,12 @@ static int LzInWindow_Create(CMatchFinde 
     628@@ -14,9 +14,15 @@ 
     629  
     630 #define kStartMaxLen 3 
     631  
     632+#if 0 
     633+#define DIRECT_INPUT   p->directInput 
     634+#else 
     635+#define DIRECT_INPUT   1 
     636+#endif 
     637+ 
     638 static void LzInWindow_Free(CMatchFinder *p, ISzAlloc *alloc) 
     639 { 
     640-  if (!p->directInput) 
     641+  if (!DIRECT_INPUT) 
     642   { 
     643     alloc->Free(alloc, p->bufferBase); 
     644     p->bufferBase = 0; 
     645@@ -28,7 +34,7 @@ static void LzInWindow_Free(CMatchFinder 
     646 static int LzInWindow_Create(CMatchFinder *p, UInt32 keepSizeReserv, ISzAlloc *alloc) 
     647 { 
     648   UInt32 blockSize = p->keepSizeBefore + p->keepSizeAfter + keepSizeReserv; 
     649-  if (p->directInput) 
     650+  if (DIRECT_INPUT) 
     651   { 
     652     p->blockSize = blockSize; 
     653     return 1; 
     654@@ -42,12 +48,12 @@ static int LzInWindow_Create(CMatchFinde 
    407655   return (p->bufferBase != 0); 
    408656 } 
     
    421669   p->posLimit -= subValue; 
    422670   p->pos -= subValue; 
    423 @@ -268,7 +268,7 @@ static void MatchFinder_SetLimits(CMatch 
     671@@ -58,7 +64,7 @@ static void MatchFinder_ReadBlock(CMatch 
     672 { 
     673   if (p->streamEndWasReached || p->result != SZ_OK) 
     674     return; 
     675-  if (p->directInput) 
     676+  if (DIRECT_INPUT) 
     677   { 
     678     UInt32 curSize = 0xFFFFFFFF - p->streamPos; 
     679     if (curSize > p->directInputRem) 
     680@@ -89,7 +95,7 @@ static void MatchFinder_ReadBlock(CMatch 
     681   } 
     682 } 
     683  
     684-void MatchFinder_MoveBlock(CMatchFinder *p) 
     685+static void MatchFinder_MoveBlock(CMatchFinder *p) 
     686 { 
     687   memmove(p->bufferBase, 
     688     p->buffer - p->keepSizeBefore, 
     689@@ -97,22 +103,14 @@ void MatchFinder_MoveBlock(CMatchFinder  
     690   p->buffer = p->bufferBase + p->keepSizeBefore; 
     691 } 
     692  
     693-int MatchFinder_NeedMove(CMatchFinder *p) 
     694+static int MatchFinder_NeedMove(CMatchFinder *p) 
     695 { 
     696-  if (p->directInput) 
     697+  if (DIRECT_INPUT) 
     698     return 0; 
     699   /* if (p->streamEndWasReached) return 0; */ 
     700   return ((size_t)(p->bufferBase + p->blockSize - p->buffer) <= p->keepSizeAfter); 
     701 } 
     702  
     703-void MatchFinder_ReadIfRequired(CMatchFinder *p) 
     704-{ 
     705-  if (p->streamEndWasReached) 
     706-    return; 
     707-  if (p->keepSizeAfter >= p->streamPos - p->pos) 
     708-    MatchFinder_ReadBlock(p); 
     709-} 
     710- 
     711 static void MatchFinder_CheckAndMoveAndRead(CMatchFinder *p) 
     712 { 
     713   if (MatchFinder_NeedMove(p)) 
     714@@ -268,7 +266,7 @@ static void MatchFinder_SetLimits(CMatch 
    424715   p->posLimit = p->pos + limit; 
    425716 } 
     
    430721   UInt32 i; 
    431722   for (i = 0; i < p->hashSizeSum; i++) 
    432 @@ -287,7 +287,7 @@ static UInt32 MatchFinder_GetSubValue(CM 
     723@@ -287,7 +285,7 @@ static UInt32 MatchFinder_GetSubValue(CM 
    433724   return (p->pos - p->historySize - 1) & kNormalizeMask; 
    434725 } 
     
    439730   UInt32 i; 
    440731   for (i = 0; i < numItems; i++) 
    441 @@ -350,7 +350,7 @@ static UInt32 * Hc_GetMatchesSpec(UInt32 
    442    } 
    443  } 
    444   
     732@@ -319,38 +317,7 @@ static void MatchFinder_CheckLimits(CMat 
     733   MatchFinder_SetLimits(p); 
     734 } 
     735  
     736-static UInt32 * Hc_GetMatchesSpec(UInt32 lenLimit, UInt32 curMatch, UInt32 pos, const Byte *cur, CLzRef *son, 
     737-    UInt32 _cyclicBufferPos, UInt32 _cyclicBufferSize, UInt32 cutValue, 
     738-    UInt32 *distances, UInt32 maxLen) 
     739-{ 
     740-  son[_cyclicBufferPos] = curMatch; 
     741-  for (;;) 
     742-  { 
     743-    UInt32 delta = pos - curMatch; 
     744-    if (cutValue-- == 0 || delta >= _cyclicBufferSize) 
     745-      return distances; 
     746-    { 
     747-      const Byte *pb = cur - delta; 
     748-      curMatch = son[_cyclicBufferPos - delta + ((delta > _cyclicBufferPos) ? _cyclicBufferSize : 0)]; 
     749-      if (pb[maxLen] == cur[maxLen] && *pb == *cur) 
     750-      { 
     751-        UInt32 len = 0; 
     752-        while (++len != lenLimit) 
     753-          if (pb[len] != cur[len]) 
     754-            break; 
     755-        if (maxLen < len) 
     756-        { 
     757-          *distances++ = maxLen = len; 
     758-          *distances++ = delta - 1; 
     759-          if (len == lenLimit) 
     760-            return distances; 
     761-        } 
     762-      } 
     763-    } 
     764-  } 
     765-} 
     766- 
    445767-UInt32 * GetMatchesSpec1(UInt32 lenLimit, UInt32 curMatch, UInt32 pos, const Byte *cur, CLzRef *son, 
    446768+static UInt32 * GetMatchesSpec1(UInt32 lenLimit, UInt32 curMatch, UInt32 pos, const Byte *cur, CLzRef *son, 
     
    448770     UInt32 *distances, UInt32 maxLen) 
    449771 { 
    450 @@ -492,7 +492,7 @@ static UInt32 Bt2_MatchFinder_GetMatches 
    451    GET_MATCHES_FOOTER(offset, 1) 
    452  } 
    453   
     772@@ -460,10 +427,10 @@ static void SkipMatchesSpec(UInt32 lenLi 
     773   p->buffer++; \ 
     774   if (++p->pos == p->posLimit) MatchFinder_CheckLimits(p); 
     775  
     776-#define MOVE_POS_RET MOVE_POS return offset; 
     777- 
     778 static void MatchFinder_MovePos(CMatchFinder *p) { MOVE_POS; } 
     779  
     780+#define MOVE_POS_RET MatchFinder_MovePos(p); return offset; 
     781+ 
     782 #define GET_MATCHES_HEADER2(minLen, ret_op) \ 
     783   UInt32 lenLimit; UInt32 hashValue; const Byte *cur; UInt32 curMatch; \ 
     784   lenLimit = p->lenLimit; { if (lenLimit < minLen) { MatchFinder_MovePos(p); ret_op; }} \ 
     785@@ -479,62 +446,7 @@ static void MatchFinder_MovePos(CMatchFi 
     786   distances + offset, maxLen) - distances); MOVE_POS_RET; 
     787  
     788 #define SKIP_FOOTER \ 
     789-  SkipMatchesSpec(lenLimit, curMatch, MF_PARAMS(p)); MOVE_POS; 
     790- 
     791-static UInt32 Bt2_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances) 
     792-{ 
     793-  UInt32 offset; 
     794-  GET_MATCHES_HEADER(2) 
     795-  HASH2_CALC; 
     796-  curMatch = p->hash[hashValue]; 
     797-  p->hash[hashValue] = p->pos; 
     798-  offset = 0; 
     799-  GET_MATCHES_FOOTER(offset, 1) 
     800-} 
     801- 
    454802-UInt32 Bt3Zip_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances) 
    455 +static __maybe_unused UInt32 Bt3Zip_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances) 
    456  { 
    457    UInt32 offset; 
    458    GET_MATCHES_HEADER(3) 
    459 @@ -632,7 +632,7 @@ static UInt32 Hc4_MatchFinder_GetMatches 
    460    MOVE_POS_RET 
    461  } 
    462   
     803-{ 
     804-  UInt32 offset; 
     805-  GET_MATCHES_HEADER(3) 
     806-  HASH_ZIP_CALC; 
     807-  curMatch = p->hash[hashValue]; 
     808-  p->hash[hashValue] = p->pos; 
     809-  offset = 0; 
     810-  GET_MATCHES_FOOTER(offset, 2) 
     811-} 
     812- 
     813-static UInt32 Bt3_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances) 
     814-{ 
     815-  UInt32 hash2Value, delta2, maxLen, offset; 
     816-  GET_MATCHES_HEADER(3) 
     817- 
     818-  HASH3_CALC; 
     819- 
     820-  delta2 = p->pos - p->hash[hash2Value]; 
     821-  curMatch = p->hash[kFix3HashSize + hashValue]; 
     822 
     823-  p->hash[hash2Value] = 
     824-  p->hash[kFix3HashSize + hashValue] = p->pos; 
     825- 
     826- 
     827-  maxLen = 2; 
     828-  offset = 0; 
     829-  if (delta2 < p->cyclicBufferSize && *(cur - delta2) == *cur) 
     830-  { 
     831-    for (; maxLen != lenLimit; maxLen++) 
     832-      if (cur[(ptrdiff_t)maxLen - delta2] != cur[maxLen]) 
     833-        break; 
     834-    distances[0] = maxLen; 
     835-    distances[1] = delta2 - 1; 
     836-    offset = 2; 
     837-    if (maxLen == lenLimit) 
     838-    { 
     839-      SkipMatchesSpec(lenLimit, curMatch, MF_PARAMS(p)); 
     840-      MOVE_POS_RET; 
     841-    } 
     842-  } 
     843-  GET_MATCHES_FOOTER(offset, maxLen) 
     844-} 
     845+  SkipMatchesSpec(lenLimit, curMatch, MF_PARAMS(p)); MatchFinder_MovePos(p); 
     846  
     847 static UInt32 Bt4_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances) 
     848 { 
     849@@ -583,108 +495,6 @@ static UInt32 Bt4_MatchFinder_GetMatches 
     850   GET_MATCHES_FOOTER(offset, maxLen) 
     851 } 
     852  
     853-static UInt32 Hc4_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances) 
     854-{ 
     855-  UInt32 hash2Value, hash3Value, delta2, delta3, maxLen, offset; 
     856-  GET_MATCHES_HEADER(4) 
     857- 
     858-  HASH4_CALC; 
     859- 
     860-  delta2 = p->pos - p->hash[                hash2Value]; 
     861-  delta3 = p->pos - p->hash[kFix3HashSize + hash3Value]; 
     862-  curMatch = p->hash[kFix4HashSize + hashValue]; 
     863- 
     864-  p->hash[                hash2Value] = 
     865-  p->hash[kFix3HashSize + hash3Value] = 
     866-  p->hash[kFix4HashSize + hashValue] = p->pos; 
     867- 
     868-  maxLen = 1; 
     869-  offset = 0; 
     870-  if (delta2 < p->cyclicBufferSize && *(cur - delta2) == *cur) 
     871-  { 
     872-    distances[0] = maxLen = 2; 
     873-    distances[1] = delta2 - 1; 
     874-    offset = 2; 
     875-  } 
     876-  if (delta2 != delta3 && delta3 < p->cyclicBufferSize && *(cur - delta3) == *cur) 
     877-  { 
     878-    maxLen = 3; 
     879-    distances[offset + 1] = delta3 - 1; 
     880-    offset += 2; 
     881-    delta2 = delta3; 
     882-  } 
     883-  if (offset != 0) 
     884-  { 
     885-    for (; maxLen != lenLimit; maxLen++) 
     886-      if (cur[(ptrdiff_t)maxLen - delta2] != cur[maxLen]) 
     887-        break; 
     888-    distances[offset - 2] = maxLen; 
     889-    if (maxLen == lenLimit) 
     890-    { 
     891-      p->son[p->cyclicBufferPos] = curMatch; 
     892-      MOVE_POS_RET; 
     893-    } 
     894-  } 
     895-  if (maxLen < 3) 
     896-    maxLen = 3; 
     897-  offset = (UInt32)(Hc_GetMatchesSpec(lenLimit, curMatch, MF_PARAMS(p), 
     898-    distances + offset, maxLen) - (distances)); 
     899-  MOVE_POS_RET 
     900-} 
     901- 
    463902-UInt32 Hc3Zip_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances) 
    464 +static __maybe_unused UInt32 Hc3Zip_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances) 
    465  { 
    466    UInt32 offset; 
    467    GET_MATCHES_HEADER(3) 
    468 @@ -657,7 +657,7 @@ static void Bt2_MatchFinder_Skip(CMatchF 
     903-{ 
     904-  UInt32 offset; 
     905-  GET_MATCHES_HEADER(3) 
     906-  HASH_ZIP_CALC; 
     907-  curMatch = p->hash[hashValue]; 
     908-  p->hash[hashValue] = p->pos; 
     909-  offset = (UInt32)(Hc_GetMatchesSpec(lenLimit, curMatch, MF_PARAMS(p), 
     910-    distances, 2) - (distances)); 
     911-  MOVE_POS_RET 
     912-} 
     913- 
     914-static void Bt2_MatchFinder_Skip(CMatchFinder *p, UInt32 num) 
     915-{ 
     916-  do 
     917-  { 
     918-    SKIP_HEADER(2) 
     919-    HASH2_CALC; 
     920-    curMatch = p->hash[hashValue]; 
     921-    p->hash[hashValue] = p->pos; 
     922-    SKIP_FOOTER 
     923-  } 
     924-  while (--num != 0); 
     925-} 
     926- 
     927-void Bt3Zip_MatchFinder_Skip(CMatchFinder *p, UInt32 num) 
     928-{ 
     929-  do 
     930-  { 
     931-    SKIP_HEADER(3) 
     932-    HASH_ZIP_CALC; 
     933-    curMatch = p->hash[hashValue]; 
     934-    p->hash[hashValue] = p->pos; 
     935-    SKIP_FOOTER 
     936-  } 
     937-  while (--num != 0); 
     938-} 
     939- 
     940-static void Bt3_MatchFinder_Skip(CMatchFinder *p, UInt32 num) 
     941-{ 
     942-  do 
     943-  { 
     944-    UInt32 hash2Value; 
     945-    SKIP_HEADER(3) 
     946-    HASH3_CALC; 
     947-    curMatch = p->hash[kFix3HashSize + hashValue]; 
     948-    p->hash[hash2Value] = 
     949-    p->hash[kFix3HashSize + hashValue] = p->pos; 
     950-    SKIP_FOOTER 
     951-  } 
     952-  while (--num != 0); 
     953-} 
     954- 
     955 static void Bt4_MatchFinder_Skip(CMatchFinder *p, UInt32 num) 
     956 { 
     957   do 
     958@@ -701,61 +511,12 @@ static void Bt4_MatchFinder_Skip(CMatchF 
    469959   while (--num != 0); 
    470960 } 
    471961  
    472 -void Bt3Zip_MatchFinder_Skip(CMatchFinder *p, UInt32 num) 
    473 +static __maybe_unused void Bt3Zip_MatchFinder_Skip(CMatchFinder *p, UInt32 num) 
    474  { 
    475    do 
    476    { 
    477 @@ -718,7 +718,7 @@ static void Hc4_MatchFinder_Skip(CMatchF 
    478    while (--num != 0); 
    479  } 
    480   
     962-static void Hc4_MatchFinder_Skip(CMatchFinder *p, UInt32 num) 
     963-{ 
     964-  do 
     965-  { 
     966-    UInt32 hash2Value, hash3Value; 
     967-    SKIP_HEADER(4) 
     968-    HASH4_CALC; 
     969-    curMatch = p->hash[kFix4HashSize + hashValue]; 
     970-    p->hash[                hash2Value] = 
     971-    p->hash[kFix3HashSize + hash3Value] = 
     972-    p->hash[kFix4HashSize + hashValue] = p->pos; 
     973-    p->son[p->cyclicBufferPos] = curMatch; 
     974-    MOVE_POS 
     975-  } 
     976-  while (--num != 0); 
     977-} 
     978- 
    481979-void Hc3Zip_MatchFinder_Skip(CMatchFinder *p, UInt32 num) 
    482 +static __maybe_unused void Hc3Zip_MatchFinder_Skip(CMatchFinder *p, UInt32 num) 
    483  { 
    484    do 
    485    { 
     980-{ 
     981-  do 
     982-  { 
     983-    SKIP_HEADER(3) 
     984-    HASH_ZIP_CALC; 
     985-    curMatch = p->hash[hashValue]; 
     986-    p->hash[hashValue] = p->pos; 
     987-    p->son[p->cyclicBufferPos] = curMatch; 
     988-    MOVE_POS 
     989-  } 
     990-  while (--num != 0); 
     991-} 
     992- 
     993 void MatchFinder_CreateVTable(CMatchFinder *p, IMatchFinder *vTable) 
     994 { 
     995   vTable->Init = (Mf_Init_Func)MatchFinder_Init; 
     996   vTable->GetIndexByte = (Mf_GetIndexByte_Func)MatchFinder_GetIndexByte; 
     997   vTable->GetNumAvailableBytes = (Mf_GetNumAvailableBytes_Func)MatchFinder_GetNumAvailableBytes; 
     998   vTable->GetPointerToCurrentPos = (Mf_GetPointerToCurrentPos_Func)MatchFinder_GetPointerToCurrentPos; 
     999-  if (!p->btMode) 
     1000-  { 
     1001-    vTable->GetMatches = (Mf_GetMatches_Func)Hc4_MatchFinder_GetMatches; 
     1002-    vTable->Skip = (Mf_Skip_Func)Hc4_MatchFinder_Skip; 
     1003-  } 
     1004-  else if (p->numHashBytes == 2) 
     1005-  { 
     1006-    vTable->GetMatches = (Mf_GetMatches_Func)Bt2_MatchFinder_GetMatches; 
     1007-    vTable->Skip = (Mf_Skip_Func)Bt2_MatchFinder_Skip; 
     1008-  } 
     1009-  else if (p->numHashBytes == 3) 
     1010-  { 
     1011-    vTable->GetMatches = (Mf_GetMatches_Func)Bt3_MatchFinder_GetMatches; 
     1012-    vTable->Skip = (Mf_Skip_Func)Bt3_MatchFinder_Skip; 
     1013-  } 
     1014-  else 
     1015-  { 
     1016-    vTable->GetMatches = (Mf_GetMatches_Func)Bt4_MatchFinder_GetMatches; 
     1017-    vTable->Skip = (Mf_Skip_Func)Bt4_MatchFinder_Skip; 
     1018-  } 
     1019+  vTable->GetMatches = (Mf_GetMatches_Func)Bt4_MatchFinder_GetMatches; 
     1020+  vTable->Skip = (Mf_Skip_Func)Bt4_MatchFinder_Skip; 
     1021 } 
  • trunk/target/linux/generic/patches-3.9/531-debloat_lzma.patch

    r36008 r37211  
    125125--- a/lib/lzma/LzmaDec.c 
    126126+++ b/lib/lzma/LzmaDec.c 
    127 @@ -682,7 +682,7 @@ static void LzmaDec_InitRc(CLzmaDec *p, 
     127@@ -682,7 +682,7 @@ static void LzmaDec_InitRc(CLzmaDec *p,  
    128128   p->needFlush = 0; 
    129129 } 
     
    152152 { 
    153153   SizeT inSize = *srcLen; 
    154 @@ -837,7 +837,7 @@ SRes LzmaDec_DecodeToDic(CLzmaDec *p, Si 
     154@@ -837,65 +837,13 @@ SRes LzmaDec_DecodeToDic(CLzmaDec *p, Si 
    155155   return (p->code == 0) ? SZ_OK : SZ_ERROR_DATA; 
    156156 } 
    157157  
    158158-SRes LzmaDec_DecodeToBuf(CLzmaDec *p, Byte *dest, SizeT *destLen, const Byte *src, SizeT *srcLen, ELzmaFinishMode finishMode, ELzmaStatus *status) 
    159 +static __maybe_unused SRes LzmaDec_DecodeToBuf(CLzmaDec *p, Byte *dest, SizeT *destLen, const Byte *src, SizeT *srcLen, ELzmaFinishMode finishMode, ELzmaStatus *status) 
    160  { 
    161    SizeT outSize = *destLen; 
    162    SizeT inSize = *srcLen; 
    163 @@ -877,7 +877,7 @@ SRes LzmaDec_DecodeToBuf(CLzmaDec *p, By 
    164    } 
    165  } 
    166   
     159-{ 
     160-  SizeT outSize = *destLen; 
     161-  SizeT inSize = *srcLen; 
     162-  *srcLen = *destLen = 0; 
     163-  for (;;) 
     164-  { 
     165-    SizeT inSizeCur = inSize, outSizeCur, dicPos; 
     166-    ELzmaFinishMode curFinishMode; 
     167-    SRes res; 
     168-    if (p->dicPos == p->dicBufSize) 
     169-      p->dicPos = 0; 
     170-    dicPos = p->dicPos; 
     171-    if (outSize > p->dicBufSize - dicPos) 
     172-    { 
     173-      outSizeCur = p->dicBufSize; 
     174-      curFinishMode = LZMA_FINISH_ANY; 
     175-    } 
     176-    else 
     177-    { 
     178-      outSizeCur = dicPos + outSize; 
     179-      curFinishMode = finishMode; 
     180-    } 
     181- 
     182-    res = LzmaDec_DecodeToDic(p, outSizeCur, src, &inSizeCur, curFinishMode, status); 
     183-    src += inSizeCur; 
     184-    inSize -= inSizeCur; 
     185-    *srcLen += inSizeCur; 
     186-    outSizeCur = p->dicPos - dicPos; 
     187-    memcpy(dest, p->dic + dicPos, outSizeCur); 
     188-    dest += outSizeCur; 
     189-    outSize -= outSizeCur; 
     190-    *destLen += outSizeCur; 
     191-    if (res != 0) 
     192-      return res; 
     193-    if (outSizeCur == 0 || outSize == 0) 
     194-      return SZ_OK; 
     195-  } 
     196-} 
     197- 
    167198-void LzmaDec_FreeProbs(CLzmaDec *p, ISzAlloc *alloc) 
    168199+static void LzmaDec_FreeProbs(CLzmaDec *p, ISzAlloc *alloc) 
     
    170201   alloc->Free(alloc, p->probs); 
    171202   p->probs = 0; 
    172 @@ -889,13 +889,13 @@ static void LzmaDec_FreeDict(CLzmaDec *p 
    173    p->dic = 0; 
    174  } 
    175   
     203 } 
     204  
     205-static void LzmaDec_FreeDict(CLzmaDec *p, ISzAlloc *alloc) 
     206-{ 
     207-  alloc->Free(alloc, p->dic); 
     208-  p->dic = 0; 
     209-} 
     210- 
    176211-void LzmaDec_Free(CLzmaDec *p, ISzAlloc *alloc) 
    177 +static void __maybe_unused LzmaDec_Free(CLzmaDec *p, ISzAlloc *alloc) 
    178  { 
    179    LzmaDec_FreeProbs(p, alloc); 
    180    LzmaDec_FreeDict(p, alloc); 
    181  } 
    182   
     212-{ 
     213-  LzmaDec_FreeProbs(p, alloc); 
     214-  LzmaDec_FreeDict(p, alloc); 
     215-} 
     216- 
    183217-SRes LzmaProps_Decode(CLzmaProps *p, const Byte *data, unsigned size) 
    184218+static SRes LzmaProps_Decode(CLzmaProps *p, const Byte *data, unsigned size) 
     
    186220   UInt32 dicSize; 
    187221   Byte d; 
    188 @@ -935,7 +935,7 @@ static SRes LzmaDec_AllocateProbs2(CLzma 
     222@@ -935,33 +883,11 @@ static SRes LzmaDec_AllocateProbs2(CLzma 
    189223   return SZ_OK; 
    190224 } 
    191225  
    192226-SRes LzmaDec_AllocateProbs(CLzmaDec *p, const Byte *props, unsigned propsSize, ISzAlloc *alloc) 
    193 +static SRes __maybe_unused LzmaDec_AllocateProbs(CLzmaDec *p, const Byte *props, unsigned propsSize, ISzAlloc *alloc) 
     227-{ 
     228-  CLzmaProps propNew; 
     229-  RINOK(LzmaProps_Decode(&propNew, props, propsSize)); 
     230-  RINOK(LzmaDec_AllocateProbs2(p, &propNew, alloc)); 
     231-  p->prop = propNew; 
     232-  return SZ_OK; 
     233-} 
     234- 
     235-SRes LzmaDec_Allocate(CLzmaDec *p, const Byte *props, unsigned propsSize, ISzAlloc *alloc) 
     236+static SRes LzmaDec_AllocateProbs(CLzmaDec *p, const Byte *props, unsigned propsSize, ISzAlloc *alloc) 
    194237 { 
    195238   CLzmaProps propNew; 
     239-  SizeT dicBufSize; 
    196240   RINOK(LzmaProps_Decode(&propNew, props, propsSize)); 
    197 @@ -944,7 +944,7 @@ SRes LzmaDec_AllocateProbs(CLzmaDec *p, 
     241   RINOK(LzmaDec_AllocateProbs2(p, &propNew, alloc)); 
     242-  dicBufSize = propNew.dicSize; 
     243-  if (p->dic == 0 || dicBufSize != p->dicBufSize) 
     244-  { 
     245-    LzmaDec_FreeDict(p, alloc); 
     246-    p->dic = (Byte *)alloc->Alloc(alloc, dicBufSize); 
     247-    if (p->dic == 0) 
     248-    { 
     249-      LzmaDec_FreeProbs(p, alloc); 
     250-      return SZ_ERROR_MEM; 
     251-    } 
     252-  } 
     253-  p->dicBufSize = dicBufSize; 
     254   p->prop = propNew; 
    198255   return SZ_OK; 
    199256 } 
    200   
    201 -SRes LzmaDec_Allocate(CLzmaDec *p, const Byte *props, unsigned propsSize, ISzAlloc *alloc) 
    202 +static SRes __maybe_unused LzmaDec_Allocate(CLzmaDec *p, const Byte *props, unsigned propsSize, ISzAlloc *alloc) 
    203  { 
    204    CLzmaProps propNew; 
    205    SizeT dicBufSize; 
    206257--- a/include/linux/lzma/LzmaEnc.h 
    207258+++ b/include/linux/lzma/LzmaEnc.h 
     
    281332   int c = 2, slotFast; 
    282333   g_FastPos[0] = 0; 
    283 @@ -339,7 +339,7 @@ typedef struct 
     334@@ -339,58 +339,6 @@ typedef struct 
    284335   CSaveState saveState; 
    285336 } CLzmaEnc; 
    286337  
    287338-void LzmaEnc_SaveState(CLzmaEncHandle pp) 
    288 +static void __maybe_unused LzmaEnc_SaveState(CLzmaEncHandle pp) 
     339-{ 
     340-  CLzmaEnc *p = (CLzmaEnc *)pp; 
     341-  CSaveState *dest = &p->saveState; 
     342-  int i; 
     343-  dest->lenEnc = p->lenEnc; 
     344-  dest->repLenEnc = p->repLenEnc; 
     345-  dest->state = p->state; 
     346- 
     347-  for (i = 0; i < kNumStates; i++) 
     348-  { 
     349-    memcpy(dest->isMatch[i], p->isMatch[i], sizeof(p->isMatch[i])); 
     350-    memcpy(dest->isRep0Long[i], p->isRep0Long[i], sizeof(p->isRep0Long[i])); 
     351-  } 
     352-  for (i = 0; i < kNumLenToPosStates; i++) 
     353-    memcpy(dest->posSlotEncoder[i], p->posSlotEncoder[i], sizeof(p->posSlotEncoder[i])); 
     354-  memcpy(dest->isRep, p->isRep, sizeof(p->isRep)); 
     355-  memcpy(dest->isRepG0, p->isRepG0, sizeof(p->isRepG0)); 
     356-  memcpy(dest->isRepG1, p->isRepG1, sizeof(p->isRepG1)); 
     357-  memcpy(dest->isRepG2, p->isRepG2, sizeof(p->isRepG2)); 
     358-  memcpy(dest->posEncoders, p->posEncoders, sizeof(p->posEncoders)); 
     359-  memcpy(dest->posAlignEncoder, p->posAlignEncoder, sizeof(p->posAlignEncoder)); 
     360-  memcpy(dest->reps, p->reps, sizeof(p->reps)); 
     361-  memcpy(dest->litProbs, p->litProbs, (0x300 << p->lclp) * sizeof(CLzmaProb)); 
     362-} 
     363- 
     364-void LzmaEnc_RestoreState(CLzmaEncHandle pp) 
     365-{ 
     366-  CLzmaEnc *dest = (CLzmaEnc *)pp; 
     367-  const CSaveState *p = &dest->saveState; 
     368-  int i; 
     369-  dest->lenEnc = p->lenEnc; 
     370-  dest->repLenEnc = p->repLenEnc; 
     371-  dest->state = p->state; 
     372- 
     373-  for (i = 0; i < kNumStates; i++) 
     374-  { 
     375-    memcpy(dest->isMatch[i], p->isMatch[i], sizeof(p->isMatch[i])); 
     376-    memcpy(dest->isRep0Long[i], p->isRep0Long[i], sizeof(p->isRep0Long[i])); 
     377-  } 
     378-  for (i = 0; i < kNumLenToPosStates; i++) 
     379-    memcpy(dest->posSlotEncoder[i], p->posSlotEncoder[i], sizeof(p->posSlotEncoder[i])); 
     380-  memcpy(dest->isRep, p->isRep, sizeof(p->isRep)); 
     381-  memcpy(dest->isRepG0, p->isRepG0, sizeof(p->isRepG0)); 
     382-  memcpy(dest->isRepG1, p->isRepG1, sizeof(p->isRepG1)); 
     383-  memcpy(dest->isRepG2, p->isRepG2, sizeof(p->isRepG2)); 
     384-  memcpy(dest->posEncoders, p->posEncoders, sizeof(p->posEncoders)); 
     385-  memcpy(dest->posAlignEncoder, p->posAlignEncoder, sizeof(p->posAlignEncoder)); 
     386-  memcpy(dest->reps, p->reps, sizeof(p->reps)); 
     387-  memcpy(dest->litProbs, p->litProbs, (0x300 << dest->lclp) * sizeof(CLzmaProb)); 
     388-} 
     389- 
     390 SRes LzmaEnc_SetProps(CLzmaEncHandle pp, const CLzmaEncProps *props2) 
    289391 { 
    290392   CLzmaEnc *p = (CLzmaEnc *)pp; 
    291    CSaveState *dest = &p->saveState; 
    292 @@ -365,7 +365,7 @@ void LzmaEnc_SaveState(CLzmaEncHandle pp 
    293    memcpy(dest->litProbs, p->litProbs, (0x300 << p->lclp) * sizeof(CLzmaProb)); 
    294  } 
    295   
    296 -void LzmaEnc_RestoreState(CLzmaEncHandle pp) 
    297 +static void __maybe_unused LzmaEnc_RestoreState(CLzmaEncHandle pp) 
    298  { 
    299    CLzmaEnc *dest = (CLzmaEnc *)pp; 
    300    const CSaveState *p = &dest->saveState; 
    301 @@ -600,7 +600,7 @@ static void LitEnc_EncodeMatched(CRangeE 
     393@@ -600,7 +548,7 @@ static void LitEnc_EncodeMatched(CRangeE 
    302394   while (symbol < 0x10000); 
    303395 } 
     
    308400   UInt32 i; 
    309401   for (i = (1 << kNumMoveReducingBits) / 2; i < kBitModelTotal; i += (1 << kNumMoveReducingBits)) 
    310 @@ -1676,7 +1676,7 @@ static void FillDistancesPrices(CLzmaEnc 
     402@@ -1676,7 +1624,7 @@ static void FillDistancesPrices(CLzmaEnc 
    311403   p->matchPriceCount = 0; 
    312404 } 
     
    317409   RangeEnc_Construct(&p->rc); 
    318410   MatchFinder_Construct(&p->matchFinderBase); 
    319 @@ -1709,7 +1709,7 @@ CLzmaEncHandle LzmaEnc_Create(ISzAlloc * 
     411@@ -1709,7 +1657,7 @@ CLzmaEncHandle LzmaEnc_Create(ISzAlloc * 
    320412   return p; 
    321413 } 
     
    326418   alloc->Free(alloc, p->litProbs); 
    327419   alloc->Free(alloc, p->saveState.litProbs); 
    328 @@ -2074,7 +2074,7 @@ SRes LzmaEnc_MemPrepare(CLzmaEncHandle p 
     420@@ -1717,7 +1665,7 @@ void LzmaEnc_FreeLits(CLzmaEnc *p, ISzAl 
     421   p->saveState.litProbs = 0; 
     422 } 
     423  
     424-void LzmaEnc_Destruct(CLzmaEnc *p, ISzAlloc *alloc, ISzAlloc *allocBig) 
     425+static void LzmaEnc_Destruct(CLzmaEnc *p, ISzAlloc *alloc, ISzAlloc *allocBig) 
     426 { 
     427   #ifndef _7ZIP_ST 
     428   MatchFinderMt_Destruct(&p->matchFinderMt, allocBig); 
     429@@ -1947,7 +1895,7 @@ static SRes LzmaEnc_Alloc(CLzmaEnc *p, U 
     430   return SZ_OK; 
     431 } 
     432  
     433-void LzmaEnc_Init(CLzmaEnc *p) 
     434+static void LzmaEnc_Init(CLzmaEnc *p) 
     435 { 
     436   UInt32 i; 
     437   p->state = 0; 
     438@@ -2005,7 +1953,7 @@ void LzmaEnc_Init(CLzmaEnc *p) 
     439   p->lpMask = (1 << p->lp) - 1; 
     440 } 
     441  
     442-void LzmaEnc_InitPrices(CLzmaEnc *p) 
     443+static void LzmaEnc_InitPrices(CLzmaEnc *p) 
     444 { 
     445   if (!p->fastMode) 
     446   { 
     447@@ -2037,26 +1985,6 @@ static SRes LzmaEnc_AllocAndInit(CLzmaEn 
     448   return SZ_OK; 
     449 } 
     450  
     451-static SRes LzmaEnc_Prepare(CLzmaEncHandle pp, ISeqOutStream *outStream, ISeqInStream *inStream, 
     452-    ISzAlloc *alloc, ISzAlloc *allocBig) 
     453-{ 
     454-  CLzmaEnc *p = (CLzmaEnc *)pp; 
     455-  p->matchFinderBase.stream = inStream; 
     456-  p->needInit = 1; 
     457-  p->rc.outStream = outStream; 
     458-  return LzmaEnc_AllocAndInit(p, 0, alloc, allocBig); 
     459-} 
     460- 
     461-SRes LzmaEnc_PrepareForLzma2(CLzmaEncHandle pp, 
     462-    ISeqInStream *inStream, UInt32 keepWindowSize, 
     463-    ISzAlloc *alloc, ISzAlloc *allocBig) 
     464-{ 
     465-  CLzmaEnc *p = (CLzmaEnc *)pp; 
     466-  p->matchFinderBase.stream = inStream; 
     467-  p->needInit = 1; 
     468-  return LzmaEnc_AllocAndInit(p, keepWindowSize, alloc, allocBig); 
     469-} 
     470- 
     471 static void LzmaEnc_SetInputBuf(CLzmaEnc *p, const Byte *src, SizeT srcLen) 
     472 { 
     473   p->matchFinderBase.directInput = 1; 
     474@@ -2064,7 +1992,7 @@ static void LzmaEnc_SetInputBuf(CLzmaEnc 
     475   p->matchFinderBase.directInputRem = srcLen; 
     476 } 
     477  
     478-SRes LzmaEnc_MemPrepare(CLzmaEncHandle pp, const Byte *src, SizeT srcLen, 
     479+static SRes LzmaEnc_MemPrepare(CLzmaEncHandle pp, const Byte *src, SizeT srcLen, 
     480     UInt32 keepWindowSize, ISzAlloc *alloc, ISzAlloc *allocBig) 
     481 { 
     482   CLzmaEnc *p = (CLzmaEnc *)pp; 
     483@@ -2074,7 +2002,7 @@ SRes LzmaEnc_MemPrepare(CLzmaEncHandle p 
    329484   return LzmaEnc_AllocAndInit(p, keepWindowSize, alloc, allocBig); 
    330485 } 
     
    335490   #ifndef _7ZIP_ST 
    336491   CLzmaEnc *p = (CLzmaEnc *)pp; 
    337 @@ -2108,7 +2108,7 @@ static size_t MyWrite(void *pp, const vo 
    338  } 
    339   
    340   
     492@@ -2107,53 +2035,6 @@ static size_t MyWrite(void *pp, const vo 
     493   return size; 
     494 } 
     495  
     496- 
    341497-UInt32 LzmaEnc_GetNumAvailableBytes(CLzmaEncHandle pp) 
    342 +static UInt32 __maybe_unused LzmaEnc_GetNumAvailableBytes(CLzmaEncHandle pp) 
    343  { 
    344    const CLzmaEnc *p = (CLzmaEnc *)pp; 
    345    return p->matchFinder.GetNumAvailableBytes(p->matchFinderObj); 
    346 @@ -2120,7 +2120,7 @@ const Byte *LzmaEnc_GetCurBuf(CLzmaEncHa 
    347    return p->matchFinder.GetPointerToCurrentPos(p->matchFinderObj) - p->additionalOffset; 
    348  } 
    349   
     498-{ 
     499-  const CLzmaEnc *p = (CLzmaEnc *)pp; 
     500-  return p->matchFinder.GetNumAvailableBytes(p->matchFinderObj); 
     501-} 
     502- 
     503-const Byte *LzmaEnc_GetCurBuf(CLzmaEncHandle pp) 
     504-{ 
     505-  const CLzmaEnc *p = (CLzmaEnc *)pp; 
     506-  return p->matchFinder.GetPointerToCurrentPos(p->matchFinderObj) - p->additionalOffset; 
     507-} 
     508- 
    350509-SRes LzmaEnc_CodeOneMemBlock(CLzmaEncHandle pp, Bool reInit, 
    351 +static SRes __maybe_unused LzmaEnc_CodeOneMemBlock(CLzmaEncHandle pp, Bool reInit, 
    352      Byte *dest, size_t *destLen, UInt32 desiredPackSize, UInt32 *unpackSize) 
     510-    Byte *dest, size_t *destLen, UInt32 desiredPackSize, UInt32 *unpackSize) 
     511-{ 
     512-  CLzmaEnc *p = (CLzmaEnc *)pp; 
     513-  UInt64 nowPos64; 
     514-  SRes res; 
     515-  CSeqOutStreamBuf outStream; 
     516- 
     517-  outStream.funcTable.Write = MyWrite; 
     518-  outStream.data = dest; 
     519-  outStream.rem = *destLen; 
     520-  outStream.overflow = False; 
     521- 
     522-  p->writeEndMark = False; 
     523-  p->finished = False; 
     524-  p->result = SZ_OK; 
     525- 
     526-  if (reInit) 
     527-    LzmaEnc_Init(p); 
     528-  LzmaEnc_InitPrices(p); 
     529-  nowPos64 = p->nowPos64; 
     530-  RangeEnc_Init(&p->rc); 
     531-  p->rc.outStream = &outStream.funcTable; 
     532- 
     533-  res = LzmaEnc_CodeOneBlock(p, True, desiredPackSize, *unpackSize); 
     534 
     535-  *unpackSize = (UInt32)(p->nowPos64 - nowPos64); 
     536-  *destLen -= outStream.rem; 
     537-  if (outStream.overflow) 
     538-    return SZ_ERROR_OUTPUT_EOF; 
     539- 
     540-  return res; 
     541-} 
     542- 
     543 static SRes LzmaEnc_Encode2(CLzmaEnc *p, ICompressProgress *progress) 
     544 { 
     545   SRes res = SZ_OK; 
     546@@ -2184,13 +2065,6 @@ static SRes LzmaEnc_Encode2(CLzmaEnc *p, 
     547   return res; 
     548 } 
     549  
     550-SRes LzmaEnc_Encode(CLzmaEncHandle pp, ISeqOutStream *outStream, ISeqInStream *inStream, ICompressProgress *progress, 
     551-    ISzAlloc *alloc, ISzAlloc *allocBig) 
     552-{ 
     553-  RINOK(LzmaEnc_Prepare(pp, outStream, inStream, alloc, allocBig)); 
     554-  return LzmaEnc_Encode2((CLzmaEnc *)pp, progress); 
     555-} 
     556- 
     557 SRes LzmaEnc_WriteProperties(CLzmaEncHandle pp, Byte *props, SizeT *size) 
    353558 { 
    354559   CLzmaEnc *p = (CLzmaEnc *)pp; 
    355 @@ -2248,7 +2248,7 @@ SRes LzmaEnc_MemEncode(CLzmaEncHandle pp 
     560@@ -2247,25 +2121,3 @@ SRes LzmaEnc_MemEncode(CLzmaEncHandle pp 
     561     return SZ_ERROR_OUTPUT_EOF; 
    356562   return res; 
    357563 } 
    358   
     564- 
    359565-SRes LzmaEncode(Byte *dest, SizeT *destLen, const Byte *src, SizeT srcLen, 
    360 +static __maybe_unused SRes LzmaEncode(Byte *dest, SizeT *destLen, const Byte *src, SizeT srcLen, 
    361      const CLzmaEncProps *props, Byte *propsEncoded, SizeT *propsSize, int writeEndMark, 
    362      ICompressProgress *progress, ISzAlloc *alloc, ISzAlloc *allocBig) 
    363  { 
     566-    const CLzmaEncProps *props, Byte *propsEncoded, SizeT *propsSize, int writeEndMark, 
     567-    ICompressProgress *progress, ISzAlloc *alloc, ISzAlloc *allocBig) 
     568-{ 
     569-  CLzmaEnc *p = (CLzmaEnc *)LzmaEnc_Create(alloc); 
     570-  SRes res; 
     571-  if (p == 0) 
     572-    return SZ_ERROR_MEM; 
     573- 
     574-  res = LzmaEnc_SetProps(p, props); 
     575-  if (res == SZ_OK) 
     576-  { 
     577-    res = LzmaEnc_WriteProperties(p, propsEncoded, propsSize); 
     578-    if (res == SZ_OK) 
     579-      res = LzmaEnc_MemEncode(p, dest, destLen, src, srcLen, 
     580-          writeEndMark, progress, alloc, allocBig); 
     581-  } 
     582- 
     583-  LzmaEnc_Destroy(p, alloc, allocBig); 
     584-  return res; 
     585-} 
    364586--- a/include/linux/lzma/LzFind.h 
    365587+++ b/include/linux/lzma/LzFind.h 
     
    376598  
    377599 /* Conditions: 
    378 @@ -70,12 +65,6 @@ int MatchFinder_Create(CMatchFinder *p, 
     600@@ -70,12 +65,6 @@ int MatchFinder_Create(CMatchFinder *p,  
    379601     UInt32 keepAddBufferBefore, UInt32 matchMaxLen, UInt32 keepAddBufferAfter, 
    380602     ISzAlloc *alloc); 
     
    404626--- a/lib/lzma/LzFind.c 
    405627+++ b/lib/lzma/LzFind.c 
    406 @@ -42,12 +42,12 @@ static int LzInWindow_Create(CMatchFinde 
     628@@ -14,9 +14,15 @@ 
     629  
     630 #define kStartMaxLen 3 
     631  
     632+#if 0 
     633+#define DIRECT_INPUT   p->directInput 
     634+#else 
     635+#define DIRECT_INPUT   1 
     636+#endif 
     637+ 
     638 static void LzInWindow_Free(CMatchFinder *p, ISzAlloc *alloc) 
     639 { 
     640-  if (!p->directInput) 
     641+  if (!DIRECT_INPUT) 
     642   { 
     643     alloc->Free(alloc, p->bufferBase); 
     644     p->bufferBase = 0; 
     645@@ -28,7 +34,7 @@ static void LzInWindow_Free(CMatchFinder 
     646 static int LzInWindow_Create(CMatchFinder *p, UInt32 keepSizeReserv, ISzAlloc *alloc) 
     647 { 
     648   UInt32 blockSize = p->keepSizeBefore + p->keepSizeAfter + keepSizeReserv; 
     649-  if (p->directInput) 
     650+  if (DIRECT_INPUT) 
     651   { 
     652     p->blockSize = blockSize; 
     653     return 1; 
     654@@ -42,12 +48,12 @@ static int LzInWindow_Create(CMatchFinde 
    407655   return (p->bufferBase != 0); 
    408656 } 
     
    421669   p->posLimit -= subValue; 
    422670   p->pos -= subValue; 
    423 @@ -268,7 +268,7 @@ static void MatchFinder_SetLimits(CMatch 
     671@@ -58,7 +64,7 @@ static void MatchFinder_ReadBlock(CMatch 
     672 { 
     673   if (p->streamEndWasReached || p->result != SZ_OK) 
     674     return; 
     675-  if (p->directInput) 
     676+  if (DIRECT_INPUT) 
     677   { 
     678     UInt32 curSize = 0xFFFFFFFF - p->streamPos; 
     679     if (curSize > p->directInputRem) 
     680@@ -89,7 +95,7 @@ static void MatchFinder_ReadBlock(CMatch 
     681   } 
     682 } 
     683  
     684-void MatchFinder_MoveBlock(CMatchFinder *p) 
     685+static void MatchFinder_MoveBlock(CMatchFinder *p) 
     686 { 
     687   memmove(p->bufferBase, 
     688     p->buffer - p->keepSizeBefore, 
     689@@ -97,22 +103,14 @@ void MatchFinder_MoveBlock(CMatchFinder  
     690   p->buffer = p->bufferBase + p->keepSizeBefore; 
     691 } 
     692  
     693-int MatchFinder_NeedMove(CMatchFinder *p) 
     694+static int MatchFinder_NeedMove(CMatchFinder *p) 
     695 { 
     696-  if (p->directInput) 
     697+  if (DIRECT_INPUT) 
     698     return 0; 
     699   /* if (p->streamEndWasReached) return 0; */ 
     700   return ((size_t)(p->bufferBase + p->blockSize - p->buffer) <= p->keepSizeAfter); 
     701 } 
     702  
     703-void MatchFinder_ReadIfRequired(CMatchFinder *p) 
     704-{ 
     705-  if (p->streamEndWasReached) 
     706-    return; 
     707-  if (p->keepSizeAfter >= p->streamPos - p->pos) 
     708-    MatchFinder_ReadBlock(p); 
     709-} 
     710- 
     711 static void MatchFinder_CheckAndMoveAndRead(CMatchFinder *p) 
     712 { 
     713   if (MatchFinder_NeedMove(p)) 
     714@@ -268,7 +266,7 @@ static void MatchFinder_SetLimits(CMatch 
    424715   p->posLimit = p->pos + limit; 
    425716 } 
     
    430721   UInt32 i; 
    431722   for (i = 0; i < p->hashSizeSum; i++) 
    432 @@ -287,7 +287,7 @@ static UInt32 MatchFinder_GetSubValue(CM 
     723@@ -287,7 +285,7 @@ static UInt32 MatchFinder_GetSubValue(CM 
    433724   return (p->pos - p->historySize - 1) & kNormalizeMask; 
    434725 } 
     
    439730   UInt32 i; 
    440731   for (i = 0; i < numItems; i++) 
    441 @@ -350,7 +350,7 @@ static UInt32 * Hc_GetMatchesSpec(UInt32 
    442    } 
    443  } 
    444   
     732@@ -319,38 +317,7 @@ static void MatchFinder_CheckLimits(CMat 
     733   MatchFinder_SetLimits(p); 
     734 } 
     735  
     736-static UInt32 * Hc_GetMatchesSpec(UInt32 lenLimit, UInt32 curMatch, UInt32 pos, const Byte *cur, CLzRef *son, 
     737-    UInt32 _cyclicBufferPos, UInt32 _cyclicBufferSize, UInt32 cutValue, 
     738-    UInt32 *distances, UInt32 maxLen) 
     739-{ 
     740-  son[_cyclicBufferPos] = curMatch; 
     741-  for (;;) 
     742-  { 
     743-    UInt32 delta = pos - curMatch; 
     744-    if (cutValue-- == 0 || delta >= _cyclicBufferSize) 
     745-      return distances; 
     746-    { 
     747-      const Byte *pb = cur - delta; 
     748-      curMatch = son[_cyclicBufferPos - delta + ((delta > _cyclicBufferPos) ? _cyclicBufferSize : 0)]; 
     749-      if (pb[maxLen] == cur[maxLen] && *pb == *cur) 
     750-      { 
     751-        UInt32 len = 0; 
     752-        while (++len != lenLimit) 
     753-          if (pb[len] != cur[len]) 
     754-            break; 
     755-        if (maxLen < len) 
     756-        { 
     757-          *distances++ = maxLen = len; 
     758-          *distances++ = delta - 1; 
     759-          if (len == lenLimit) 
     760-            return distances; 
     761-        } 
     762-      } 
     763-    } 
     764-  } 
     765-} 
     766- 
    445767-UInt32 * GetMatchesSpec1(UInt32 lenLimit, UInt32 curMatch, UInt32 pos, const Byte *cur, CLzRef *son, 
    446768+static UInt32 * GetMatchesSpec1(UInt32 lenLimit, UInt32 curMatch, UInt32 pos, const Byte *cur, CLzRef *son, 
     
    448770     UInt32 *distances, UInt32 maxLen) 
    449771 { 
    450 @@ -492,7 +492,7 @@ static UInt32 Bt2_MatchFinder_GetMatches 
    451    GET_MATCHES_FOOTER(offset, 1) 
    452  } 
    453   
     772@@ -460,10 +427,10 @@ static void SkipMatchesSpec(UInt32 lenLi 
     773   p->buffer++; \ 
     774   if (++p->pos == p->posLimit) MatchFinder_CheckLimits(p); 
     775  
     776-#define MOVE_POS_RET MOVE_POS return offset; 
     777- 
     778 static void MatchFinder_MovePos(CMatchFinder *p) { MOVE_POS; } 
     779  
     780+#define MOVE_POS_RET MatchFinder_MovePos(p); return offset; 
     781+ 
     782 #define GET_MATCHES_HEADER2(minLen, ret_op) \ 
     783   UInt32 lenLimit; UInt32 hashValue; const Byte *cur; UInt32 curMatch; \ 
     784   lenLimit = p->lenLimit; { if (lenLimit < minLen) { MatchFinder_MovePos(p); ret_op; }} \ 
     785@@ -479,62 +446,7 @@ static void MatchFinder_MovePos(CMatchFi 
     786   distances + offset, maxLen) - distances); MOVE_POS_RET; 
     787  
     788 #define SKIP_FOOTER \ 
     789-  SkipMatchesSpec(lenLimit, curMatch, MF_PARAMS(p)); MOVE_POS; 
     790- 
     791-static UInt32 Bt2_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances) 
     792-{ 
     793-  UInt32 offset; 
     794-  GET_MATCHES_HEADER(2) 
     795-  HASH2_CALC; 
     796-  curMatch = p->hash[hashValue]; 
     797-  p->hash[hashValue] = p->pos; 
     798-  offset = 0; 
     799-  GET_MATCHES_FOOTER(offset, 1) 
     800-} 
     801- 
    454802-UInt32 Bt3Zip_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances) 
    455 +static __maybe_unused UInt32 Bt3Zip_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances) 
    456  { 
    457    UInt32 offset; 
    458    GET_MATCHES_HEADER(3) 
    459 @@ -632,7 +632,7 @@ static UInt32 Hc4_MatchFinder_GetMatches 
    460    MOVE_POS_RET 
    461  } 
    462   
     803-{ 
     804-  UInt32 offset; 
     805-  GET_MATCHES_HEADER(3) 
     806-  HASH_ZIP_CALC; 
     807-  curMatch = p->hash[hashValue]; 
     808-  p->hash[hashValue] = p->pos; 
     809-  offset = 0; 
     810-  GET_MATCHES_FOOTER(offset, 2) 
     811-} 
     812- 
     813-static UInt32 Bt3_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances) 
     814-{ 
     815-  UInt32 hash2Value, delta2, maxLen, offset; 
     816-  GET_MATCHES_HEADER(3) 
     817- 
     818-  HASH3_CALC; 
     819- 
     820-  delta2 = p->pos - p->hash[hash2Value]; 
     821-  curMatch = p->hash[kFix3HashSize + hashValue]; 
     822 
     823-  p->hash[hash2Value] = 
     824-  p->hash[kFix3HashSize + hashValue] = p->pos; 
     825- 
     826- 
     827-  maxLen = 2; 
     828-  offset = 0; 
     829-  if (delta2 < p->cyclicBufferSize && *(cur - delta2) == *cur) 
     830-  { 
     831-    for (; maxLen != lenLimit; maxLen++) 
     832-      if (cur[(ptrdiff_t)maxLen - delta2] != cur[maxLen]) 
     833-        break; 
     834-    distances[0] = maxLen; 
     835-    distances[1] = delta2 - 1; 
     836-    offset = 2; 
     837-    if (maxLen == lenLimit) 
     838-    { 
     839-      SkipMatchesSpec(lenLimit, curMatch, MF_PARAMS(p)); 
     840-      MOVE_POS_RET; 
     841-    } 
     842-  } 
     843-  GET_MATCHES_FOOTER(offset, maxLen) 
     844-} 
     845+  SkipMatchesSpec(lenLimit, curMatch, MF_PARAMS(p)); MatchFinder_MovePos(p); 
     846  
     847 static UInt32 Bt4_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances) 
     848 { 
     849@@ -583,108 +495,6 @@ static UInt32 Bt4_MatchFinder_GetMatches 
     850   GET_MATCHES_FOOTER(offset, maxLen) 
     851 } 
     852  
     853-static UInt32 Hc4_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances) 
     854-{ 
     855-  UInt32 hash2Value, hash3Value, delta2, delta3, maxLen, offset; 
     856-  GET_MATCHES_HEADER(4) 
     857- 
     858-  HASH4_CALC; 
     859- 
     860-  delta2 = p->pos - p->hash[                hash2Value]; 
     861-  delta3 = p->pos - p->hash[kFix3HashSize + hash3Value]; 
     862-  curMatch = p->hash[kFix4HashSize + hashValue]; 
     863- 
     864-  p->hash[                hash2Value] = 
     865-  p->hash[kFix3HashSize + hash3Value] = 
     866-  p->hash[kFix4HashSize + hashValue] = p->pos; 
     867- 
     868-  maxLen = 1; 
     869-  offset = 0; 
     870-  if (delta2 < p->cyclicBufferSize && *(cur - delta2) == *cur) 
     871-  { 
     872-    distances[0] = maxLen = 2; 
     873-    distances[1] = delta2 - 1; 
     874-    offset = 2; 
     875-  } 
     876-  if (delta2 != delta3 && delta3 < p->cyclicBufferSize && *(cur - delta3) == *cur) 
     877-  { 
     878-    maxLen = 3; 
     879-    distances[offset + 1] = delta3 - 1; 
     880-    offset += 2; 
     881-    delta2 = delta3; 
     882-  } 
     883-  if (offset != 0) 
     884-  { 
     885-    for (; maxLen != lenLimit; maxLen++) 
     886-      if (cur[(ptrdiff_t)maxLen - delta2] != cur[maxLen]) 
     887-        break; 
     888-    distances[offset - 2] = maxLen; 
     889-    if (maxLen == lenLimit) 
     890-    { 
     891-      p->son[p->cyclicBufferPos] = curMatch; 
     892-      MOVE_POS_RET; 
     893-    } 
     894-  } 
     895-  if (maxLen < 3) 
     896-    maxLen = 3; 
     897-  offset = (UInt32)(Hc_GetMatchesSpec(lenLimit, curMatch, MF_PARAMS(p), 
     898-    distances + offset, maxLen) - (distances)); 
     899-  MOVE_POS_RET 
     900-} 
     901- 
    463902-UInt32 Hc3Zip_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances) 
    464 +static __maybe_unused UInt32 Hc3Zip_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances) 
    465  { 
    466    UInt32 offset; 
    467    GET_MATCHES_HEADER(3) 
    468 @@ -657,7 +657,7 @@ static void Bt2_MatchFinder_Skip(CMatchF 
     903-{ 
     904-  UInt32 offset; 
     905-  GET_MATCHES_HEADER(3) 
     906-  HASH_ZIP_CALC; 
     907-  curMatch = p->hash[hashValue]; 
     908-  p->hash[hashValue] = p->pos; 
     909-  offset = (UInt32)(Hc_GetMatchesSpec(lenLimit, curMatch, MF_PARAMS(p), 
     910-    distances, 2) - (distances)); 
     911-  MOVE_POS_RET 
     912-} 
     913- 
     914-static void Bt2_MatchFinder_Skip(CMatchFinder *p, UInt32 num) 
     915-{ 
     916-  do 
     917-  { 
     918-    SKIP_HEADER(2) 
     919-    HASH2_CALC; 
     920-    curMatch = p->hash[hashValue]; 
     921-    p->hash[hashValue] = p->pos; 
     922-    SKIP_FOOTER 
     923-  } 
     924-  while (--num != 0); 
     925-} 
     926- 
     927-void Bt3Zip_MatchFinder_Skip(CMatchFinder *p, UInt32 num) 
     928-{ 
     929-  do 
     930-  { 
     931-    SKIP_HEADER(3) 
     932-    HASH_ZIP_CALC; 
     933-    curMatch = p->hash[hashValue]; 
     934-    p->hash[hashValue] = p->pos; 
     935-    SKIP_FOOTER 
     936-  } 
     937-  while (--num != 0); 
     938-} 
     939- 
     940-static void Bt3_MatchFinder_Skip(CMatchFinder *p, UInt32 num) 
     941-{ 
     942-  do 
     943-  { 
     944-    UInt32 hash2Value; 
     945-    SKIP_HEADER(3) 
     946-    HASH3_CALC; 
     947-    curMatch = p->hash[kFix3HashSize + hashValue]; 
     948-    p->hash[hash2Value] = 
     949-    p->hash[kFix3HashSize + hashValue] = p->pos; 
     950-    SKIP_FOOTER 
     951-  } 
     952-  while (--num != 0); 
     953-} 
     954- 
     955 static void Bt4_MatchFinder_Skip(CMatchFinder *p, UInt32 num) 
     956 { 
     957   do 
     958@@ -701,61 +511,12 @@ static void Bt4_MatchFinder_Skip(CMatchF 
    469959   while (--num != 0); 
    470960 } 
    471961  
    472 -void Bt3Zip_MatchFinder_Skip(CMatchFinder *p, UInt32 num) 
    473 +static __maybe_unused void Bt3Zip_MatchFinder_Skip(CMatchFinder *p, UInt32 num) 
    474  { 
    475    do 
    476    { 
    477 @@ -718,7 +718,7 @@ static void Hc4_MatchFinder_Skip(CMatchF 
    478    while (--num != 0); 
    479  } 
    480   
     962-static void Hc4_MatchFinder_Skip(CMatchFinder *p, UInt32 num) 
     963-{ 
     964-  do 
     965-  { 
     966-    UInt32 hash2Value, hash3Value; 
     967-    SKIP_HEADER(4) 
     968-    HASH4_CALC; 
     969-    curMatch = p->hash[kFix4HashSize + hashValue]; 
     970-    p->hash[                hash2Value] = 
     971-    p->hash[kFix3HashSize + hash3Value] = 
     972-    p->hash[kFix4HashSize + hashValue] = p->pos; 
     973-    p->son[p->cyclicBufferPos] = curMatch; 
     974-    MOVE_POS 
     975-  } 
     976-  while (--num != 0); 
     977-} 
     978- 
    481979-void Hc3Zip_MatchFinder_Skip(CMatchFinder *p, UInt32 num) 
    482 +static __maybe_unused void Hc3Zip_MatchFinder_Skip(CMatchFinder *p, UInt32 num) 
    483  { 
    484    do 
    485    { 
     980-{ 
     981-  do 
     982-  { 
     983-    SKIP_HEADER(3) 
     984-    HASH_ZIP_CALC; 
     985-    curMatch = p->hash[hashValue]; 
     986-    p->hash[hashValue] = p->pos; 
     987-    p->son[p->cyclicBufferPos] = curMatch; 
     988-    MOVE_POS 
     989-  } 
     990-  while (--num != 0); 
     991-} 
     992- 
     993 void MatchFinder_CreateVTable(CMatchFinder *p, IMatchFinder *vTable) 
     994 { 
     995   vTable->Init = (Mf_Init_Func)MatchFinder_Init; 
     996   vTable->GetIndexByte = (Mf_GetIndexByte_Func)MatchFinder_GetIndexByte; 
     997   vTable->GetNumAvailableBytes = (Mf_GetNumAvailableBytes_Func)MatchFinder_GetNumAvailableBytes; 
     998   vTable->GetPointerToCurrentPos = (Mf_GetPointerToCurrentPos_Func)MatchFinder_GetPointerToCurrentPos; 
     999-  if (!p->btMode) 
     1000-  { 
     1001-    vTable->GetMatches = (Mf_GetMatches_Func)Hc4_MatchFinder_GetMatches; 
     1002-    vTable->Skip = (Mf_Skip_Func)Hc4_MatchFinder_Skip; 
     1003-  } 
     1004-  else if (p->numHashBytes == 2) 
     1005-  { 
     1006-    vTable->GetMatches = (Mf_GetMatches_Func)Bt2_MatchFinder_GetMatches; 
     1007-    vTable->Skip = (Mf_Skip_Func)Bt2_MatchFinder_Skip; 
     1008-  } 
     1009-  else if (p->numHashBytes == 3) 
     1010-  { 
     1011-    vTable->GetMatches = (Mf_GetMatches_Func)Bt3_MatchFinder_GetMatches; 
     1012-    vTable->Skip = (Mf_Skip_Func)Bt3_MatchFinder_Skip; 
     1013-  } 
     1014-  else 
     1015-  { 
     1016-    vTable->GetMatches = (Mf_GetMatches_Func)Bt4_MatchFinder_GetMatches; 
     1017-    vTable->Skip = (Mf_Skip_Func)Bt4_MatchFinder_Skip; 
     1018-  } 
     1019+  vTable->GetMatches = (Mf_GetMatches_Func)Bt4_MatchFinder_GetMatches; 
     1020+  vTable->Skip = (Mf_Skip_Func)Bt4_MatchFinder_Skip; 
     1021 } 
Note: See TracChangeset for help on using the changeset viewer.