On 02/16/16 21:47, Jordan Justen wrote:
> On 2016-02-15 10:47:28, Laszlo Ersek wrote:
>> The "_maxMode" variable doesn't exist in edk2's variant of LzmaCompress,
>> but the way one of the old uses of the variable is commented out (i.e.,
>> together with the enclosing "if" statement) triggers the
>> "misleading-indentation" warning that is new in gcc-6.0, for the block of
>> code that originally depended on the "if" statement. Gcc believes
>> (mistakenly) that the programmer believes (mistakenly) that the block
>> depends on (repIndex == 0) higher up.
>>
>> Remove the commented out uses of "_maxMode", and unindent the block in
>> question.
>>
>> This patch is best viewed with "git show -b".
>>
>> Cc: Cole Robinson <[email protected]>
>> Cc: Yonghong Zhu <[email protected]>
>> Cc: Liming Gao <[email protected]>
>> Reported-by: Cole Robinson <[email protected]>
>> Ref: https://bugzilla.redhat.com/show_bug.cgi?id=1307439
>> Contributed-under: TianoCore Contribution Agreement 1.0
>> Signed-off-by: Laszlo Ersek <[email protected]>
>> ---
>> BaseTools/Source/C/LzmaCompress/Sdk/C/LzmaEnc.c | 81
>> ++++++++++++-------------
>> 1 file changed, 40 insertions(+), 41 deletions(-)
>>
>> diff --git a/BaseTools/Source/C/LzmaCompress/Sdk/C/LzmaEnc.c
>> b/BaseTools/Source/C/LzmaCompress/Sdk/C/LzmaEnc.c
>> index 9b2dd16ffa48..1eb9898b5291 100644
>> --- a/BaseTools/Source/C/LzmaCompress/Sdk/C/LzmaEnc.c
>> +++ b/BaseTools/Source/C/LzmaCompress/Sdk/C/LzmaEnc.c
>> @@ -1367,52 +1367,51 @@ static UInt32 GetOptimum(CLzmaEnc *p, UInt32
>> position, UInt32 *backRes)
>> if (repIndex == 0)
>> startLen = lenTest + 1;
>>
>> - /* if (_maxMode) */
>
> This also seems to exist as-is in the LZMA SDK code. So, it is not an
> EDK II deviation.
>
> One of the things I tried to do with incorporating the LZMA SDK was
> minimize any changes to LZMA SDK files. This would hopefully make it
> easier to merge in newer versions of the SDK. (Which, of course, we've
> never done.)
>
> Nevertheless, what about just making this change instead:
>
> - /* if (_maxMode) */
> + if (1 /* _maxMode */)
Clearly, that was my first thought as well, but you never know when gcc
will have a bad day and warn about the above as "condition always
evaluates to true".
Cole, can you please try reverting the patch I sent you earlier (i.e.,
this patch) from the fedora tools build, and replace it with Jordan's
suggestion? If that too builds with gcc-6, then I'll submit it as
another normal patch, and once it's upstream, you can rebase the fedora
package (or just pick up the simpler replacement patch).
Thanks!
Laszlo
>
> -Jordan
>
>> + {
>> + UInt32 lenTest2 = lenTest + 1;
>> + UInt32 limit = lenTest2 + p->numFastBytes;
>> + UInt32 nextRepMatchPrice;
>> + if (limit > numAvailFull)
>> + limit = numAvailFull;
>> + for (; lenTest2 < limit && data[lenTest2] == data2[lenTest2];
>> lenTest2++);
>> + lenTest2 -= lenTest + 1;
>> + if (lenTest2 >= 2)
>> {
>> - UInt32 lenTest2 = lenTest + 1;
>> - UInt32 limit = lenTest2 + p->numFastBytes;
>> - UInt32 nextRepMatchPrice;
>> - if (limit > numAvailFull)
>> - limit = numAvailFull;
>> - for (; lenTest2 < limit && data[lenTest2] == data2[lenTest2];
>> lenTest2++);
>> - lenTest2 -= lenTest + 1;
>> - if (lenTest2 >= 2)
>> + UInt32 state2 = kRepNextStates[state];
>> + UInt32 posStateNext = (position + lenTest) & p->pbMask;
>> + UInt32 curAndLenCharPrice =
>> + price + p->repLenEnc.prices[posState][lenTest - 2] +
>> + GET_PRICE_0(p->isMatch[state2][posStateNext]) +
>> + LitEnc_GetPriceMatched(LIT_PROBS(position + lenTest,
>> data[lenTest - 1]),
>> + data[lenTest], data2[lenTest], p->ProbPrices);
>> + state2 = kLiteralNextStates[state2];
>> + posStateNext = (position + lenTest + 1) & p->pbMask;
>> + nextRepMatchPrice = curAndLenCharPrice +
>> + GET_PRICE_1(p->isMatch[state2][posStateNext]) +
>> + GET_PRICE_1(p->isRep[state2]);
>> +
>> + /* for (; lenTest2 >= 2; lenTest2--) */
>> {
>> - UInt32 state2 = kRepNextStates[state];
>> - UInt32 posStateNext = (position + lenTest) & p->pbMask;
>> - UInt32 curAndLenCharPrice =
>> - price + p->repLenEnc.prices[posState][lenTest - 2] +
>> - GET_PRICE_0(p->isMatch[state2][posStateNext]) +
>> - LitEnc_GetPriceMatched(LIT_PROBS(position + lenTest,
>> data[lenTest - 1]),
>> - data[lenTest], data2[lenTest], p->ProbPrices);
>> - state2 = kLiteralNextStates[state2];
>> - posStateNext = (position + lenTest + 1) & p->pbMask;
>> - nextRepMatchPrice = curAndLenCharPrice +
>> - GET_PRICE_1(p->isMatch[state2][posStateNext]) +
>> - GET_PRICE_1(p->isRep[state2]);
>> -
>> - /* for (; lenTest2 >= 2; lenTest2--) */
>> + UInt32 curAndLenPrice;
>> + COptimal *opt;
>> + UInt32 offset = cur + lenTest + 1 + lenTest2;
>> + while (lenEnd < offset)
>> + p->opt[++lenEnd].price = kInfinityPrice;
>> + curAndLenPrice = nextRepMatchPrice + GetRepPrice(p, 0,
>> lenTest2, state2, posStateNext);
>> + opt = &p->opt[offset];
>> + if (curAndLenPrice < opt->price)
>> {
>> - UInt32 curAndLenPrice;
>> - COptimal *opt;
>> - UInt32 offset = cur + lenTest + 1 + lenTest2;
>> - while (lenEnd < offset)
>> - p->opt[++lenEnd].price = kInfinityPrice;
>> - curAndLenPrice = nextRepMatchPrice + GetRepPrice(p, 0,
>> lenTest2, state2, posStateNext);
>> - opt = &p->opt[offset];
>> - if (curAndLenPrice < opt->price)
>> - {
>> - opt->price = curAndLenPrice;
>> - opt->posPrev = cur + lenTest + 1;
>> - opt->backPrev = 0;
>> - opt->prev1IsChar = True;
>> - opt->prev2 = True;
>> - opt->posPrev2 = cur;
>> - opt->backPrev2 = repIndex;
>> - }
>> + opt->price = curAndLenPrice;
>> + opt->posPrev = cur + lenTest + 1;
>> + opt->backPrev = 0;
>> + opt->prev1IsChar = True;
>> + opt->prev2 = True;
>> + opt->posPrev2 = cur;
>> + opt->backPrev2 = repIndex;
>> }
>> }
>> }
>> + }
>> }
>> }
>> /* for (UInt32 lenTest = 2; lenTest <= newLen; lenTest++) */
>> @@ -1456,7 +1455,7 @@ static UInt32 GetOptimum(CLzmaEnc *p, UInt32 position,
>> UInt32 *backRes)
>> opt->prev1IsChar = False;
>> }
>>
>> - if (/*_maxMode && */lenTest == matches[offs])
>> + if (lenTest == matches[offs])
>> {
>> /* Try Match + Literal + Rep0 */
>> const Byte *data2 = data - (curBack + 1);
>> --
>> 1.8.3.1
>>
>> _______________________________________________
>> edk2-devel mailing list
>> [email protected]
>> https://lists.01.org/mailman/listinfo/edk2-devel
_______________________________________________
edk2-devel mailing list
[email protected]
https://lists.01.org/mailman/listinfo/edk2-devel