In order to keep future maintenance at a minimum, as it has been around
a year since the last time we updated the LZMA code, update it again.
This brings us in line with the 26.05 release and there are few changes
here which have an impact on us.

Signed-off-by: Tom Rini <[email protected]>
---
 lib/lzma/7zC.txt    |  4 ++--
 lib/lzma/7zTypes.h  |  7 +++++--
 lib/lzma/Compiler.h | 43 ++++++++++++++++++++++++++++++++++++++++++-
 lib/lzma/LzmaDec.c  | 18 +++++++++++-------
 lib/lzma/Precomp.h  | 14 +++++++-------
 5 files changed, 67 insertions(+), 19 deletions(-)

diff --git a/lib/lzma/7zC.txt b/lib/lzma/7zC.txt
index 10d3f4792f16..5bfcdfc9000b 100644
--- a/lib/lzma/7zC.txt
+++ b/lib/lzma/7zC.txt
@@ -165,8 +165,8 @@ Memory usage for archive Decompressing:
      - Memory for LZMA decompressing structures
   - Main pool:
      - Memory for decompressed solid block
-     - Memory for temprorary buffers, if BCJ2 fileter is used. Usually these
-       temprorary buffers can be about 15% of solid block size.
+     - Memory for temporary buffers, if BCJ2 filter is used. Usually these
+       temporary buffers can be about 15% of solid block size.
 
 
 7z Decoder doesn't allocate memory for compressed blocks.
diff --git a/lib/lzma/7zTypes.h b/lib/lzma/7zTypes.h
index 89f40f2a66e6..44b5c0076952 100644
--- a/lib/lzma/7zTypes.h
+++ b/lib/lzma/7zTypes.h
@@ -1,6 +1,6 @@
 /* SPDX-License-Identifier: LZMA-SDK-9.22 */
 /* 7zTypes.h -- Basic types
-2024-01-24 : Igor Pavlov : Public domain */
+: Igor Pavlov : Public domain */
 
 #ifndef ZIP7_7Z_TYPES_H
 #define ZIP7_7Z_TYPES_H
@@ -46,8 +46,9 @@ EXTERN_C_BEGIN
 typedef int SRes;
 
 #ifdef _MSC_VER
+  #define MY_ALIGN_IN_STRUCT(n) __declspec(align(n))
   #if _MSC_VER > 1200
-    #define MY_ALIGN(n) __declspec(align(n))
+    #define MY_ALIGN(n) MY_ALIGN_IN_STRUCT(n)
   #else
     #define MY_ALIGN(n)
   #endif
@@ -58,6 +59,7 @@ typedef int SRes;
   #define MY_ALIGN(n) alignas(n)
   */
   #define MY_ALIGN(n) __attribute__ ((aligned(n)))
+  #define MY_ALIGN_IN_STRUCT(n) MY_ALIGN(n)
 #endif
 
 #ifdef _WIN32
@@ -532,6 +534,7 @@ struct ISzAlloc
 #define Z7_DECLARE_HANDLE(name)  struct name##_dummy{int unused;}; typedef 
struct name##_dummy *name;
 
 #define Z7_memset_0_ARRAY(a)  memset((a), 0, sizeof(a))
+#define Z7_memset_0_VAR(a)  memset(&(a), 0, sizeof(a))
 
 #ifndef Z7_ARRAY_SIZE
 #define Z7_ARRAY_SIZE(a) (sizeof(a) / sizeof((a)[0]))
diff --git a/lib/lzma/Compiler.h b/lib/lzma/Compiler.h
index b1d682e19aa4..0be04f9cc3e3 100644
--- a/lib/lzma/Compiler.h
+++ b/lib/lzma/Compiler.h
@@ -55,6 +55,12 @@
 #pragma GCC diagnostic ignored "-Wexcess-padding"
 #endif
 
+#if defined(Z7_APPLE_CLANG_VERSION) && __clang_major__ >= 21
+// warning: function MyAlloc might be an allocator wrapper
+// clang in xcode: clang 21.0.0
+#pragma GCC diagnostic ignored "-Wallocator-wrappers"
+#endif
+
 #if __clang_major__ >= 16
 #pragma GCC diagnostic ignored "-Wunsafe-buffer-usage"
 #endif
