Skip to content

Commit

Permalink
Issues/0139 macos compile warnings (#149)
Browse files Browse the repository at this point in the history
* 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:
  • Loading branch information
michaeldsmith authored Apr 15, 2024
1 parent 4a8bcf0 commit 2adb330
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 13 deletions.
2 changes: 1 addition & 1 deletion ctlrender/transform.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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 <module_name> (%s) function", module);
snprintf( message_text, 512, "CTL file must contain either a main or <module_name> (%s) function", module);
THROW(Iex::ArgExc, message_text);
}

Expand Down
49 changes: 42 additions & 7 deletions lib/IlmCtl/CtlType.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}


Expand Down Expand Up @@ -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);
}


Expand Down Expand Up @@ -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);
}


Expand Down Expand Up @@ -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);
}


Expand Down Expand Up @@ -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);
}


Expand Down Expand Up @@ -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);
}


Expand Down Expand Up @@ -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);
}


Expand Down
9 changes: 5 additions & 4 deletions lib/dpx/dpx.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
3 changes: 2 additions & 1 deletion lib/dpx/dpx_rw.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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...
}
}
Expand Down

0 comments on commit 2adb330

Please sign in to comment.