From b801e7151a5db0cec1e98ab6e3be6b3c8d37074f Mon Sep 17 00:00:00 2001 From: Uwe Date: Mon, 18 Jul 2022 02:59:14 +0200 Subject: [PATCH] [libE57] remove superfluous nullptr checks --- .../libE57Format/src/BlobNodeImpl.cpp | 2 +- src/3rdParty/libE57Format/src/CheckedFile.cpp | 6 +-- .../src/CompressedVectorNodeImpl.cpp | 2 +- src/3rdParty/libE57Format/src/Decoder.cpp | 2 +- .../libE57Format/src/E57Exception.cpp | 4 +- .../libE57Format/src/E57XmlParser.cpp | 2 +- .../libE57Format/src/FloatNodeImpl.cpp | 2 +- .../libE57Format/src/ImageFileImpl.cpp | 4 +- .../libE57Format/src/IntegerNodeImpl.cpp | 2 +- src/3rdParty/libE57Format/src/ReaderImpl.cpp | 46 +++++++++---------- .../src/ScaledIntegerNodeImpl.cpp | 2 +- .../libE57Format/src/SourceDestBufferImpl.cpp | 6 +-- .../libE57Format/src/StringNodeImpl.cpp | 2 +- .../libE57Format/src/StructureNodeImpl.cpp | 2 +- .../libE57Format/src/VectorNodeImpl.cpp | 2 +- src/3rdParty/libE57Format/src/WriterImpl.cpp | 2 +- 16 files changed, 44 insertions(+), 44 deletions(-) diff --git a/src/3rdParty/libE57Format/src/BlobNodeImpl.cpp b/src/3rdParty/libE57Format/src/BlobNodeImpl.cpp index 7fe268f1ed..e3187310d6 100644 --- a/src/3rdParty/libE57Format/src/BlobNodeImpl.cpp +++ b/src/3rdParty/libE57Format/src/BlobNodeImpl.cpp @@ -184,7 +184,7 @@ namespace e57 // don't checkImageFileOpen ustring fieldName; - if ( forcedFieldName != nullptr ) + if ( forcedFieldName ) { fieldName = forcedFieldName; } diff --git a/src/3rdParty/libE57Format/src/CheckedFile.cpp b/src/3rdParty/libE57Format/src/CheckedFile.cpp index 2dc4143ccf..17f646d0a9 100644 --- a/src/3rdParty/libE57Format/src/CheckedFile.cpp +++ b/src/3rdParty/libE57Format/src/CheckedFile.cpp @@ -455,7 +455,7 @@ void CheckedFile::seek( uint64_t offset, OffsetMode omode ) uint64_t CheckedFile::lseek64( int64_t offset, int whence ) { - if ( ( fd_ < 0 ) && ( bufView_ != nullptr ) ) + if ( ( fd_ < 0 ) && bufView_ ) { const auto uoffset = static_cast( offset ); @@ -652,7 +652,7 @@ void CheckedFile::close() fd_ = -1; } - if ( bufView_ != nullptr ) + if ( bufView_ ) { delete bufView_; bufView_ = nullptr; @@ -746,7 +746,7 @@ void CheckedFile::readPhysicalPage( char *page_buffer, uint64_t page ) /// Seek to start of physical page seek( page * physicalPageSize, Physical ); - if ( ( fd_ < 0 ) && ( bufView_ != nullptr ) ) + if ( ( fd_ < 0 ) && bufView_ ) { bufView_->read( page_buffer, physicalPageSize ); return; diff --git a/src/3rdParty/libE57Format/src/CompressedVectorNodeImpl.cpp b/src/3rdParty/libE57Format/src/CompressedVectorNodeImpl.cpp index 1dbcb98d37..d6bbd53bcb 100644 --- a/src/3rdParty/libE57Format/src/CompressedVectorNodeImpl.cpp +++ b/src/3rdParty/libE57Format/src/CompressedVectorNodeImpl.cpp @@ -202,7 +202,7 @@ namespace e57 // don't checkImageFileOpen ustring fieldName; - if ( forcedFieldName != nullptr ) + if ( forcedFieldName ) { fieldName = forcedFieldName; } diff --git a/src/3rdParty/libE57Format/src/Decoder.cpp b/src/3rdParty/libE57Format/src/Decoder.cpp index 9eb872ad1a..8b4f468a12 100644 --- a/src/3rdParty/libE57Format/src/Decoder.cpp +++ b/src/3rdParty/libE57Format/src/Decoder.cpp @@ -220,7 +220,7 @@ size_t BitpackDecoder::inputProcess( const char *source, const size_t availableB size_t byteCount = std::min( bytesUnsaved, inBuffer_.size() - static_cast( inBufferEndByte_ ) ); /// Copy input bytes from caller, if any - if ( ( byteCount > 0 ) && ( source != nullptr ) ) + if ( ( byteCount > 0 ) && source ) { memcpy( &inBuffer_[inBufferEndByte_], source, byteCount ); diff --git a/src/3rdParty/libE57Format/src/E57Exception.cpp b/src/3rdParty/libE57Format/src/E57Exception.cpp index ee16efa663..e95afe7724 100644 --- a/src/3rdParty/libE57Format/src/E57Exception.cpp +++ b/src/3rdParty/libE57Format/src/E57Exception.cpp @@ -143,14 +143,14 @@ namespace e57 os << " Debug info: " << std::endl; os << " context: " << context_ << std::endl; os << " sourceFunctionName: " << sourceFunctionName_ << std::endl; - if ( reportingFunctionName != nullptr ) + if ( reportingFunctionName ) os << " reportingFunctionName: " << reportingFunctionName << std::endl; /*** Add a line in error message that a smart editor (gnu emacs) can * interpret as a link to the source code: */ os << sourceFileName_ << "(" << sourceLineNumber_ << ") : error C" << errorCode_ << ": <--- occurred on" << std::endl; - if ( reportingFileName != nullptr ) + if ( reportingFileName ) os << reportingFileName << "(" << reportingLineNumber << ") : error C0: <--- reported on" << std::endl; #endif } diff --git a/src/3rdParty/libE57Format/src/E57XmlParser.cpp b/src/3rdParty/libE57Format/src/E57XmlParser.cpp index ef60ab848a..eecc2ea289 100644 --- a/src/3rdParty/libE57Format/src/E57XmlParser.cpp +++ b/src/3rdParty/libE57Format/src/E57XmlParser.cpp @@ -252,7 +252,7 @@ void E57XmlParser::init() xmlReader = XMLReaderFactory::createXMLReader(); //??? auto_ptr? - if ( xmlReader == nullptr ) + if ( !xmlReader ) { throw E57_EXCEPTION2( E57_ERROR_XML_PARSER_INIT, "could not create the xml reader" ); } diff --git a/src/3rdParty/libE57Format/src/FloatNodeImpl.cpp b/src/3rdParty/libE57Format/src/FloatNodeImpl.cpp index 865b8638ec..7bdb15fa45 100644 --- a/src/3rdParty/libE57Format/src/FloatNodeImpl.cpp +++ b/src/3rdParty/libE57Format/src/FloatNodeImpl.cpp @@ -149,7 +149,7 @@ namespace e57 // don't checkImageFileOpen ustring fieldName; - if ( forcedFieldName != nullptr ) + if ( forcedFieldName ) { fieldName = forcedFieldName; } diff --git a/src/3rdParty/libE57Format/src/ImageFileImpl.cpp b/src/3rdParty/libE57Format/src/ImageFileImpl.cpp index 8d05d26af2..fbc9c5924e 100644 --- a/src/3rdParty/libE57Format/src/ImageFileImpl.cpp +++ b/src/3rdParty/libE57Format/src/ImageFileImpl.cpp @@ -290,7 +290,7 @@ namespace e57 void ImageFileImpl::close() { /// If file already closed, have nothing to do - if ( file_ == nullptr ) + if ( !file_ ) { return; } @@ -349,7 +349,7 @@ namespace e57 void ImageFileImpl::cancel() { /// If file already closed, have nothing to do - if ( file_ == nullptr ) + if ( !file_ ) { return; } diff --git a/src/3rdParty/libE57Format/src/IntegerNodeImpl.cpp b/src/3rdParty/libE57Format/src/IntegerNodeImpl.cpp index de9e73081e..492baab0ae 100644 --- a/src/3rdParty/libE57Format/src/IntegerNodeImpl.cpp +++ b/src/3rdParty/libE57Format/src/IntegerNodeImpl.cpp @@ -120,7 +120,7 @@ namespace e57 // don't checkImageFileOpen ustring fieldName; - if ( forcedFieldName != nullptr ) + if ( forcedFieldName ) { fieldName = forcedFieldName; } diff --git a/src/3rdParty/libE57Format/src/ReaderImpl.cpp b/src/3rdParty/libE57Format/src/ReaderImpl.cpp index 89f7f762d1..1b53258068 100644 --- a/src/3rdParty/libE57Format/src/ReaderImpl.cpp +++ b/src/3rdParty/libE57Format/src/ReaderImpl.cpp @@ -1303,117 +1303,117 @@ namespace e57 bool haveNormalsExt = imf_.extensionsLookupPrefix( "nor", norExtUri ); if ( ( name.compare( "cartesianX" ) == 0 ) && proto.isDefined( "cartesianX" ) && - ( buffers.cartesianX != nullptr ) ) + buffers.cartesianX ) { destBuffers.emplace_back( imf_, "cartesianX", buffers.cartesianX, count, true, scaled ); } else if ( ( name.compare( "cartesianY" ) == 0 ) && proto.isDefined( "cartesianY" ) && - ( buffers.cartesianY != nullptr ) ) + buffers.cartesianY ) { destBuffers.emplace_back( imf_, "cartesianY", buffers.cartesianY, count, true, scaled ); } else if ( ( name.compare( "cartesianZ" ) == 0 ) && proto.isDefined( "cartesianZ" ) && - ( buffers.cartesianZ != nullptr ) ) + buffers.cartesianZ ) { destBuffers.emplace_back( imf_, "cartesianZ", buffers.cartesianZ, count, true, scaled ); } else if ( ( name.compare( "cartesianInvalidState" ) == 0 ) && proto.isDefined( "cartesianInvalidState" ) && - ( buffers.cartesianInvalidState != nullptr ) ) + buffers.cartesianInvalidState ) { destBuffers.emplace_back( imf_, "cartesianInvalidState", buffers.cartesianInvalidState, count, true ); } else if ( ( name.compare( "sphericalRange" ) == 0 ) && proto.isDefined( "sphericalRange" ) && - ( buffers.sphericalRange != nullptr ) ) + buffers.sphericalRange ) { destBuffers.emplace_back( imf_, "sphericalRange", buffers.sphericalRange, count, true, scaled ); } else if ( ( name.compare( "sphericalAzimuth" ) == 0 ) && proto.isDefined( "sphericalAzimuth" ) && - ( buffers.sphericalAzimuth != nullptr ) ) + buffers.sphericalAzimuth ) { destBuffers.emplace_back( imf_, "sphericalAzimuth", buffers.sphericalAzimuth, count, true, scaled ); } else if ( ( name.compare( "sphericalElevation" ) == 0 ) && proto.isDefined( "sphericalElevation" ) && - ( buffers.sphericalElevation != nullptr ) ) + buffers.sphericalElevation ) { destBuffers.emplace_back( imf_, "sphericalElevation", buffers.sphericalElevation, count, true, scaled ); } else if ( ( name.compare( "sphericalInvalidState" ) == 0 ) && proto.isDefined( "sphericalInvalidState" ) && - ( buffers.sphericalInvalidState != nullptr ) ) + buffers.sphericalInvalidState ) { destBuffers.emplace_back( imf_, "sphericalInvalidState", buffers.sphericalInvalidState, count, true ); } else if ( ( name.compare( "rowIndex" ) == 0 ) && proto.isDefined( "rowIndex" ) && - ( buffers.rowIndex != nullptr ) ) + buffers.rowIndex ) { destBuffers.emplace_back( imf_, "rowIndex", buffers.rowIndex, count, true ); } else if ( ( name.compare( "columnIndex" ) == 0 ) && proto.isDefined( "columnIndex" ) && - ( buffers.columnIndex != nullptr ) ) + buffers.columnIndex ) { destBuffers.emplace_back( imf_, "columnIndex", buffers.columnIndex, count, true ); } else if ( ( name.compare( "returnIndex" ) == 0 ) && proto.isDefined( "returnIndex" ) && - ( buffers.returnIndex != nullptr ) ) + buffers.returnIndex ) { destBuffers.emplace_back( imf_, "returnIndex", buffers.returnIndex, count, true ); } else if ( ( name.compare( "returnCount" ) == 0 ) && proto.isDefined( "returnCount" ) && - ( buffers.returnCount != nullptr ) ) + buffers.returnCount ) { destBuffers.emplace_back( imf_, "returnCount", buffers.returnCount, count, true ); } else if ( ( name.compare( "timeStamp" ) == 0 ) && proto.isDefined( "timeStamp" ) && - ( buffers.timeStamp != nullptr ) ) + buffers.timeStamp ) { destBuffers.emplace_back( imf_, "timeStamp", buffers.timeStamp, count, true, scaled ); } else if ( ( name.compare( "isTimeStampInvalid" ) == 0 ) && proto.isDefined( "isTimeStampInvalid" ) && - ( buffers.isTimeStampInvalid != nullptr ) ) + buffers.isTimeStampInvalid ) { destBuffers.emplace_back( imf_, "isTimeStampInvalid", buffers.isTimeStampInvalid, count, true ); } else if ( ( name.compare( "intensity" ) == 0 ) && proto.isDefined( "intensity" ) && - ( buffers.intensity != nullptr ) ) + buffers.intensity ) { destBuffers.emplace_back( imf_, "intensity", buffers.intensity, count, true, scaled ); } else if ( ( name.compare( "isIntensityInvalid" ) == 0 ) && proto.isDefined( "isIntensityInvalid" ) && - ( buffers.isIntensityInvalid != nullptr ) ) + buffers.isIntensityInvalid ) { destBuffers.emplace_back( imf_, "isIntensityInvalid", buffers.isIntensityInvalid, count, true ); } else if ( ( name.compare( "colorRed" ) == 0 ) && proto.isDefined( "colorRed" ) && - ( buffers.colorRed != nullptr ) ) + buffers.colorRed ) { destBuffers.emplace_back( imf_, "colorRed", buffers.colorRed, count, true, scaled ); } else if ( ( name.compare( "colorGreen" ) == 0 ) && proto.isDefined( "colorGreen" ) && - ( buffers.colorGreen != nullptr ) ) + buffers.colorGreen ) { destBuffers.emplace_back( imf_, "colorGreen", buffers.colorGreen, count, true, scaled ); } else if ( ( name.compare( "colorBlue" ) == 0 ) && proto.isDefined( "colorBlue" ) && - ( buffers.colorBlue != nullptr ) ) + buffers.colorBlue ) { destBuffers.emplace_back( imf_, "colorBlue", buffers.colorBlue, count, true, scaled ); } else if ( ( name.compare( "isColorInvalid" ) == 0 ) && proto.isDefined( "isColorInvalid" ) && - ( buffers.isColorInvalid != nullptr ) ) + buffers.isColorInvalid ) { destBuffers.emplace_back( imf_, "isColorInvalid", buffers.isColorInvalid, count, true ); } else if ( haveNormalsExt && ( name.compare( "nor:normalX" ) == 0 ) && proto.isDefined( "nor:normalX" ) && - ( buffers.normalX != nullptr ) ) + buffers.normalX ) { destBuffers.emplace_back( imf_, "nor:normalX", buffers.normalX, count, true, scaled ); } else if ( haveNormalsExt && ( name.compare( "nor:normalY" ) == 0 ) && proto.isDefined( "nor:normalY" ) && - ( buffers.normalY != nullptr ) ) + buffers.normalY ) { destBuffers.emplace_back( imf_, "nor:normalY", buffers.normalY, count, true, scaled ); } else if ( haveNormalsExt && ( name.compare( "nor:normalZ" ) == 0 ) && proto.isDefined( "nor:normalZ" ) && - ( buffers.normalZ != nullptr ) ) + buffers.normalZ ) { destBuffers.emplace_back( imf_, "nor:normalZ", buffers.normalZ, count, true, scaled ); } diff --git a/src/3rdParty/libE57Format/src/ScaledIntegerNodeImpl.cpp b/src/3rdParty/libE57Format/src/ScaledIntegerNodeImpl.cpp index c6fc94b13d..90c40c6873 100644 --- a/src/3rdParty/libE57Format/src/ScaledIntegerNodeImpl.cpp +++ b/src/3rdParty/libE57Format/src/ScaledIntegerNodeImpl.cpp @@ -183,7 +183,7 @@ namespace e57 // don't checkImageFileOpen ustring fieldName; - if ( forcedFieldName != nullptr ) + if ( forcedFieldName ) { fieldName = forcedFieldName; } diff --git a/src/3rdParty/libE57Format/src/SourceDestBufferImpl.cpp b/src/3rdParty/libE57Format/src/SourceDestBufferImpl.cpp index c3563730e2..010a27296c 100644 --- a/src/3rdParty/libE57Format/src/SourceDestBufferImpl.cpp +++ b/src/3rdParty/libE57Format/src/SourceDestBufferImpl.cpp @@ -112,7 +112,7 @@ SourceDestBufferImpl::SourceDestBufferImpl( ImageFileImplWeakPtr destImageFile, /// don't checkImageFileOpen, checkState_ will do it /// Set capacity_ after testing that b is OK - if ( b == nullptr ) + if ( !b ) { throw E57_EXCEPTION2( E57_ERROR_BAD_BUFFER, "sdbuf.pathName=" + pathName ); } @@ -291,7 +291,7 @@ void SourceDestBufferImpl::checkState_() const if ( memoryRepresentation_ != E57_USTRING ) { - if ( base_ == nullptr ) + if ( !base_ ) { throw E57_EXCEPTION2( E57_ERROR_BAD_BUFFER, "pathName=" + pathName_ ); } @@ -304,7 +304,7 @@ void SourceDestBufferImpl::checkState_() const } else { - if ( ustrings_ == nullptr ) + if ( !ustrings_ ) { throw E57_EXCEPTION2( E57_ERROR_BAD_BUFFER, "pathName=" + pathName_ ); } diff --git a/src/3rdParty/libE57Format/src/StringNodeImpl.cpp b/src/3rdParty/libE57Format/src/StringNodeImpl.cpp index 91d1faf317..8d03d58138 100644 --- a/src/3rdParty/libE57Format/src/StringNodeImpl.cpp +++ b/src/3rdParty/libE57Format/src/StringNodeImpl.cpp @@ -83,7 +83,7 @@ namespace e57 // don't checkImageFileOpen ustring fieldName; - if ( forcedFieldName != nullptr ) + if ( forcedFieldName ) { fieldName = forcedFieldName; } diff --git a/src/3rdParty/libE57Format/src/StructureNodeImpl.cpp b/src/3rdParty/libE57Format/src/StructureNodeImpl.cpp index af9bd168ea..e4aacb6ca0 100644 --- a/src/3rdParty/libE57Format/src/StructureNodeImpl.cpp +++ b/src/3rdParty/libE57Format/src/StructureNodeImpl.cpp @@ -387,7 +387,7 @@ void StructureNodeImpl::writeXml( ImageFileImplSharedPtr imf, CheckedFile &cf, i /// don't checkImageFileOpen ustring fieldName; - if ( forcedFieldName != nullptr ) + if ( forcedFieldName ) { fieldName = forcedFieldName; } diff --git a/src/3rdParty/libE57Format/src/VectorNodeImpl.cpp b/src/3rdParty/libE57Format/src/VectorNodeImpl.cpp index 707858e83a..9534375a23 100644 --- a/src/3rdParty/libE57Format/src/VectorNodeImpl.cpp +++ b/src/3rdParty/libE57Format/src/VectorNodeImpl.cpp @@ -103,7 +103,7 @@ namespace e57 /// don't checkImageFileOpen ustring fieldName; - if ( forcedFieldName != nullptr ) + if ( forcedFieldName ) { fieldName = forcedFieldName; } diff --git a/src/3rdParty/libE57Format/src/WriterImpl.cpp b/src/3rdParty/libE57Format/src/WriterImpl.cpp index c1d3afc110..d09009d735 100644 --- a/src/3rdParty/libE57Format/src/WriterImpl.cpp +++ b/src/3rdParty/libE57Format/src/WriterImpl.cpp @@ -1017,7 +1017,7 @@ namespace e57 sourceBuffers.emplace_back( imf_, "timeStamp", buffers.timeStamp, count, true, true ); } - if ( proto.isDefined( "cartesianInvalidState" ) && ( buffers.cartesianInvalidState != nullptr ) ) + if ( proto.isDefined( "cartesianInvalidState" ) && buffers.cartesianInvalidState ) { sourceBuffers.emplace_back( imf_, "cartesianInvalidState", buffers.cartesianInvalidState, count, true ); }