From 3aafa81838e4e634c60bbc8cee19e4d965804429 Mon Sep 17 00:00:00 2001
From: Andy Nichols <nezticle@gmail.com>
Date: Wed, 7 Sep 2022 15:35:06 +0200
Subject: [PATCH] Fix unused variable warning in TinyEXR when building in
 release mode

The variable is used for an assert() check, which are disabled in
release mode leading to clang warning about an unused variable. This
patch removes the variable and asserts since this is development code
for a 3rd party library.

---
 src/3rdparty/tinyexr/tinyexr.h | 10 ----------
 1 file changed, 10 deletions(-)

diff --git a/src/3rdparty/tinyexr/tinyexr.h b/src/3rdparty/tinyexr/tinyexr.h
index d9ce07e0..3830af94 100644
--- a/src/3rdparty/tinyexr/tinyexr.h
+++ b/src/3rdparty/tinyexr/tinyexr.h
@@ -7208,7 +7208,6 @@ static size_t SaveEXRNPartImageToMemory(const EXRImage* exr_images,
   // Writing header
   memcpy((*memory_out), &memory[0], memory.size());
   unsigned char* memory_ptr = *memory_out + memory.size();
-  size_t sum = memory.size();
 
   // Writing offset data for chunks
   for (unsigned int i = 0; i < num_parts; ++i) {
@@ -7219,8 +7218,6 @@ static size_t SaveEXRNPartImageToMemory(const EXRImage* exr_images,
       for (int level_index = 0; level_index < num_levels; ++level_index) {
         for (size_t j = 0; j < offset_data[i].offsets[level_index].size(); ++j) {
           size_t num_bytes = sizeof(tinyexr_uint64) * offset_data[i].offsets[level_index][j].size();
-          sum += num_bytes;
-          assert(sum <= total_size);
           memcpy(memory_ptr,
                  reinterpret_cast<unsigned char*>(&offset_data[i].offsets[level_index][j][0]),
                  num_bytes);
@@ -7230,8 +7227,6 @@ static size_t SaveEXRNPartImageToMemory(const EXRImage* exr_images,
       }
     } else {
       size_t num_bytes = sizeof(tinyexr::tinyexr_uint64) * static_cast<size_t>(chunk_count[i]);
-      sum += num_bytes;
-      assert(sum <= total_size);
       std::vector<tinyexr::tinyexr_uint64>& offsets = offset_data[i].offsets[0][0];
       memcpy(memory_ptr, reinterpret_cast<unsigned char*>(&offsets[0]), num_bytes);
       memory_ptr += num_bytes;
@@ -7242,20 +7237,15 @@ static size_t SaveEXRNPartImageToMemory(const EXRImage* exr_images,
   for (unsigned int i = 0; i < num_parts; ++i) {
     for (size_t j = 0; j < static_cast<size_t>(chunk_count[i]); ++j) {
       if (num_parts > 1) {
-        sum += 4;
-        assert(sum <= total_size);
         unsigned int part_number = i;
         swap4(&part_number);
         memcpy(memory_ptr, &part_number, 4);
         memory_ptr += 4;
       }
-      sum += data_lists[i][j].size();
-      assert(sum <= total_size);
       memcpy(memory_ptr, &data_lists[i][j][0], data_lists[i][j].size());
       memory_ptr += data_lists[i][j].size();
     }
   }
-  assert(sum == total_size);
   return total_size;  // OK
 }
 
-- 
2.32.1 (Apple Git-133)

