From 964185b4a1a9e985744703c76e562f8e6bb4e7af Mon Sep 17 00:00:00 2001 From: ptahmose Date: Fri, 17 Feb 2023 00:00:33 +0100 Subject: [PATCH 1/6] clang-tidy fixes --- Src/libCZI/CziWriter.cpp | 4 ++-- Src/libCZI/splines.cpp | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Src/libCZI/CziWriter.cpp b/Src/libCZI/CziWriter.cpp index 90e79f18..b354c921 100644 --- a/Src/libCZI/CziWriter.cpp +++ b/Src/libCZI/CziWriter.cpp @@ -586,7 +586,7 @@ void libCZI::ICziWriter::SyncAddSubBlock(const AddSubBlockInfoStridedBitmap& add uint64_t bytesWritten; uint64_t totalBytesWritten = 0; - auto msHeaderAllocatedSize = ms.header.AllocatedSize; // need to save this information before (potentially) changing the byte-order + const auto msHeaderAllocatedSize = ms.header.AllocatedSize; // need to save this information before (potentially) changing the byte-order ConvertToHostByteOrder::Convert(&ms); info.writeFunc(metadataSegmentPos, &ms, sizeof(ms), &bytesWritten, "MetadataSegment"); @@ -606,7 +606,7 @@ void libCZI::ICziWriter::SyncAddSubBlock(const AddSubBlockInfoStridedBitmap& add if (totalBytesWritten < msHeaderAllocatedSize + sizeof(SegmentHeader)) { - totalBytesWritten += CWriterUtils::WriteZeroes(info.writeFunc, metadataSegmentPos + totalBytesWritten, msHeaderAllocatedSize + sizeof(SegmentHeader) - totalBytesWritten); + CWriterUtils::WriteZeroes(info.writeFunc, metadataSegmentPos + totalBytesWritten, msHeaderAllocatedSize + sizeof(SegmentHeader) - totalBytesWritten); } return make_tuple(metadataSegmentPos, static_cast(msHeaderAllocatedSize)); diff --git a/Src/libCZI/splines.cpp b/Src/libCZI/splines.cpp index 9f0ba6b5..c1952497 100644 --- a/Src/libCZI/splines.cpp +++ b/Src/libCZI/splines.cpp @@ -117,7 +117,7 @@ using namespace Eigen; // TODO: since the points are sorted for x (I'd think so...) we should be able to use a binary search here? int index = 0; - double xPos_for_foundIndex; + double xPos_for_foundIndex = 0; for (int i = 0; i < pointsCnt; i++) { double xPos_i; From c3d0b0813dbea261bfcbace1872b775c48c6d9c1 Mon Sep 17 00:00:00 2001 From: ptahmose Date: Fri, 17 Feb 2023 20:22:20 +0100 Subject: [PATCH 2/6] cosmetic --- Src/libCZI/CziParse.cpp | 16 ++++++++-------- Src/libCZI/CziReaderWriter.cpp | 2 +- Src/libCZI/CziSubBlockDirectory.cpp | 4 ++-- Src/libCZI/CziWriter.cpp | 3 +-- 4 files changed, 12 insertions(+), 13 deletions(-) diff --git a/Src/libCZI/CziParse.cpp b/Src/libCZI/CziParse.cpp index f33f13c4..93c8a9ba 100644 --- a/Src/libCZI/CziParse.cpp +++ b/Src/libCZI/CziParse.cpp @@ -214,7 +214,7 @@ using namespace libCZI; } catch (const std::exception&) { - std::throw_with_nested(LibCZIIOException("Error reading FileHeaderSegement", offset + sizeof(attachmentDirSegment), attachmentEntriesSize)); + std::throw_with_nested(LibCZIIOException("Error reading FileHeaderSegment", offset + sizeof(attachmentDirSegment), attachmentEntriesSize)); } if (bytesRead != attachmentEntriesSize) @@ -378,7 +378,7 @@ using namespace libCZI; } catch (const std::exception&) { - std::throw_with_nested(LibCZIIOException("Error reading FileHeaderSegement", offset + lengthSubblockSegmentData + sizeof(SegmentHeader), subBlckSegment.data.MetadataSize)); + std::throw_with_nested(LibCZIIOException("Error reading FileHeaderSegment", offset + lengthSubblockSegmentData + sizeof(SegmentHeader), subBlckSegment.data.MetadataSize)); } if (bytesRead != subBlckSegment.data.MetadataSize) @@ -395,7 +395,7 @@ using namespace libCZI; } catch (const std::exception&) { - std::throw_with_nested(LibCZIIOException("Error reading FileHeaderSegement", offset + lengthSubblockSegmentData + sizeof(SegmentHeader) + subBlckSegment.data.MetadataSize, subBlckSegment.data.DataSize)); + std::throw_with_nested(LibCZIIOException("Error reading FileHeaderSegment", offset + lengthSubblockSegmentData + sizeof(SegmentHeader) + subBlckSegment.data.MetadataSize, subBlckSegment.data.DataSize)); } if (bytesRead != subBlckSegment.data.DataSize) @@ -412,7 +412,7 @@ using namespace libCZI; } catch (const std::exception&) { - std::throw_with_nested(LibCZIIOException("Error reading FileHeaderSegement", offset + lengthSubblockSegmentData + sizeof(SegmentHeader) + subBlckSegment.data.MetadataSize + subBlckSegment.data.DataSize, subBlckSegment.data.AttachmentSize)); + std::throw_with_nested(LibCZIIOException("Error reading FileHeaderSegment", offset + lengthSubblockSegmentData + sizeof(SegmentHeader) + subBlckSegment.data.MetadataSize + subBlckSegment.data.DataSize, subBlckSegment.data.AttachmentSize)); } if (bytesRead != subBlckSegment.data.AttachmentSize) @@ -467,7 +467,7 @@ using namespace libCZI; } catch (const std::exception&) { - std::throw_with_nested(LibCZIIOException("Error reading AttachmentSegement", offset + 256 + sizeof(SegmentHeader), attchmntSegment.data.DataSize)); + std::throw_with_nested(LibCZIIOException("Error reading AttachmentSegment", offset + 256 + sizeof(SegmentHeader), attchmntSegment.data.DataSize)); } if (bytesRead != attchmntSegment.data.DataSize) @@ -566,7 +566,7 @@ using namespace libCZI; } catch (const std::exception&) { - std::throw_with_nested(LibCZIIOException("Error reading MetaDataSegement", offset, sizeof(metadataSegment))); + std::throw_with_nested(LibCZIIOException("Error reading MetaDataSegment", offset, sizeof(metadataSegment))); } if (bytesRead != sizeof(metadataSegment)) @@ -593,7 +593,7 @@ using namespace libCZI; } catch (const std::exception&) { - std::throw_with_nested(LibCZIIOException("Error reading MetaDataSegement", offset + sizeof(metadataSegment), metadataSegment.data.XmlSize)); + std::throw_with_nested(LibCZIIOException("Error reading MetaDataSegment", offset + sizeof(metadataSegment), metadataSegment.data.XmlSize)); } if (bytesRead != metadataSegment.data.XmlSize) @@ -610,7 +610,7 @@ using namespace libCZI; } catch (const std::exception&) { - std::throw_with_nested(LibCZIIOException("Error reading MetaDataSegement", offset + sizeof(metadataSegment) + metadataSegment.data.XmlSize, metadataSegment.data.AttachmentSize)); + std::throw_with_nested(LibCZIIOException("Error reading MetaDataSegment", offset + sizeof(metadataSegment) + metadataSegment.data.XmlSize, metadataSegment.data.AttachmentSize)); } if (bytesRead != metadataSegment.data.AttachmentSize) diff --git a/Src/libCZI/CziReaderWriter.cpp b/Src/libCZI/CziReaderWriter.cpp index 2f3f58aa..f0bbc5c3 100644 --- a/Src/libCZI/CziReaderWriter.cpp +++ b/Src/libCZI/CziReaderWriter.cpp @@ -33,7 +33,7 @@ struct ReplaceHelper int key; ICziReaderWriter* t; ReplaceHelper(int key, ICziReaderWriter* t) - :key(key), t(t) {}; + :key(key), t(t) {} void operator()(const AddSubBlockInfo& addSbBlkInfo) const { diff --git a/Src/libCZI/CziSubBlockDirectory.cpp b/Src/libCZI/CziSubBlockDirectory.cpp index 45395a0c..f2f2f3b8 100644 --- a/Src/libCZI/CziSubBlockDirectory.cpp +++ b/Src/libCZI/CziSubBlockDirectory.cpp @@ -149,12 +149,12 @@ void CSbBlkStatisticsUpdater::UpdateStatistics(const CCziSubBlockDirectoryBase:: auto it = this->pyramidStatistics.scenePyramidStatistics.find(sceneIndex); if (it != this->pyramidStatistics.scenePyramidStatistics.end()) { - this->UpdatePyramidLayerStatistics(it->second, pli); + CSbBlkStatisticsUpdater::UpdatePyramidLayerStatistics(it->second, pli); } else { std::vector vecPs; - this->UpdatePyramidLayerStatistics(vecPs, pli); + CSbBlkStatisticsUpdater::UpdatePyramidLayerStatistics(vecPs, pli); this->pyramidStatistics.scenePyramidStatistics.insert(std::pair>(sceneIndex, vecPs)); } diff --git a/Src/libCZI/CziWriter.cpp b/Src/libCZI/CziWriter.cpp index b354c921..779f8a08 100644 --- a/Src/libCZI/CziWriter.cpp +++ b/Src/libCZI/CziWriter.cpp @@ -54,7 +54,7 @@ void libCZI::ICziWriter::SyncAddSubBlock(const libCZI::AddSubBlockInfoLinewiseBi { AddSubBlockInfo addSbInfo(addSbInfoLinewise); - size_t stride = addSbInfoLinewise.physicalWidth * CziUtils::GetBytesPerPel(addSbInfoLinewise.PixelType); + size_t stride = addSbInfoLinewise.physicalWidth * (size_t)CziUtils::GetBytesPerPel(addSbInfoLinewise.PixelType); addSbInfo.sizeData = addSbInfoLinewise.physicalHeight * stride; auto linesCnt = addSbInfoLinewise.physicalHeight; addSbInfo.getData = [&](int callCnt, size_t offset, const void*& ptr, size_t& size)->bool @@ -699,7 +699,6 @@ void libCZI::ICziWriter::SyncAddSubBlock(const AddSubBlockInfoStridedBitmap& add uint64_t attchmDirPos; // if we have already written a subblock-directory-segment (possibly a reservation), then we check here if the existing // segment is large enough, and if so we write our data into this segment - //if (this->attachmentDirectorySegment.GetAllocatedSize() >= attchmntDirSegment.header.UsedSize) if (int64_t(info.sizeExistingSegmentPos) >= attchmntDirSegment.header.UsedSize) { attchmDirPos = info.existingSegmentPos;// this->attachmentDirectorySegment.GetFilePos(); From a6e01453a16a52dbcc5f7f0742b2e3cb6d77431f Mon Sep 17 00:00:00 2001 From: ptahmose Date: Mon, 2 Sep 2024 23:34:30 +0200 Subject: [PATCH 3/6] Update CMake for libcurl: SChannel, version bump, fix - Enable SChannel backend for libcurl on Windows to use native SSL/TLS. - Update libcurl version from `curl-8_4_0` to `curl-8_9_1`. --- Src/CMakeLists.txt | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/Src/CMakeLists.txt b/Src/CMakeLists.txt index 579297ed..22ee9459 100644 --- a/Src/CMakeLists.txt +++ b/Src/CMakeLists.txt @@ -37,10 +37,16 @@ if (LIBCZI_BUILD_CURL_BASED_STREAM) # if (APPLE) # for MacOS - let's choose Apple's native secure transport backend # set(CURL_USE_SECTRANSP ON) # endif(APPLE) + + # On Windows, we can enable the SChannel backend, as it is the native one, and it requires no additional dependencies. + if(WIN32) + set(CURL_USE_SCHANNEL ON CACHE BOOL "" FORCE) + endif(WIN32) + FetchContent_Declare( libcurl GIT_REPOSITORY "https://github.com/curl/curl.git" - GIT_TAG "curl-8_4_0" + GIT_TAG "curl-8_9_1" # Set the prefix to control where it's installed PREFIX "${CMAKE_BINARY_DIR}/vendor/curl" ) @@ -52,7 +58,7 @@ if (LIBCZI_BUILD_CURL_BASED_STREAM) set(BUILD_CURL_EXE OFF CACHE BOOL "" FORCE) set(CMAKE_POSITION_INDEPENDENT_CODE ON CACHE BOOL "" FORCE) set(ENABLE_UNICODE ON CACHE BOOL "" FORCE) - + FetchContent_MakeAvailable(libcurl) endif(LIBCZI_BUILD_PREFER_EXTERNALPACKAGE_LIBCURL) endif(LIBCZI_BUILD_CURL_BASED_STREAM) From 91700b5277de2e645f9745f1c935dc0ee4958534 Mon Sep 17 00:00:00 2001 From: ptahmose Date: Mon, 2 Sep 2024 23:39:56 +0200 Subject: [PATCH 4/6] update version-history --- CMakeLists.txt | 2 +- Src/libCZI/Doc/version-history.markdown | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 2ac0efef..312db7db 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -3,7 +3,7 @@ cmake_minimum_required(VERSION 3.15) cmake_policy(SET CMP0091 NEW) # enable new "MSVC runtime library selection" (https://cmake.org/cmake/help/latest/variable/CMAKE_MSVC_RUNTIME_LIBRARY.html) project(libCZI - VERSION 0.61.1 + VERSION 0.61.2 HOMEPAGE_URL "https://github.com/ZEISS/libczi" DESCRIPTION "libCZI is an Open Source Cross-Platform C++ library to read and write CZI") diff --git a/Src/libCZI/Doc/version-history.markdown b/Src/libCZI/Doc/version-history.markdown index 0eb5c7f3..2991bb20 100644 --- a/Src/libCZI/Doc/version-history.markdown +++ b/Src/libCZI/Doc/version-history.markdown @@ -25,3 +25,4 @@ version history {#version_history} 0.60.0 | [106](https://github.com/ZEISS/libczi/pull/106) | with metadata-builder, by default copy the attributes "Id" and "Name" from the channel-node; allow to control the behavior fine-grained 0.61.0 | [109](https://github.com/ZEISS/libczi/pull/109) | fix behaviour of `IXmlNodeRead::GetChildNodeReadonly` (for non-existing nodes), new method `ICziWriter::GetStatistics` added 0.61.1 | [110](https://github.com/ZEISS/libczi/pull/110) | some code cleanup + 0.61.2. | [111](https://github.com/ZEISS/libczi/pull/111) | update libcurl to 8.91 (for build with `LIBCZI_BUILD_PREFER_EXTERNALPACKAGE_LIBCURL=OFF`), enable SChannel (on Windows) by default \ No newline at end of file From ec841fbca76bb82d07afa426a0750730a5b90365 Mon Sep 17 00:00:00 2001 From: ptahmose Date: Mon, 2 Sep 2024 23:47:00 +0200 Subject: [PATCH 5/6] typo --- Src/libCZI/Doc/version-history.markdown | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Src/libCZI/Doc/version-history.markdown b/Src/libCZI/Doc/version-history.markdown index 2991bb20..feb5bdef 100644 --- a/Src/libCZI/Doc/version-history.markdown +++ b/Src/libCZI/Doc/version-history.markdown @@ -25,4 +25,4 @@ version history {#version_history} 0.60.0 | [106](https://github.com/ZEISS/libczi/pull/106) | with metadata-builder, by default copy the attributes "Id" and "Name" from the channel-node; allow to control the behavior fine-grained 0.61.0 | [109](https://github.com/ZEISS/libczi/pull/109) | fix behaviour of `IXmlNodeRead::GetChildNodeReadonly` (for non-existing nodes), new method `ICziWriter::GetStatistics` added 0.61.1 | [110](https://github.com/ZEISS/libczi/pull/110) | some code cleanup - 0.61.2. | [111](https://github.com/ZEISS/libczi/pull/111) | update libcurl to 8.91 (for build with `LIBCZI_BUILD_PREFER_EXTERNALPACKAGE_LIBCURL=OFF`), enable SChannel (on Windows) by default \ No newline at end of file + 0.61.2 | [111](https://github.com/ZEISS/libczi/pull/111) | update libcurl to 8.91 (for build with `LIBCZI_BUILD_PREFER_EXTERNALPACKAGE_LIBCURL=OFF`), enable SChannel (on Windows) by default \ No newline at end of file From cdf38e3dcf7fa64afbbe750d3a3d112fefe94324 Mon Sep 17 00:00:00 2001 From: ptahmose Date: Tue, 3 Sep 2024 00:07:47 +0200 Subject: [PATCH 6/6] typo --- Src/libCZI/Doc/version-history.markdown | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Src/libCZI/Doc/version-history.markdown b/Src/libCZI/Doc/version-history.markdown index feb5bdef..2712bad2 100644 --- a/Src/libCZI/Doc/version-history.markdown +++ b/Src/libCZI/Doc/version-history.markdown @@ -25,4 +25,4 @@ version history {#version_history} 0.60.0 | [106](https://github.com/ZEISS/libczi/pull/106) | with metadata-builder, by default copy the attributes "Id" and "Name" from the channel-node; allow to control the behavior fine-grained 0.61.0 | [109](https://github.com/ZEISS/libczi/pull/109) | fix behaviour of `IXmlNodeRead::GetChildNodeReadonly` (for non-existing nodes), new method `ICziWriter::GetStatistics` added 0.61.1 | [110](https://github.com/ZEISS/libczi/pull/110) | some code cleanup - 0.61.2 | [111](https://github.com/ZEISS/libczi/pull/111) | update libcurl to 8.91 (for build with `LIBCZI_BUILD_PREFER_EXTERNALPACKAGE_LIBCURL=OFF`), enable SChannel (on Windows) by default \ No newline at end of file + 0.61.2 | [111](https://github.com/ZEISS/libczi/pull/111) | update libcurl to 8.9.1 (for build with `LIBCZI_BUILD_PREFER_EXTERNALPACKAGE_LIBCURL=OFF`), enable SChannel (on Windows) by default \ No newline at end of file