Skip to content

Commit

Permalink
Rewrite the logic in VRTSourcedRasterBand::SetMetadata.
Browse files Browse the repository at this point in the history
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
  • Loading branch information
schwehr committed Nov 7, 2015
1 parent 8f1bc43 commit f41e8da
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions gdal/frmts/vrt/vrtsourcedrasterband.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit f41e8da

Please sign in to comment.