From 2adb330a641b0eed2b8a901c9328a714cad3f46f Mon Sep 17 00:00:00 2001 From: michaeldsmith <37905569+michaeldsmith@users.noreply.github.com> Date: Mon, 15 Apr 2024 07:09:20 -0700 Subject: [PATCH] Issues/0139 macos compile warnings (#149) * fixes warning: expression with side effects will be evaluated despite being used as an operand to 'typeid' [-Wpotentially-evaluated-expression] * move expression evaluation outside typeid() * fixes warning: result of comparison of constant 'little_endian' (3) with expression of type 'bool' is always true [-Wtautological-constant-out-of-range-compare] * fixes warning: self-comparison always evaluates to false [-Wtautological-compare] * fixes warning: 'sprintf' is deprecated: --- ctlrender/transform.cc | 2 +- lib/IlmCtl/CtlType.cpp | 49 ++++++++++++++++++++++++++++++++++++------ lib/dpx/dpx.cc | 9 ++++---- lib/dpx/dpx_rw.cc | 3 ++- 4 files changed, 50 insertions(+), 13 deletions(-) diff --git a/ctlrender/transform.cc b/ctlrender/transform.cc index a78da758..dd14b007 100644 --- a/ctlrender/transform.cc +++ b/ctlrender/transform.cc @@ -394,7 +394,7 @@ void run_ctl_transform(const ctl_operation_t &ctl_operation, CTLResults *ctl_res } } catch (...) { char message_text[512] = {'\0'}; - sprintf( message_text, "CTL file must contain either a main or (%s) function", module); + snprintf( message_text, 512, "CTL file must contain either a main or (%s) function", module); THROW(Iex::ArgExc, message_text); } diff --git a/lib/IlmCtl/CtlType.cpp b/lib/IlmCtl/CtlType.cpp index 3a66557d..ff8d37f1 100644 --- a/lib/IlmCtl/CtlType.cpp +++ b/lib/IlmCtl/CtlType.cpp @@ -204,7 +204,12 @@ VoidType::VoidType (): DataType () bool VoidType::isSameTypeAs (const TypePtr &t) const { - return t && typeid (*this) == typeid (*t); + auto& t1 = *this; + const type_info& ti1 = typeid(t1); + auto& t2 = *t; + const type_info& ti2 = typeid(t2); + return t && ti1 == ti2; + //return t && typeid (*this) == typeid (*t); } @@ -282,7 +287,12 @@ BoolType::BoolType () : DataType () bool BoolType::isSameTypeAs (const TypePtr &t) const { - return t && typeid (*this) == typeid (*t); + auto& t1 = *this; + const type_info& ti1 = typeid(t1); + auto& t2 = *t; + const type_info& ti2 = typeid(t2); + return t && ti1 == ti2; + //return t && typeid (*this) == typeid (*t); } @@ -463,7 +473,12 @@ IntType::IntType () : DataType () bool IntType::isSameTypeAs (const TypePtr &t) const { - return t && typeid (*this) == typeid (*t); + auto& t1 = *this; + const type_info& ti1 = typeid(t1); + auto& t2 = *t; + const type_info& ti2 = typeid(t2); + return t && ti1 == ti2; + //return t && typeid (*this) == typeid (*t); } @@ -678,7 +693,12 @@ UIntType::UIntType () : DataType () bool UIntType::isSameTypeAs (const TypePtr &t) const { - return t && typeid (*this) == typeid (*t); + auto& t1 = *this; + const type_info& ti1 = typeid(t1); + auto& t2 = *t; + const type_info& ti2 = typeid(t2); + return t && ti1 == ti2; + //return t && typeid (*this) == typeid (*t); } @@ -892,7 +912,12 @@ HalfType::HalfType (): DataType () bool HalfType::isSameTypeAs (const TypePtr &t) const { - return t && typeid (*this) == typeid (*t); + auto& t1 = *this; + const type_info& ti1 = typeid(t1); + auto& t2 = *t; + const type_info& ti2 = typeid(t2); + return t && ti1 == ti2; + //return t && typeid (*this) == typeid (*t); } @@ -1076,7 +1101,12 @@ FloatType::FloatType (): DataType () bool FloatType::isSameTypeAs (const TypePtr &t) const { - return t && typeid (*this) == typeid (*t); + auto& t1 = *this; + const type_info& ti1 = typeid(t1); + auto& t2 = *t; + const type_info& ti2 = typeid(t2); + return t && ti1 == ti2; + //return t && typeid (*this) == typeid (*t); } @@ -1261,7 +1291,12 @@ StringType::StringType (): DataType () bool StringType::isSameTypeAs (const TypePtr &t) const { - return t && typeid (*this) == typeid (*t); + auto& t1 = *this; + const type_info& ti1 = typeid(t1); + auto& t2 = *t; + const type_info& ti2 = typeid(t2); + return t && ti1 == ti2; + //return t && typeid (*this) == typeid (*t); } diff --git a/lib/dpx/dpx.cc b/lib/dpx/dpx.cc index 67cbc430..bcf557ea 100644 --- a/lib/dpx/dpx.cc +++ b/lib/dpx/dpx.cc @@ -387,10 +387,11 @@ void dpx::write(std::ostream *os) cpu_is_little_endian=TRUE; } - _need_byteswap=FALSE; - if(cpu_is_little_endian!=little_endian) { - _need_byteswap=TRUE; - } + //_need_byteswap=FALSE; + //if(cpu_is_little_endian!=little_endian) { + // _need_byteswap=TRUE; + //} + _need_byteswap=TRUE; // struct tm source_creation_time_tm; // time_t source_creation_time_time; diff --git a/lib/dpx/dpx_rw.cc b/lib/dpx/dpx_rw.cc index 2c197806..7d9e9b5a 100644 --- a/lib/dpx/dpx_rw.cc +++ b/lib/dpx/dpx_rw.cc @@ -261,7 +261,8 @@ void rwinfo::write_init(std::ostream *o, dpx *h) { if(h->current_compliance!=h->compliance) { // XXX changed validation level... This will probably end in tears... } - if(h->current_endian_mode!=h->current_endian_mode) { + //if(h->current_endian_mode!=h->current_endian_mode) { + if(h->current_endian_mode!=h->endian_mode) { // XXX byteswap changed. this will probably end in tears... } }