Skip to content

Commit

Permalink
Fix numerous CLang -Wshadow-field warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
rouault committed Mar 20, 2022
1 parent 8a7ea1b commit 3f6c8dc
Show file tree
Hide file tree
Showing 61 changed files with 505 additions and 508 deletions.
4 changes: 2 additions & 2 deletions apps/gdaldem_lib.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@
* For terrestrial use cases, implements
* Riley, S.J., De Gloria, S.D., Elliot, R. (1999): A Terrain Ruggedness
* that Quantifies Topographic Heterogeneity. Intermountain Journal of Science, Vol.5, No.1-4, pp.23-27
*
*
*
* TPI - Topographic Position Index follows the description in
* Wilson et al. (2007), following Weiss (2001). The radius is fixed
Expand Down Expand Up @@ -2847,7 +2847,7 @@ class GDALGeneric3x3RasterBand : public GDALRasterBand
void InitWithNoData( void* pImage );

public:
GDALGeneric3x3RasterBand( GDALGeneric3x3Dataset<T> *poDS,
GDALGeneric3x3RasterBand( GDALGeneric3x3Dataset<T> *poDSIn,
GDALDataType eDstDataType );

virtual CPLErr IReadBlock( int, int, void * ) override;
Expand Down
8 changes: 4 additions & 4 deletions frmts/adrg/adrgdataset.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ class ADRGDataset final: public GDALPamDataset

static GDALDataset *Open( GDALOpenInfo * );
static GDALDataset *Create(const char* pszFilename, int nXSize, int nYSize,
int nBands, GDALDataType eType, char **papszOptions);
int nBandsIn, GDALDataType eType, char **papszOptions);

static double GetLongitudeFromString(const char* str);
static double GetLatitudeFromString(const char* str);
Expand Down Expand Up @@ -1648,7 +1648,7 @@ GDALDataset *ADRGDataset::Open( GDALOpenInfo * poOpenInfo )
GDALDataset *ADRGDataset::Create( const char* pszFilename,
int nXSize,
int nYSize,
int nBands,
int nBandsIn,
GDALDataType eType,
CPL_UNUSED char **papszOptions )
{
Expand All @@ -1662,12 +1662,12 @@ GDALDataset *ADRGDataset::Create( const char* pszFilename,
return nullptr;
}

if( nBands != 3 )
if( nBandsIn != 3 )
{
CPLError( CE_Failure, CPLE_NotSupported,
"ADRG driver doesn't support %d bands. "
"Must be 3 (rgb) bands.",
nBands );
nBandsIn );
return nullptr;
}

Expand Down
14 changes: 7 additions & 7 deletions frmts/bmp/bmpdataset.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ class BMPDataset final: public GDALPamDataset
static int Identify( GDALOpenInfo * );
static GDALDataset *Open( GDALOpenInfo * );
static GDALDataset *Create( const char * pszFilename,
int nXSize, int nYSize, int nBands,
int nXSize, int nYSize, int nBandsIn,
GDALDataType eType, char ** papszParamList );

CPLErr GetGeoTransform( double * padfTransform ) override;
Expand Down Expand Up @@ -1412,7 +1412,7 @@ GDALDataset *BMPDataset::Open( GDALOpenInfo * poOpenInfo )
/************************************************************************/

GDALDataset *BMPDataset::Create( const char * pszFilename,
int nXSize, int nYSize, int nBands,
int nXSize, int nYSize, int nBandsIn,
GDALDataType eType, char **papszOptions )

