diff --git a/3d-viewer/3d_rendering/raytracing/render_3d_raytrace.cpp b/3d-viewer/3d_rendering/raytracing/render_3d_raytrace.cpp index a2149aefc7..3ad6675532 100644 --- a/3d-viewer/3d_rendering/raytracing/render_3d_raytrace.cpp +++ b/3d-viewer/3d_rendering/raytracing/render_3d_raytrace.cpp @@ -27,7 +27,6 @@ #include #include #include -#include #include #include "render_3d_raytrace.h" diff --git a/common/eda_pattern_match.cpp b/common/eda_pattern_match.cpp index 43070d3d45..39507f54f0 100644 --- a/common/eda_pattern_match.cpp +++ b/common/eda_pattern_match.cpp @@ -23,10 +23,13 @@ */ #include +#include #include #include #include -#include + +// Helper to make the code cleaner when we want this operation +#define CLAMPED_VAL_INT_MAX( x ) std::min( x, static_cast( std::numeric_limits::max() ) ) bool EDA_PATTERN_MATCH_SUBSTR::SetPattern( const wxString& aPattern ) { @@ -114,8 +117,8 @@ EDA_PATTERN_MATCH::FIND_RESULT EDA_PATTERN_MATCH_REGEX::Find( const wxString& aC size_t start, len; m_regex.GetMatch( &start, &len, 0 ); - return { static_cast( std::min( start, static_cast( INT_MAX ) ) ), - static_cast( std::min( len, static_cast( INT_MAX ) ) ) }; + return { static_cast( CLAMPED_VAL_INT_MAX( start ) ), + static_cast( CLAMPED_VAL_INT_MAX( len ) ) }; } else { @@ -295,7 +298,7 @@ EDA_PATTERN_MATCH::FIND_RESULT EDA_PATTERN_MATCH_RELATIONAL::Find( const wxStrin if( found_delta != EDA_PATTERN_NOT_FOUND ) { size_t found = (size_t) found_delta + lastpos; - return { static_cast( std::min( found, static_cast( INT_MAX ) ) ), 0 }; + return { static_cast( CLAMPED_VAL_INT_MAX( found ) ), 0 }; } lastpos = tokenizer.GetPosition(); @@ -318,7 +321,7 @@ int EDA_PATTERN_MATCH_RELATIONAL::FindOne( const wxString& aCandidate ) const wxString val = m_regex_description.GetMatch( aCandidate, 2 ); wxString unit = m_regex_description.GetMatch( aCandidate, 3 ); - int istart = ( start > INT_MAX ) ? INT_MAX : start; + int istart = ( start > std::numeric_limits::max() ) ? std::numeric_limits::max() : start; if( key.Lower() != m_key ) return EDA_PATTERN_NOT_FOUND; diff --git a/eeschema/sch_sheet.cpp b/eeschema/sch_sheet.cpp index 18052dbff8..72d85ea2e1 100644 --- a/eeschema/sch_sheet.cpp +++ b/eeschema/sch_sheet.cpp @@ -23,7 +23,6 @@ */ #include -#include #include #include