Skip to content

Commit

Permalink
appslib: enable -Weffc++
Browse files Browse the repository at this point in the history
  • Loading branch information
rouault committed Sep 20, 2024
1 parent 927be3f commit 14faa95
Show file tree
Hide file tree
Showing 12 changed files with 56 additions and 26 deletions.
2 changes: 1 addition & 1 deletion apps/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ add_library(
add_dependencies(appslib generate_gdal_version_h)
target_sources(${GDAL_LIB_TARGET_NAME} PRIVATE $<TARGET_OBJECTS:appslib>)
gdal_standard_includes(appslib)
target_compile_options(appslib PRIVATE ${GDAL_CXX_WARNING_FLAGS} ${WFLAG_OLD_STYLE_CAST})
target_compile_options(appslib PRIVATE ${GDAL_CXX_WARNING_FLAGS} ${WFLAG_OLD_STYLE_CAST} ${WFLAG_EFFCXX})
target_include_directories(
appslib PRIVATE $<TARGET_PROPERTY:gdal_vrt,SOURCE_DIR> $<TARGET_PROPERTY:ogrsf_generic,SOURCE_DIR>
$<TARGET_PROPERTY:ogr_geojson,SOURCE_DIR> $<TARGET_PROPERTY:ogr_MEM,SOURCE_DIR>)
Expand Down
4 changes: 3 additions & 1 deletion apps/gdal_footprint_lib.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ struct GDALFootprintOptions
/*! Whether to force writing absolute paths in location field. */
bool bAbsolutePath = false;

std::string osSrcNoData;
std::string osSrcNoData{};
};

static std::unique_ptr<GDALArgumentParser> GDALFootprintAppOptionsGetParser(
Expand Down Expand Up @@ -295,6 +295,8 @@ class GDALFootprintMaskBand final : public GDALRasterBand
{
GDALRasterBand *m_poSrcBand = nullptr;

CPL_DISALLOW_COPY_ASSIGN(GDALFootprintMaskBand)

public:
explicit GDALFootprintMaskBand(GDALRasterBand *poSrcBand)
: m_poSrcBand(poSrcBand)
Expand Down
2 changes: 2 additions & 0 deletions apps/gdal_grid_lib.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,8 @@ struct GDALGridOptions
&l_pOptions);
pOptions.reset(l_pOptions);
}

CPL_DISALLOW_COPY_ASSIGN(GDALGridOptions)
};

/************************************************************************/
Expand Down
10 changes: 5 additions & 5 deletions apps/gdal_utils_priv.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,10 @@ struct GDALInfoOptionsForBinary

struct GDALDEMProcessingOptionsForBinary
{
std::string osProcessing;
std::string osSrcFilename;
std::string osColorFilename;
std::string osDstFilename;
std::string osProcessing{};
std::string osSrcFilename{};
std::string osColorFilename{};
std::string osDstFilename{};
bool bQuiet = false;
};

Expand All @@ -83,7 +83,7 @@ struct GDALVectorTranslateOptionsForBinary
std::string osDestDataSource{};
bool bQuiet = false;
CPLStringList aosOpenOptions{};
std::string osFormat;
std::string osFormat{};
GDALVectorTranslateAccessMode eAccessMode = ACCESS_CREATION;
bool bShowUsageIfError = false;

Expand Down
11 changes: 10 additions & 1 deletion apps/gdalargumentparser.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,17 @@
#pragma warning(disable : 4702)
#endif

#ifdef __GNUC__
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Weffc++"
#endif

#include "argparse/argparse.hpp"

#ifdef __GNUC__
#pragma GCC diagnostic pop
#endif

#ifdef _MSC_VER
#pragma warning(pop)
#endif
Expand Down Expand Up @@ -156,7 +165,7 @@ class GDALArgumentParser : public ArgumentParser
private:
std::map<std::string, ArgumentParser::argument_it>::iterator
find_argument(const std::string &name);
std::vector<std::unique_ptr<GDALArgumentParser>> aoSubparsers;
std::vector<std::unique_ptr<GDALArgumentParser>> aoSubparsers{};
std::string m_osExtraUsageHint{};
};