@@ -71,9 +77,14 @@
   #pragma GCC diagnostic ignored "-Wreserved-identifier"
 #endif
 
+#if __clang_major__ >= 22
+// for "StdAfx.h" and "Precomp.h"
+#pragma GCC diagnostic ignored "-Wshadow-header"
+#endif
+
 #endif // __clang__
 
-#if defined(_WIN32) && defined(__clang__) && __clang_major__ >= 16
+#if defined(__clang__) && __clang_major__ >= 16
 // #pragma GCC diagnostic ignored "-Wcast-function-type-strict"
 #define Z7_DIAGNOSTIC_IGNORE_CAST_FUNCTION \
   _Pragma("GCC diagnostic ignored \"-Wcast-function-type-strict\"")
@@ -114,6 +125,36 @@ typedef void (*Z7_void_Function)(void);
 #pragma warning(disable : 4464) // relative include path contains '..'
 #endif
 
+// #define Z7_ANALYZE_MODE
+#if defined(Z7_ANALYZE_MODE) // && defined(Z7_MSC_VER_ORIGINAL)
+// for -analyze switch:
+#if _MSC_VER >= 1900
+#pragma warning(disable : 6001) // Using uninitialized memory 'ps'.
+#pragma warning(disable : 6031) // Return value ignored: 'CoInitialize'
+#pragma warning(disable : 6553) // The annotation for function 'RegOpenKeyExW' 
on _Param_(3) does not apply to a value type.
+#pragma warning(disable : 28159) // Random.cpp(21) : Consider using 
'GetTickCount64' instead of 'GetTickCount'
+#pragma warning(disable : 28160) // ProcessUtils.h(92) : Error annotation: 
Passing MEM_RELEASE and a non-zero dwSize parameter to VirtualFree is not 
allowed. This results in the failure of this call
+#pragma warning(disable : 28251) // Inconsistent annotation for 'WinMain': 
this instance has no annotations. See c:\program files (x86)\windows 
kits\10\include\10.0.26100.0\um\winbase.h(1062).
+#pragma warning(disable : 28286) // um\consoleapi.h(236) : For function 
'ReadConsoleW', error near the end of 
'SAL_readableTo(byteCount(*__formal(3,lpNumberOfCharsRead) * sizeof(TCHAR%)))'.
+#pragma warning(disable : 28301) // No annotations for first declaration of 
'PNTSTATUS'. See c:\program files (x86)\windows 
kits\10\include\10.0.26100.0\shared\bcrypt.h(40).
+#endif
+#if _MSC_VER >= 1600
+#pragma warning(disable : 6011) // Dereferencing NULL pointer 'p->IsDirs'
+#pragma warning(disable : 6255) // `_alloca` indicates failure by raising a 
stack overflow exception.  Consider using _malloca instead.
+#pragma warning(disable : 6258) // Using TerminateThread does not allow proper 
thread clean up.
+// #pragma warning(disable : 6262) // SfxSetup.c : Function uses '32808' bytes 
of stack.
+#pragma warning(disable : 6320) // Threads.c : Exception-filter expression is 
the constant EXCEPTION_EXECUTE_HANDLER. This might mask exceptions that were 
not intended to be handled.
+#pragma warning(disable : 6385) // createcoder.cpp : Invalid data: accessing 
'struct CCodecInfo const * * g_Codecs', the readable size is '256' bytes, but 
'4194244' bytes might be read: Lines: 338, 339, 340, 342, 344
+#pragma warning(disable : 6387) // MyString.cpp : 's' could be '0':  this does 
not adhere to the specification for the function 'wmemcpy'
+#endif
+#if _MSC_VER == 1600
+#pragma warning(disable : 6200) // compressdialog.cpp : Index '31' is out of 
valid index range '0' to '9' for non-stack buffer 'g_Levels'
+#pragma warning(disable : 6204) // Possible buffer overrun in call to 
'memset': use of unchecked parameter 'size'
+#pragma warning(disable : 6309) // Argument '1' is null: this does not adhere 
to function specification of 'GetProcAddress'
+#pragma warning(disable : 6386) // myvector.h : Buffer overrun: accessing 
'argument 1', the writable size is 'newCapacity*4' bytes, but '8' bytes might 
be written
+#endif
+#endif // Z7_ANALYZE_MODE
+
 // == 1200 : -O1 : for __forceinline
 // >= 1900 : -O1 : for printf
 #pragma warning(disable : 4710) // function not inlined
