From: abn Date: Mon, 21 Sep 2020 15:16:08 +0000 (+0200) Subject: Removing unnecessary comparison (clang -Wtautological-compare) X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=40afdb08c273f6c5a117769c551111e18999de22;p=tools%2Fmedcoupling.git Removing unnecessary comparison (clang -Wtautological-compare) --- diff --git a/src/MEDCoupling/MEDCouplingMemArray.cxx b/src/MEDCoupling/MEDCouplingMemArray.cxx index 1b5a457a8..0708ee57c 100755 --- a/src/MEDCoupling/MEDCouplingMemArray.cxx +++ b/src/MEDCoupling/MEDCouplingMemArray.cxx @@ -204,7 +204,7 @@ void DataArray::copyPartOfStringInfoFrom(const DataArray& other, const std::vect std::size_t nbOfCompoOth=other.getNumberOfComponents(); std::size_t newNbOfCompo=compoIds.size(); for(std::size_t i=0;i=nbOfCompoOth || compoIds[i]<0) + if(compoIds[i]>=nbOfCompoOth) { std::ostringstream oss; oss << "Specified component id is out of range (" << compoIds[i] << ") compared with nb of actual components (" << nbOfCompoOth << ")"; throw INTERP_KERNEL::Exception(oss.str().c_str()); @@ -220,7 +220,7 @@ void DataArray::copyPartOfStringInfoFrom2(const std::vector& compoI std::size_t partOfCompoToSet=compoIds.size(); std::size_t nbOfCompo=getNumberOfComponents(); for(std::size_t i=0;i=nbOfCompo || compoIds[i]<0) + if(compoIds[i]>=nbOfCompo) { std::ostringstream oss; oss << "Specified component id is out of range (" << compoIds[i] << ") compared with nb of actual components (" << nbOfCompo << ")"; throw INTERP_KERNEL::Exception(oss.str().c_str()); diff --git a/src/MEDCoupling/MEDCouplingMemArray.txx b/src/MEDCoupling/MEDCouplingMemArray.txx index 327fbc8b0..14b8b34b7 100755 --- a/src/MEDCoupling/MEDCouplingMemArray.txx +++ b/src/MEDCoupling/MEDCouplingMemArray.txx @@ -1467,7 +1467,7 @@ namespace MEDCoupling std::size_t newNbOfCompo=compoIds.size(); std::size_t oldNbOfCompo=getNumberOfComponents(); for(std::vector::const_iterator it=compoIds.begin();it!=compoIds.end();it++) - if((*it)<0 || (*it)>=oldNbOfCompo) + if((*it)>=oldNbOfCompo) // (*it) >= 0 (it is a size_t) { std::ostringstream oss; oss << Traits::ArrayTypeName << "::keepSelectedComponents : invalid requested component : " << *it << " whereas it should be in [0," << oldNbOfCompo << ") !"; throw INTERP_KERNEL::Exception(oss.str().c_str()); @@ -5252,7 +5252,7 @@ struct NotInRange const T *ptr=this->getConstPointer(); mcIdType nbTuple(this->getNumberOfTuples()); std::size_t nbComps(this->getNumberOfComponents()); - if(compId<0 || compId>=nbComps) + if(compId>=nbComps) // compId >= 0 (it is a size_t) throw INTERP_KERNEL::Exception("DataArrayInt::accumulate : Invalid compId specified : No such nb of components !"); T ret=0; for(mcIdType i=0;i=0 && j tse2;