Expand Down
2 changes: 2 additions & 0 deletions apps/gdalbuildvrt_lib.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,8 @@ class VRTBuilder
void CreateVRTSeparate(VRTDatasetH hVRTDS);
void CreateVRTNonSeparate(VRTDatasetH hVRTDS);

CPL_DISALLOW_COPY_ASSIGN(VRTBuilder)

public:
VRTBuilder(bool bStrictIn, const char *pszOutputFilename, int nInputFiles,
const char *const *ppszInputFilenames, GDALDatasetH *pahSrcDSIn,
Expand Down
8 changes: 6 additions & 2 deletions apps/gdaldem_lib.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ using namespace gdal::GDALDEM;
struct GDALDEMProcessingOptions
{
/*! output format. Use the short format name. */
std::string osFormat;
std::string osFormat{};

/*! the progress function to use */
GDALProgressFunc pfnProgress = nullptr;
Expand All @@ -184,7 +184,7 @@ struct GDALDEMProcessingOptions
bool bCombined = false;
bool bIgor = false;
bool bMultiDirectional = false;
CPLStringList aosCreationOptions;
CPLStringList aosCreationOptions{};
int nBand = 1;
};

Expand Down Expand Up @@ -1972,6 +1972,8 @@ class GDALColorReliefDataset : public GDALDataset
int nCurBlockXOff;
int nCurBlockYOff;

CPL_DISALLOW_COPY_ASSIGN(GDALColorReliefDataset)

public:
GDALColorReliefDataset(GDALDatasetH hSrcDS, GDALRasterBandH hSrcBand,
const char *pszColorFilename,
Expand Down Expand Up @@ -2565,6 +2567,8 @@ template <class T> class GDALGeneric3x3Dataset : public GDALDataset
int nCurLine;
bool bComputeAtEdges;

CPL_DISALLOW_COPY_ASSIGN(GDALGeneric3x3Dataset)

public:
GDALGeneric3x3Dataset(GDALDatasetH hSrcDS, GDALRasterBandH hSrcBand,
GDALDataType eDstDataType, int bDstHasNoData,
Expand Down
2 changes: 1 addition & 1 deletion apps/gdalinfo_lib.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ struct GDALInfoOptions
/*! report metadata for the specified domains. "all" can be used to report
metadata in all domains.
*/
CPLStringList aosExtraMDDomains;
CPLStringList aosExtraMDDomains{};

/*! WKT format used for SRS */
std::string osWKTFormat = "WKT2";
Expand Down
2 changes: 2 additions & 0 deletions apps/gdaltindex_lib.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -387,6 +387,8 @@ struct GDALTileIndexTileIterator
int iCurSrc = 0;
VSIDIR *psDir = nullptr;

CPL_DISALLOW_COPY_ASSIGN(GDALTileIndexTileIterator)

GDALTileIndexTileIterator(const GDALTileIndexOptions *psOptionsIn,
int nSrcCountIn,
const char *const *papszSrcDSNamesIn)
Expand Down
2 changes: 2 additions & 0 deletions apps/gdalwarp_lib.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4868,6 +4868,8 @@ static GDALDatasetH GDALWarpCreateOutput(

class CutlineTransformer : public OGRCoordinateTransformation
{
CPL_DISALLOW_COPY_ASSIGN(CutlineTransformer)

public:
void *hSrcImageTransformer = nullptr;

Expand Down
35 changes: 21 additions & 14 deletions apps/ogr2ogr_lib.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,8 @@ struct CopyableGCPs
CPLFree(pasGCPs);
}
}

CopyableGCPs &operator=(const CopyableGCPs &) = delete;
};
} // namespace gdal::ogr2ogr_lib

Expand Down Expand Up @@ -433,7 +435,7 @@ struct GDALVectorTranslateOptions
whose geometry intersects the extents will be selected. The geometries
will not be clipped unless GDALVectorTranslateOptions::bClipSrc is true.
*/
std::shared_ptr<OGRGeometry> poSpatialFilter;
std::shared_ptr<OGRGeometry> poSpatialFilter{};

/*! the progress function to use */
GDALProgressFunc pfnProgress = nullptr;
Expand Down Expand Up @@ -743,15 +745,17 @@ typedef struct

class OGRSplitListFieldLayer : public OGRLayer
{
OGRLayer *poSrcLayer;
OGRFeatureDefn *poFeatureDefn;
ListFieldDesc *pasListFields;
int nListFieldCount;
int nMaxSplitListSubFields;
OGRLayer *poSrcLayer = nullptr;
OGRFeatureDefn *poFeatureDefn = nullptr;
ListFieldDesc *pasListFields = nullptr;
int nListFieldCount = 0;
const int nMaxSplitListSubFields;

std::unique_ptr<OGRFeature>
TranslateFeature(std::unique_ptr<OGRFeature> poSrcFeature);

CPL_DISALLOW_COPY_ASSIGN(OGRSplitListFieldLayer)

public:
OGRSplitListFieldLayer(OGRLayer *poSrcLayer, int nMaxSplitListSubFields);
virtual ~OGRSplitListFieldLayer();
Expand Down Expand Up @@ -826,8 +830,7 @@ class OGRSplitListFieldLayer : public OGRLayer

OGRSplitListFieldLayer::OGRSplitListFieldLayer(OGRLayer *poSrcLayerIn,
int nMaxSplitListSubFieldsIn)
: poSrcLayer(poSrcLayerIn), poFeatureDefn(nullptr), pasListFields(nullptr),
nListFieldCount(0),
: poSrcLayer(poSrcLayerIn),
nMaxSplitListSubFields(
nMaxSplitListSubFieldsIn < 0 ? INT_MAX : nMaxSplitListSubFieldsIn)
{
Expand Down Expand Up @@ -1569,15 +1572,17 @@ class GDALVectorTranslateWrappedDataset : public GDALDataset
std::unique_ptr<GDALDriver> m_poDriverToFree{};
GDALDataset *m_poBase = nullptr;
OGRSpatialReference *m_poOutputSRS = nullptr;
bool m_bTransform = false;
const bool m_bTransform = false;

std::vector<std::unique_ptr<OGRLayer>> m_apoLayers{};
std::vector<std::unique_ptr<OGRLayer>> m_apoHiddenLayers;
std::vector<std::unique_ptr<OGRLayer>> m_apoHiddenLayers{};

GDALVectorTranslateWrappedDataset(GDALDataset *poBase,
OGRSpatialReference *poOutputSRS,
bool bTransform);

CPL_DISALLOW_COPY_ASSIGN(GDALVectorTranslateWrappedDataset)

public:
virtual int GetLayerCount() override
{
Expand Down Expand Up @@ -1605,6 +1610,8 @@ class GDALVectorTranslateWrappedLayer : public OGRLayerDecorator
std::unique_ptr<OGRFeature>
TranslateFeature(std::unique_ptr<OGRFeature> poSrcFeat);

CPL_DISALLOW_COPY_ASSIGN(GDALVectorTranslateWrappedLayer)

public:
virtual ~GDALVectorTranslateWrappedLayer();

Expand Down Expand Up @@ -1849,12 +1856,12 @@ void GDALVectorTranslateWrappedDataset::ReleaseResultSet(OGRLayer *poResultsSet)

class OGR2OGRSpatialReferenceHolder
{
OGRSpatialReference *m_poSRS;
OGRSpatialReference *m_poSRS = nullptr;

CPL_DISALLOW_COPY_ASSIGN(OGR2OGRSpatialReferenceHolder)

public:
OGR2OGRSpatialReferenceHolder() : m_poSRS(nullptr)
{
}
OGR2OGRSpatialReferenceHolder() = default;

~OGR2OGRSpatialReferenceHolder()
{
Expand Down
2 changes: 1 addition & 1 deletion apps/ogrinfo_lib.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ struct GDALVectorInfoOptions
GDALVectorInfoFormat eFormat = FORMAT_TEXT;
std::string osWHERE{};
CPLStringList aosLayers{};
std::unique_ptr<OGRGeometry> poSpatialFilter;
std::unique_ptr<OGRGeometry> poSpatialFilter{};
bool bAllLayers = false;
std::string osSQLStatement{};
std::string osDialect{};
Expand Down

0 comments on commit 14faa95

Please sign in to comment.