{
Expand All @@ -1426,11 +1426,11 @@ GDALDataset *BMPDataset::Create( const char * pszFilename,
return nullptr;
}

if( nBands != 1 && nBands != 3 )
if( nBandsIn != 1 && nBandsIn != 3 )
{
CPLError( CE_Failure, CPLE_NotSupported,
"BMP driver doesn't support %d bands. Must be 1 or 3.\n",
nBands );
nBandsIn );

return nullptr;
}
Expand Down Expand Up @@ -1459,7 +1459,7 @@ GDALDataset *BMPDataset::Create( const char * pszFilename,
poDS->sInfoHeader.iWidth = nXSize;
poDS->sInfoHeader.iHeight = nYSize;
poDS->sInfoHeader.iPlanes = 1;
poDS->sInfoHeader.iBitCount = ( nBands == 3 )?24:8;
poDS->sInfoHeader.iBitCount = ( nBandsIn == 3 )?24:8;
poDS->sInfoHeader.iCompression = BMPC_RGB;

/* XXX: Avoid integer overflow. We can calculate size in one
Expand Down Expand Up @@ -1495,7 +1495,7 @@ GDALDataset *BMPDataset::Create( const char * pszFilename,
/* -------------------------------------------------------------------- */
/* Do we need colour table? */
/* -------------------------------------------------------------------- */
if ( nBands == 1 )
if ( nBandsIn == 1 )
{
poDS->sInfoHeader.iClrUsed = 1 << poDS->sInfoHeader.iBitCount;
poDS->pabyColorTable =
Expand Down Expand Up @@ -1594,7 +1594,7 @@ GDALDataset *BMPDataset::Create( const char * pszFilename,
poDS->nRasterXSize = nXSize;
poDS->nRasterYSize = nYSize;
poDS->eAccess = GA_Update;
poDS->nBands = nBands;
poDS->nBands = nBandsIn;

/* -------------------------------------------------------------------- */
/* Create band information objects. */
Expand Down
14 changes: 7 additions & 7 deletions frmts/elas/elasdataset.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ class ELASDataset final: public GDALPamDataset
static GDALDataset *Open( GDALOpenInfo * );
static int Identify( GDALOpenInfo * );
static GDALDataset *Create( const char * pszFilename,
int nXSize, int nYSize, int nBands,
int nXSize, int nYSize, int nBandsIn,
GDALDataType eType, char ** papszParamList );

void FlushCache(bool bAtClosing) override;
Expand Down Expand Up @@ -504,18 +504,18 @@ GDALDataset *ELASDataset::Open( GDALOpenInfo * poOpenInfo )
/************************************************************************/

GDALDataset *ELASDataset::Create( const char * pszFilename,
int nXSize, int nYSize, int nBands,
int nXSize, int nYSize, int nBandsIn,
GDALDataType eType,
char ** /* notdef: papszParamList */ )

{
/* -------------------------------------------------------------------- */
/* Verify input options. */
/* -------------------------------------------------------------------- */
if (nBands <= 0)
if (nBandsIn <= 0)
{
CPLError( CE_Failure, CPLE_NotSupported,
"ELAS driver does not support %d bands.\n", nBands);
"ELAS driver does not support %d bands.\n", nBandsIn);
return nullptr;
}

Expand Down Expand Up @@ -562,15 +562,15 @@ GDALDataset *ELASDataset::Create( const char * pszFilename,

sHeader.NBIH = CPL_MSBWORD32(1024);

sHeader.NBPR = CPL_MSBWORD32(nBands * nBandOffset);
sHeader.NBPR = CPL_MSBWORD32(nBandsIn * nBandOffset);

sHeader.IL = CPL_MSBWORD32(1);
sHeader.LL = CPL_MSBWORD32(nYSize);

sHeader.IE = CPL_MSBWORD32(1);
sHeader.LE = CPL_MSBWORD32(nXSize);

sHeader.NC = CPL_MSBWORD32(nBands);
sHeader.NC = CPL_MSBWORD32(nBandsIn);

sHeader.H4321 = CPL_MSBWORD32(4321);

Expand All @@ -594,7 +594,7 @@ GDALDataset *ELASDataset::Create( const char * pszFilename,
/* Now write out zero data for all the imagery. This is */
/* inefficient, but simplifies IReadBlock() / IWriteBlock() logic. */
/* -------------------------------------------------------------------- */
GByte *pabyLine = (GByte *) CPLCalloc(nBandOffset,nBands);
GByte *pabyLine = (GByte *) CPLCalloc(nBandOffset,nBandsIn);
for( int iLine = 0; iLine < nYSize; iLine++ )
{
if( VSIFWrite( pabyLine, 1, nBandOffset, fp ) != (size_t) nBandOffset )
Expand Down
12 changes: 6 additions & 6 deletions frmts/ers/ersdataset.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ class ERSDataset final: public RawDataset
static GDALDataset *Open( GDALOpenInfo * );
static int Identify( GDALOpenInfo * );
static GDALDataset *Create( const char * pszFilename,
int nXSize, int nYSize, int nBands,
int nXSize, int nYSize, int nBandsIn,
GDALDataType eType, char ** papszParamList );
};

Expand Down Expand Up @@ -1334,17 +1334,17 @@ GDALDataset *ERSDataset::Open( GDALOpenInfo * poOpenInfo )
/************************************************************************/

GDALDataset *ERSDataset::Create( const char * pszFilename,
int nXSize, int nYSize, int nBands,
int nXSize, int nYSize, int nBandsIn,
GDALDataType eType, char ** papszOptions )

{
/* -------------------------------------------------------------------- */
/* Verify settings. */
/* -------------------------------------------------------------------- */
if (nBands <= 0)
if (nBandsIn <= 0)
{
CPLError( CE_Failure, CPLE_NotSupported,
"ERS driver does not support %d bands.\n", nBands);
"ERS driver does not support %d bands.\n", nBandsIn);
return nullptr;
}

Expand Down Expand Up @@ -1422,7 +1422,7 @@ GDALDataset *ERSDataset::Create( const char * pszFilename,
}

GUIntBig nSize = nXSize * (GUIntBig) nYSize
* nBands * (GDALGetDataTypeSize(eType) / 8);
* nBandsIn * (GDALGetDataTypeSize(eType) / 8);
GByte byZero = 0;
if( VSIFSeekL( fpBin, nSize-1, SEEK_SET ) != 0
|| VSIFWriteL( &byZero, 1, 1, fpBin ) != 1 )
Expand Down Expand Up @@ -1464,7 +1464,7 @@ GDALDataset *ERSDataset::Create( const char * pszFilename,
VSIFPrintfL( fpERS, "\t\tCellType\t= %s\n", pszCellType );
VSIFPrintfL( fpERS, "\t\tNrOfLines\t= %d\n", nYSize );
VSIFPrintfL( fpERS, "\t\tNrOfCellsPerLine\t= %d\n", nXSize );
VSIFPrintfL( fpERS, "\t\tNrOfBands\t= %d\n", nBands );
VSIFPrintfL( fpERS, "\t\tNrOfBands\t= %d\n", nBandsIn );
VSIFPrintfL( fpERS, "\tRasterInfo End\n" );
if( VSIFPrintfL( fpERS, "DatasetHeader End\n" ) < 17 )
{
Expand Down
10 changes: 5 additions & 5 deletions frmts/exr/exrdataset.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ class GDALEXRDataset final: public GDALPamDataset
static int Identify(GDALOpenInfo* poOpenInfo);
static GDALDataset* Open(GDALOpenInfo* poOpenInfo);
static GDALDataset *Create( const char * pszFilename,
int nXSize, int nYSize, int nBands,
int nXSize, int nYSize, int nBandsIn,
GDALDataType eType, char ** papszOptions );
static GDALDataset *CreateCopy( const char * pszFilename,
GDALDataset *poSrcDS,
Expand Down Expand Up @@ -1916,10 +1916,10 @@ CPLErr GDALEXRWritableRasterBand::IWriteBlock(int nBlockXOff,
/************************************************************************/

GDALDataset *GDALEXRDataset::Create( const char * pszFilename,
int nXSize, int nYSize, int nBands,
int nXSize, int nYSize, int nBandsIn,
GDALDataType eType, char ** papszOptions )
{
if( nBands == 0 )
if( nBandsIn == 0 )
return nullptr;
const PixelType pixelType = getPixelType(eType, papszOptions);

Expand Down Expand Up @@ -2014,12 +2014,12 @@ GDALDataset *GDALEXRDataset::Create( const char * pszFilename,
poDS->m_bRescaleDiv255 =
CPLTestBool(CSLFetchNameValueDef(papszOptions, "AUTO_RESCALE", "YES"));

if( nBands > 1 )
if( nBandsIn > 1 )
{
poDS->GDALDataset::SetMetadataItem("INTERLEAVE", "PIXEL",
"IMAGE_STRUCTURE");
}
for(int i = 0; i < nBands; i++ )
for(int i = 0; i < nBandsIn; i++ )
{
poDS->SetBand(i+1, new GDALEXRWritableRasterBand(poDS.get(), i+1, eType));
}
Expand Down
14 changes: 7 additions & 7 deletions frmts/fits/fitsdataset.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ class FITSDataset final : public GDALPamDataset {
static GDALDataset* Open( GDALOpenInfo* );
static int Identify( GDALOpenInfo* );
static GDALDataset* Create( const char* pszFilename,
int nXSize, int nYSize, int nBands,
int nXSize, int nYSize, int nBandsIn,
GDALDataType eType,
char** papszParamList );
static CPLErr Delete( const char * pszFilename );
Expand Down Expand Up @@ -2657,12 +2657,12 @@ GDALDataset* FITSDataset::Open(GDALOpenInfo* poOpenInfo) {

GDALDataset *FITSDataset::Create( const char* pszFilename,
int nXSize, int nYSize,
int nBands, GDALDataType eType,
int nBandsIn, GDALDataType eType,
CPL_UNUSED char** papszParamList )
{
int status = 0;

if( nXSize == 0 && nYSize == 0 && nBands == 0 && eType == GDT_Unknown )
if( nXSize == 0 && nYSize == 0 && nBandsIn == 0 && eType == GDT_Unknown )
{
// Create the file - to force creation, we prepend the name with '!'
CPLString extFilename("!");
Expand Down Expand Up @@ -2690,12 +2690,12 @@ GDALDataset *FITSDataset::Create( const char* pszFilename,
// 2018 - BZERO BSCALE keywords are now set using SetScale() and
// SetOffset() functions

if( nXSize < 1 || nYSize < 1 || nBands < 1 ) {
if( nXSize < 1 || nYSize < 1 || nBandsIn < 1 ) {
CPLError(
CE_Failure, CPLE_AppDefined,
"Attempt to create %dx%dx%d raster FITS file, but width, height and bands"
" must be positive.",
nXSize, nYSize, nBands );
nXSize, nYSize, nBandsIn );

return nullptr;
}
Expand Down Expand Up @@ -2734,8 +2734,8 @@ GDALDataset *FITSDataset::Create( const char* pszFilename,
}

// Now create an image of appropriate size and type
long naxes[3] = {nXSize, nYSize, nBands};
int naxis = (nBands == 1) ? 2 : 3;
long naxes[3] = {nXSize, nYSize, nBandsIn};
int naxis = (nBandsIn == 1) ? 2 : 3;
fits_create_img(hFITS, bitpix, naxis, naxes, &status);

// Check the status
Expand Down
6 changes: 3 additions & 3 deletions frmts/gsg/gs7bgdataset.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ class GS7BGDataset final: public GDALPamDataset
static int Identify( GDALOpenInfo * );
static GDALDataset *Open( GDALOpenInfo * );
static GDALDataset *Create( const char * pszFilename,
int nXSize, int nYSize, int nBands,
int nXSize, int nYSize, int nBandsIn,
GDALDataType eType,
char **papszParamList );
static GDALDataset *CreateCopy( const char *pszFilename,
Expand Down Expand Up @@ -1069,7 +1069,7 @@ CPLErr GS7BGDataset::WriteHeader( VSILFILE *fp, GInt32 nXSize, GInt32 nYSize,
GDALDataset *GS7BGDataset::Create( const char * pszFilename,
int nXSize,
int nYSize,
int nBands,
int nBandsIn,
GDALDataType eType,
CPL_UNUSED char **papszParamList )

Expand All @@ -1094,7 +1094,7 @@ GDALDataset *GS7BGDataset::Create( const char * pszFilename,
return nullptr;
}

if (nBands > 1)
if (nBandsIn > 1)
{
CPLError( CE_Failure, CPLE_NotSupported,
"Unable to create copy, "
Expand Down
2 changes: 1 addition & 1 deletion frmts/gsg/gsbgdataset.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -823,7 +823,7 @@ CPLErr GSBGDataset::WriteHeader( VSILFILE *fp, GInt16 nXSize, GInt16 nYSize,
GDALDataset *GSBGDataset::Create( const char * pszFilename,
int nXSize,
int nYSize,
CPL_UNUSED int nBands,
int /* nBands */,
GDALDataType eType,
CPL_UNUSED char **papszParamList )
{
Expand Down
14 changes: 7 additions & 7 deletions frmts/hdf4/hdf4imagedataset.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ class HDF4ImageDataset final: public HDF4Dataset

static GDALDataset *Open( GDALOpenInfo * );
static GDALDataset *Create( const char * pszFilename,
int nXSize, int nYSize, int nBands,
int nXSize, int nYSize, int nBandsIn,
GDALDataType eType, char ** papszParamList );
virtual void FlushCache( bool bAtClosing ) override;
CPLErr GetGeoTransform( double * padfTransform ) override;
Expand Down Expand Up @@ -3890,15 +3890,15 @@ GDALDataset *HDF4ImageDataset::Open( GDALOpenInfo * poOpenInfo )
/************************************************************************/

GDALDataset *HDF4ImageDataset::Create( const char * pszFilename,
int nXSize, int nYSize, int nBands,
int nXSize, int nYSize, int nBandsIn,
GDALDataType eType,
char **papszOptions )

{
/* -------------------------------------------------------------------- */
/* Create the dataset. */
/* -------------------------------------------------------------------- */
if( nBands == 0 )
if( nBandsIn == 0 )
{
CPLError( CE_Failure, CPLE_NotSupported,
"Unable to export files with zero bands." );
Expand Down Expand Up @@ -3947,7 +3947,7 @@ GDALDataset *HDF4ImageDataset::Create( const char * pszFilename,
int32 aiDimSizes[H4_MAX_VAR_DIMS] = {};
aiDimSizes[poDS->iXDim] = nXSize;
aiDimSizes[poDS->iYDim] = nYSize;
aiDimSizes[poDS->iBandDim] = nBands;
aiDimSizes[poDS->iBandDim] = nBandsIn;

const auto GetHDFType = [](GDALDataType eTypeIn)
{
Expand Down Expand Up @@ -3986,7 +3986,7 @@ GDALDataset *HDF4ImageDataset::Create( const char * pszFilename,

if( poDS->iRank == 2 )
{
for( int iBand = 0; iBand < nBands; iBand++ )
for( int iBand = 0; iBand < nBandsIn; iBand++ )
{
pszSDSName = CPLSPrintf( "Band%d", iBand );
iSDS = SDcreate( poDS->hSD, pszSDSName, GetHDFType(eType),
Expand Down Expand Up @@ -4030,12 +4030,12 @@ GDALDataset *HDF4ImageDataset::Create( const char * pszFilename,
poDS->eAccess = GA_Update;
poDS->iDatasetType = HDF4_SDS;
poDS->iSubdatasetType = H4ST_GDAL;
poDS->nBands = nBands;
poDS->nBands = nBandsIn;

/* -------------------------------------------------------------------- */
/* Create band information objects. */
/* -------------------------------------------------------------------- */
for( int iBand = 1; iBand <= nBands; iBand++ )
for( int iBand = 1; iBand <= nBandsIn; iBand++ )
poDS->SetBand( iBand, new HDF4ImageRasterBand( poDS, iBand, eType ) );

SDsetattr( poDS->hSD, "Signature", DFNT_CHAR8,
Expand Down
Loading

0 comments on commit 3f6c8dc

Please sign in to comment.