Skip to content

Commit

Permalink
add upstream patch for Clang build
Browse files Browse the repository at this point in the history
  • Loading branch information
marxin committed Aug 15, 2023
1 parent aee814a commit a5b3e77
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 0 deletions.
1 change: 1 addition & 0 deletions recipes/libe57format/all/conandata.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,4 @@ patches:
- patch_file: "patches/2.3.0-0001-fix-pic.patch"
"3.0.2":
- patch_file: "patches/3.0.1-0001-fix-pic-lto.patch"
- patch_file: "patches/0001-Cast-int-_MAX-comparisons-to-fix-clang-warnings-257.patch"
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
From 507c98a229333995fd92b37e890c1c50f97fa91d Mon Sep 17 00:00:00 2001
From: Andy Maloney <asmaloney@gmail.com>
Date: Tue, 15 Aug 2023 11:02:53 -0400
Subject: [PATCH] Cast <int>_MAX comparisons to fix clang warnings (#257)

These should be safe because we aren't checking equality.

Note that Apple's clang doesn't warn about these, but it looks like the official clang releases do.

Fixes #256
---
src/SourceDestBufferImpl.cpp | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/src/SourceDestBufferImpl.cpp b/src/SourceDestBufferImpl.cpp
index b103414..c534e30 100644
--- a/src/SourceDestBufferImpl.cpp
+++ b/src/SourceDestBufferImpl.cpp
@@ -203,7 +203,7 @@ template <typename T> void SourceDestBufferImpl::_setNextReal( T inValue )
{
throw E57_EXCEPTION2( ErrorConversionRequired, "pathName=" + pathName_ );
}
- if ( inValue < INT32_MIN || INT32_MAX < inValue )
+ if ( inValue < INT32_MIN || ( inValue > static_cast<T>( INT32_MAX ) ) )
{
throw E57_EXCEPTION2( ErrorValueNotRepresentable,
"pathName=" + pathName_ + " value=" + toString( inValue ) );
@@ -215,7 +215,7 @@ template <typename T> void SourceDestBufferImpl::_setNextReal( T inValue )
{
throw E57_EXCEPTION2( ErrorConversionRequired, "pathName=" + pathName_ );
}
- if ( inValue < UINT32_MIN || UINT32_MAX < inValue )
+ if ( inValue < UINT32_MIN || ( inValue > ( static_cast<T>( UINT32_MAX ) ) ) )
{
throw E57_EXCEPTION2( ErrorValueNotRepresentable,
"pathName=" + pathName_ + " value=" + toString( inValue ) );
@@ -227,7 +227,7 @@ template <typename T> void SourceDestBufferImpl::_setNextReal( T inValue )
{
throw E57_EXCEPTION2( ErrorConversionRequired, "pathName=" + pathName_ );
}
- if ( inValue < INT64_MIN || INT64_MAX < inValue )
+ if ( inValue < INT64_MIN || ( inValue > ( static_cast<T>( INT64_MAX ) ) ) )
{
throw E57_EXCEPTION2( ErrorValueNotRepresentable,
"pathName=" + pathName_ + " value=" + toString( inValue ) );
@@ -491,8 +491,9 @@ int64_t SourceDestBufferImpl::getNextInt64( double scale, double offset )
default:
throw E57_EXCEPTION2( ErrorInternal, "pathName=" + pathName_ );
}
+
/// Make sure that value is representable in an int64_t
- if ( doubleRawValue < INT64_MIN || INT64_MAX < doubleRawValue )
+ if ( doubleRawValue < INT64_MIN || ( doubleRawValue > ( static_cast<double>( INT64_MAX ) ) ) )
{
throw E57_EXCEPTION2( ErrorScaledValueNotRepresentable,
"pathName=" + pathName_ + " value=" + toString( doubleRawValue ) );
--
2.41.0

0 comments on commit a5b3e77

Please sign in to comment.