From f41e8da8dde99846924d1b3132d8924c5b985950 Mon Sep 17 00:00:00 2001 From: Kurt Schwehr Date: Sat, 7 Nov 2015 06:56:18 +0000 Subject: [PATCH] Rewrite the logic in VRTSourcedRasterBand::SetMetadata. CID 1338309 (#1 of 1): Structurally dead code (UNREACHABLE) unreachable: Since the loop increment i++; is unreachable, the loop body will never execute more than once By testing if poSource is a nullptr first and returning an error if it is a nullptr, I think the logic is much easier to follow. I misread the logic here: https://trac.osgeo.org/gdal/browser/trunk/gdal/frmts/vrt/vrtsourcedrasterband.cpp?rev=31122#L1400 and created r31355 that got it wrong. git-svn-id: https://svn.osgeo.org/gdal/trunk@31361 f0d54148-0727-0410-94bb-9a71ac55c965 --- gdal/frmts/vrt/vrtsourcedrasterband.cpp | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/gdal/frmts/vrt/vrtsourcedrasterband.cpp b/gdal/frmts/vrt/vrtsourcedrasterband.cpp index 82ae3a8db386..fe24055867ce 100644 --- a/gdal/frmts/vrt/vrtsourcedrasterband.cpp +++ b/gdal/frmts/vrt/vrtsourcedrasterband.cpp @@ -1380,14 +1380,12 @@ CPLErr VRTSourcedRasterBand::SetMetadata( char **papszNewMD, const char *pszDoma VRTSource *poSource = poDriver->ParseSource( psTree, NULL ); CPLDestroyXMLNode( psTree ); - if( poSource != NULL ) - { - CPLErr eErr = AddSource( poSource ); - if( eErr != CE_None ) - return eErr; - } + if( poSource == NULL ) + return CE_Failure; - return CE_Failure; + CPLErr eErr = AddSource( poSource ); + if( eErr != CE_None ) + return eErr; } return CE_None;