diff --git a/lib/lzma/LzmaDec.c b/lib/lzma/LzmaDec.c
index f509afcf31fd..323a3c8d9492 100644
--- a/lib/lzma/LzmaDec.c
+++ b/lib/lzma/LzmaDec.c
@@ -1,6 +1,6 @@
 // SPDX-License-Identifier: LZMA-SDK-9.22
 /* LzmaDec.c -- LZMA Decoder
-2023-04-07 : Igor Pavlov : Public domain */
+: Igor Pavlov : Public domain */
 
 #include "Precomp.h"
 
@@ -463,8 +463,10 @@ int Z7_FASTCALL LZMA_DECODE_REAL(CLzmaDec *p, SizeT limit, 
const Byte *bufLimit)
       if (state >= kNumStates)
       {
         UInt32 distance;
-        prob = probs + PosSlot +
-            ((len < kNumLenToPosStates ? len : kNumLenToPosStates - 1) << 
kNumPosSlotBits);
+        {
+          const unsigned temp = (len < kNumLenToPosStates ? len : 
kNumLenToPosStates - 1) << kNumPosSlotBits;
+          prob = probs + PosSlot + temp;
+        }
         TREE_6_DECODE(prob, distance)
         if (distance >= kStartPosModelIndex)
         {
@@ -853,9 +855,10 @@ static ELzmaDummy LzmaDec_TryDummy(const CLzmaDec *p, 
const Byte *buf, const Byt
       if (state < 4)
       {
         unsigned posSlot;
-        prob = probs + PosSlot +
-            ((len < kNumLenToPosStates - 1 ? len : kNumLenToPosStates - 1) <<
-            kNumPosSlotBits);
+        {
+          const unsigned temp = (len < kNumLenToPosStates - 1 ? len : 
kNumLenToPosStates - 1) << kNumPosSlotBits;
+          prob = probs + PosSlot + temp;
+        }
         TREE_DECODE_CHECK(prob, 1 << kNumPosSlotBits, posSlot)
         if (posSlot >= kStartPosModelIndex)
         {
@@ -863,7 +866,8 @@ static ELzmaDummy LzmaDec_TryDummy(const CLzmaDec *p, const 
Byte *buf, const Byt
 
           if (posSlot < kEndPosModelIndex)
           {
-            prob = probs + SpecPos + ((2 | (posSlot & 1)) << numDirectBits);
+            const unsigned temp = (2 | (posSlot & 1)) << numDirectBits;
+            prob = probs + SpecPos + temp;
           }
           else
           {
diff --git a/lib/lzma/Precomp.h b/lib/lzma/Precomp.h
index bcdf3d57b6c8..208d35be7b81 100644
--- a/lib/lzma/Precomp.h
+++ b/lib/lzma/Precomp.h
@@ -1,6 +1,6 @@
 /* SPDX-License-Identifier: LZMA-SDK-9.22 */
 /* Precomp.h -- precompilation file
-2024-01-25 : Igor Pavlov : Public domain */
+: Igor Pavlov : Public domain */
 
 #ifndef ZIP7_INC_PRECOMP_H
 #define ZIP7_INC_PRECOMP_H
@@ -41,18 +41,18 @@
 #endif
 */
 
+#ifndef Z7_LARGE_PAGES
+#if !defined(Z7_NO_LARGE_PAGES) && !defined(UNDER_CE)
+#define Z7_LARGE_PAGES 1
+#endif
+#endif
+
 #ifdef _WIN32
 /*
   this "Precomp.h" file must be included before <windows.h>,
   if we want to define _WIN32_WINNT before <windows.h>.
 */
 
-#ifndef Z7_LARGE_PAGES
-#ifndef Z7_NO_LARGE_PAGES
-#define Z7_LARGE_PAGES 1
-#endif
-#endif
-
 #ifndef Z7_LONG_PATH
 #ifndef Z7_NO_LONG_PATH
 #define Z7_LONG_PATH 1
-- 
2.43.0

Reply via email to