Skip to content

Commit

Permalink
Mass replacement of NULL by nullptr in C++ code; configure: enable -W…
Browse files Browse the repository at this point in the history
…zero-as-null-pointer-constant when possible; remove gcc48_stdcpp11 Travis-CI target now useless

git-svn-id: https://svn.osgeo.org/gdal/trunk@41004 f0d54148-0727-0410-94bb-9a71ac55c965
  • Loading branch information
rouault committed Dec 11, 2017
1 parent b6f6208 commit 7e07230
Show file tree
Hide file tree
Showing 1,178 changed files with 40,226 additions and 40,303 deletions.
12 changes: 0 additions & 12 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -82,18 +82,6 @@ matrix:
env:
- BUILD_NAME=big_endian
- DETAILS=""
- os: linux
compiler: gcc
language: cpp
sudo: required
dist: precise
cache:
apt: true
directories:
- $HOME/.ccache
env:
- BUILD_NAME=gcc48_stdcpp11
- DETAILS=""
- os: linux
compiler: gcc
language: cpp
Expand Down
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ GDAL - Geospatial Data Abstraction Library
| MinGW_W64 | [![Build Status](http://badges.herokuapp.com/travis/OSGeo/gdal?branch=trunk&env=BUILD_NAME=mingw_w64&label=mingw_w64)](https://travis-ci.org/OSGeo/gdal) |
| Android | [![Build Status](http://badges.herokuapp.com/travis/OSGeo/gdal?branch=trunk&env=BUILD_NAME=android&label=android)](https://travis-ci.org/OSGeo/gdal) |
| Big endian host | [![Build Status](http://badges.herokuapp.com/travis/OSGeo/gdal?branch=trunk&env=BUILD_NAME=big_endian&label=big_endian)](https://travis-ci.org/OSGeo/gdal) |
| GCC 4.8 C++11 | [![Build Status](http://badges.herokuapp.com/travis/OSGeo/gdal?branch=trunk&env=BUILD_NAME=gcc48_stdcpp11&label=gcc48_stdcpp11)](https://travis-ci.org/OSGeo/gdal) |
| GCC 5.2 C++14 -fsanitize | [![Build Status](http://badges.herokuapp.com/travis/OSGeo/gdal?branch=trunk&env=BUILD_NAME=gcc52_stdcpp14_sanitize&label=gcc52_stdcpp14_sanitize)](https://travis-ci.org/OSGeo/gdal) |
| Clang Static Analyzer | [![Build Status](https://travis-ci.org/rouault/gdal_coverage.svg?branch=trunk_clang_static_analyzer)](https://travis-ci.org/rouault/gdal_coverage) |
| Coverity Scan | [![Build Status](https://scan.coverity.com/projects/749/badge.svg?flat=1)](https://scan.coverity.com/projects/gdal) |
Expand Down
2 changes: 1 addition & 1 deletion autotest/cpp/gdal_unit_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ int main(int argc, char* argv[])
GDALDestroyDriverManager();
OGRCleanupAll();

CPLDumpSharedList( NULL );
CPLDumpSharedList( nullptr );
CPLCleanupTLS();

return nRetCode;
Expand Down
182 changes: 91 additions & 91 deletions autotest/cpp/test_cpl.cpp

Large diffs are not rendered by default.

22 changes: 11 additions & 11 deletions autotest/cpp/test_gdal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,9 @@ namespace tut
template<>
void object::test<1>()
{
GDALDriverManager* drv_mgr = NULL;
GDALDriverManager* drv_mgr = nullptr;
drv_mgr = GetGDALDriverManager();
ensure("GetGDALDriverManager() is NULL", NULL != drv_mgr);
ensure("GetGDALDriverManager() is NULL", nullptr != drv_mgr);
}

// Test number of registered GDAL drivers
Expand Down Expand Up @@ -185,7 +185,7 @@ namespace tut
{
int bClamped, bRounded;

ensure( GDALAdjustValueToDataType(GDT_Byte,255.0,NULL,NULL) == 255.0);
ensure( GDALAdjustValueToDataType(GDT_Byte,255.0,nullptr,nullptr) == 255.0);
ensure( GDALAdjustValueToDataType(GDT_Byte,255.0,&bClamped,&bRounded) == 255.0 && !bClamped && !bRounded);
ensure( GDALAdjustValueToDataType(GDT_Byte,254.4,&bClamped,&bRounded) == 254.0 && !bClamped && bRounded);
ensure( GDALAdjustValueToDataType(GDT_Byte,-1,&bClamped,&bRounded) == 0.0 && bClamped && !bRounded);
Expand Down Expand Up @@ -289,16 +289,16 @@ namespace tut
poDriver->SetDescription("DatasetWithErrorInFlushCache");
poDriver->pfnCreateCopy = DatasetWithErrorInFlushCache::CreateCopy;
GetGDALDriverManager()->RegisterDriver( poDriver );
const char* args[] = { "-of", "DatasetWithErrorInFlushCache", NULL };
GDALTranslateOptions* psOptions = GDALTranslateOptionsNew((char**)args, NULL);
const char* args[] = { "-of", "DatasetWithErrorInFlushCache", nullptr };
GDALTranslateOptions* psOptions = GDALTranslateOptionsNew((char**)args, nullptr);
GDALDatasetH hSrcDS = GDALOpen("../gcore/data/byte.tif", GA_ReadOnly);
CPLErrorReset();
CPLPushErrorHandler(CPLQuietErrorHandler);
GDALDatasetH hOutDS = GDALTranslate("", hSrcDS, psOptions, NULL);
GDALDatasetH hOutDS = GDALTranslate("", hSrcDS, psOptions, nullptr);
CPLPopErrorHandler();
GDALClose(hSrcDS);
GDALTranslateOptionsFree(psOptions);
ensure(hOutDS == NULL);
ensure(hOutDS == nullptr);
ensure(CPLGetLastErrorType() != CE_None);
GetGDALDriverManager()->DeregisterDriver( poDriver );
delete poDriver;
Expand All @@ -311,16 +311,16 @@ namespace tut
poDriver->SetDescription("DatasetWithErrorInFlushCache");
poDriver->pfnCreate = DatasetWithErrorInFlushCache::Create;
GetGDALDriverManager()->RegisterDriver( poDriver );
const char* args[] = { "-of", "DatasetWithErrorInFlushCache", NULL };
GDALWarpAppOptions* psOptions = GDALWarpAppOptionsNew((char**)args, NULL);
const char* args[] = { "-of", "DatasetWithErrorInFlushCache", nullptr };
GDALWarpAppOptions* psOptions = GDALWarpAppOptionsNew((char**)args, nullptr);
GDALDatasetH hSrcDS = GDALOpen("../gcore/data/byte.tif", GA_ReadOnly);
CPLErrorReset();
CPLPushErrorHandler(CPLQuietErrorHandler);
GDALDatasetH hOutDS = GDALWarp("/", NULL, 1, &hSrcDS, psOptions, NULL);
GDALDatasetH hOutDS = GDALWarp("/", nullptr, 1, &hSrcDS, psOptions, nullptr);
CPLPopErrorHandler();
GDALClose(hSrcDS);
GDALWarpAppOptionsFree(psOptions);
ensure(hOutDS == NULL);
ensure(hOutDS == nullptr);
ensure(CPLGetLastErrorType() != CE_None);
GetGDALDriverManager()->DeregisterDriver( poDriver );
delete poDriver;
Expand Down
34 changes: 17 additions & 17 deletions autotest/cpp/test_gdal_aaigrid.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ namespace tut
rasters_t rasters_;

test_aaigrid_data()
: drv_(NULL), drv_name_("AAIGrid")
: drv_(nullptr), drv_name_("AAIGrid")
{
drv_ = GDALGetDriverByName(drv_name_.c_str());

Expand All @@ -87,7 +87,7 @@ namespace tut
template<>
void object::test<1>()
{
ensure("GDAL::AAIGrid driver not available", NULL != drv_);
ensure("GDAL::AAIGrid driver not available", nullptr != drv_);
}

// Test open dataset
Expand All @@ -101,7 +101,7 @@ namespace tut
std::string file(data_ + SEP);
file += it->file_;
GDALDatasetH ds = GDALOpen(file.c_str(), GA_ReadOnly);
ensure("Can't open dataset: " + file, NULL != ds);
ensure("Can't open dataset: " + file, nullptr != ds);
GDALClose(ds);
}
}
Expand All @@ -118,10 +118,10 @@ namespace tut
file += it->file_;

GDALDatasetH ds = GDALOpen(file.c_str(), GA_ReadOnly);
ensure("Can't open dataset: " + file, NULL != ds);
ensure("Can't open dataset: " + file, nullptr != ds);

GDALRasterBandH band = GDALGetRasterBand(ds, it->band_);
ensure("Can't get raster band", NULL != band);
ensure("Can't get raster band", nullptr != band);

const int xsize = GDALGetRasterXSize(ds);
const int ysize = GDALGetRasterYSize(ds);
Expand All @@ -147,7 +147,7 @@ namespace tut
file += grids_.at(fileIdx).file_;

GDALDatasetH ds = GDALOpen(file.c_str(), GA_ReadOnly);
ensure("Can't open dataset: " + file, NULL != ds);
ensure("Can't open dataset: " + file, nullptr != ds);

double geoTransform[6] = { 0 };
CPLErr err = GDALGetGeoTransform(ds, geoTransform);
Expand Down Expand Up @@ -179,7 +179,7 @@ namespace tut
file += grids_.at(fileIdx).file_;

GDALDatasetH ds = GDALOpen(file.c_str(), GA_ReadOnly);
ensure("Can't open dataset: " + file, NULL != ds);
ensure("Can't open dataset: " + file, nullptr != ds);

std::string proj(GDALGetProjectionRef(ds));
ensure_equals("Projection definition is not available", proj.empty(), false);
Expand Down Expand Up @@ -212,12 +212,12 @@ namespace tut
file += grids_.at(fileIdx).file_;

GDALDatasetH ds = GDALOpen(file.c_str(), GA_ReadOnly);
ensure("Can't open dataset: " + file, NULL != ds);
ensure("Can't open dataset: " + file, nullptr != ds);

GDALRasterBandH band = GDALGetRasterBand(ds, grids_.at(fileIdx).band_);
ensure("Can't get raster band", NULL != band);
ensure("Can't get raster band", nullptr != band);

const double noData = GDALGetRasterNoDataValue(band, NULL);
const double noData = GDALGetRasterNoDataValue(band, nullptr);
ensure_equals("Grid NODATA value wrong or missing", noData, -99999);

ensure_equals("Data type is not GDT_Float32", GDALGetRasterDataType(band), GDT_Float32);
Expand All @@ -237,16 +237,16 @@ namespace tut
src += rasters_.at(fileIdx).file_;

GDALDatasetH dsSrc = GDALOpen(src.c_str(), GA_ReadOnly);
ensure("Can't open source dataset: " + src, NULL != dsSrc);
ensure("Can't open source dataset: " + src, nullptr != dsSrc);

std::string dst(data_tmp_ + SEP);
dst += rasters_.at(fileIdx).file_;
dst += ".grd";

GDALDatasetH dsDst = NULL;
dsDst = GDALCreateCopy(drv_, dst.c_str(), dsSrc, FALSE, NULL, NULL, NULL);
GDALDatasetH dsDst = nullptr;
dsDst = GDALCreateCopy(drv_, dst.c_str(), dsSrc, FALSE, nullptr, nullptr, nullptr);
GDALClose(dsSrc);
ensure("Can't copy dataset", NULL != dsDst);
ensure("Can't copy dataset", nullptr != dsDst);

std::string proj(GDALGetProjectionRef(dsDst));
ensure_equals("Projection definition is not available", proj.empty(), false);
Expand All @@ -261,7 +261,7 @@ namespace tut
ensure_equals("Projection does not match expected", proj, expect);

GDALRasterBandH band = GDALGetRasterBand(dsDst, rasters_.at(fileIdx).band_);
ensure("Can't get raster band", NULL != band);
ensure("Can't get raster band", nullptr != band);

const int xsize = GDALGetRasterXSize(dsDst);
const int ysize = GDALGetRasterYSize(dsDst);
Expand All @@ -287,10 +287,10 @@ namespace tut
file += grids_.at(fileIdx).file_;

GDALDatasetH ds = GDALOpen(file.c_str(), GA_ReadOnly);
ensure("Can't open dataset: " + file, NULL != ds);
ensure("Can't open dataset: " + file, nullptr != ds);

GDALRasterBandH band = GDALGetRasterBand(ds, grids_.at(fileIdx).band_);
ensure("Can't get raster band", NULL != band);
ensure("Can't get raster band", nullptr != band);

// Sub-windows size
const int win[4] = { 5, 5, 5, 5 };
Expand Down
34 changes: 17 additions & 17 deletions autotest/cpp/test_gdal_dted.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ namespace tut
rasters_t rasters_;

test_dted_data()
: drv_(NULL), drv_name_("DTED")
: drv_(nullptr), drv_name_("DTED")
{
drv_ = GDALGetDriverByName(drv_name_.c_str());

Expand All @@ -85,7 +85,7 @@ namespace tut
template<>
void object::test<1>()
{
ensure("GDAL::DTED driver not available", NULL != drv_);
ensure("GDAL::DTED driver not available", nullptr != drv_);
}

// Test open dataset
Expand All @@ -99,7 +99,7 @@ namespace tut
std::string file(data_ + SEP);
file += it->file_;
GDALDatasetH ds = GDALOpen(file.c_str(), GA_ReadOnly);
ensure("Can't open dataset: " + file, NULL != ds);
ensure("Can't open dataset: " + file, nullptr != ds);
GDALClose(ds);
}
}
Expand All @@ -117,10 +117,10 @@ namespace tut
file += it->file_;

GDALDatasetH ds = GDALOpen(file.c_str(), GA_ReadOnly);
ensure("Can't open dataset: " + file, NULL != ds);
ensure("Can't open dataset: " + file, nullptr != ds);

GDALRasterBandH band = GDALGetRasterBand(ds, it->band_);
ensure("Can't get raster band", NULL != band);
ensure("Can't get raster band", nullptr != band);

const int xsize = GDALGetRasterXSize(ds);
const int ysize = GDALGetRasterYSize(ds);
Expand All @@ -146,7 +146,7 @@ namespace tut
file += rasters_.at(fileIdx).file_;

GDALDatasetH ds = GDALOpen(file.c_str(), GA_ReadOnly);
ensure("Can't open dataset: " + file, NULL != ds);
ensure("Can't open dataset: " + file, nullptr != ds);

double geoTransform[6] = { 0 };
CPLErr err = GDALGetGeoTransform(ds, geoTransform);
Expand Down Expand Up @@ -181,7 +181,7 @@ namespace tut
file += rasters_.at(fileIdx).file_;

GDALDatasetH ds = GDALOpen(file.c_str(), GA_ReadOnly);
ensure("Can't open dataset: " + file, NULL != ds);
ensure("Can't open dataset: " + file, nullptr != ds);

std::string proj(GDALGetProjectionRef(ds));
ensure_equals("Projection definition is not available", proj.empty(), false);
Expand All @@ -204,12 +204,12 @@ namespace tut
file += rasters_.at(fileIdx).file_;

GDALDatasetH ds = GDALOpen(file.c_str(), GA_ReadOnly);
ensure("Can't open dataset: " + file, NULL != ds);
ensure("Can't open dataset: " + file, nullptr != ds);

GDALRasterBandH band = GDALGetRasterBand(ds, rasters_.at(fileIdx).band_);
ensure("Can't get raster band", NULL != band);
ensure("Can't get raster band", nullptr != band);

const double noData = GDALGetRasterNoDataValue(band, NULL);
const double noData = GDALGetRasterNoDataValue(band, nullptr);
ensure_equals("Grid NODATA value wrong or missing", noData, -32767);

ensure_equals("Data type is not GDT_Int16", GDALGetRasterDataType(band), GDT_Int16);
Expand All @@ -229,15 +229,15 @@ namespace tut
src += rasters_.at(fileIdx).file_;

GDALDatasetH dsSrc = GDALOpen(src.c_str(), GA_ReadOnly);
ensure("Can't open source dataset: " + src, NULL != dsSrc);
ensure("Can't open source dataset: " + src, nullptr != dsSrc);

std::string dst(data_tmp_ + SEP);
dst += rasters_.at(fileIdx).file_;

GDALDatasetH dsDst = NULL;
dsDst = GDALCreateCopy(drv_, dst.c_str(), dsSrc, FALSE, NULL, NULL, NULL);
GDALDatasetH dsDst = nullptr;
dsDst = GDALCreateCopy(drv_, dst.c_str(), dsSrc, FALSE, nullptr, nullptr, nullptr);
GDALClose(dsSrc);
ensure("Can't copy dataset", NULL != dsDst);
ensure("Can't copy dataset", nullptr != dsDst);

std::string proj(GDALGetProjectionRef(dsDst));
ensure_equals("Projection definition is not available", proj.empty(), false);
Expand All @@ -246,7 +246,7 @@ namespace tut
ensure_equals("Projection does not match expected", proj, expect);

GDALRasterBandH band = GDALGetRasterBand(dsDst, rasters_.at(fileIdx).band_);
ensure("Can't get raster band", NULL != band);
ensure("Can't get raster band", nullptr != band);

const int xsize = GDALGetRasterXSize(dsDst);
const int ysize = GDALGetRasterYSize(dsDst);
Expand All @@ -271,10 +271,10 @@ namespace tut
file += rasters_.at(fileIdx).file_;

GDALDatasetH ds = GDALOpen(file.c_str(), GA_ReadOnly);
ensure("Can't open dataset: " + file, NULL != ds);
ensure("Can't open dataset: " + file, nullptr != ds);

GDALRasterBandH band = GDALGetRasterBand(ds, rasters_.at(fileIdx).band_);
ensure("Can't get raster band", NULL != band);
ensure("Can't get raster band", nullptr != band);

// Sub-windows size
const int win[4] = { 5, 5, 5, 5 };
Expand Down
Loading

0 comments on commit 7e07230

Please sign in to comment.