Opened 7 years ago

Last modified 7 years ago

#6729 closed defect

Can ogr_geocoding.cpp avoid calling? — at Initial Version

Reported by: Kurt Schwehr Owned by: Kurt Schwehr
Priority: low Milestone:
Component: default Version: unspecified
Severity: normal Keywords:
Cc:

Description

If there is any way that these sneaky register calls could be removed it would be good for C++ testing and situations where security is important. aka someone (aka me) wants to only link in no or a limited subset of drivers.

I'm trying to work on a my autotest2 C++ setup and having the registers in the unusual files means that all my tests that do not require any drivers must still link in all the drivers and their libs. My hope is to keep the C++ tests as light and fast as possible.

I am trying to create a gdal base bazel (aka not make or cmake) target that only includes the minimum of targets. Then I will have a separate target that brings in the rest of the drivers and their support libraries.

https://trac.osgeo.org/gdal/browser/trunk/gdal/ogr/ogr_geocoding.cpp?annotate=blame#L424

Added in r25373

static OGRLayer* OGRGeocodeGetCacheLayer( OGRGeocodingSessionH hSession,
415                                               bool bCreateIfNecessary,
416                                               int* pnIdxBlob )
[25373] 417     {
    OGRDataSource* poDS = hSession->poDS;
    CPLString osExt = CPLGetExtension(hSession->pszCacheFilename);

    if( poDS == NULL )
    {
        if( OGRGetDriverCount() == 0 )
            OGRRegisterAll();                             //  <<<--- Why?
find . -name \*.cpp | xargs grep OGRRegisterAll | egrep -v 'apps|swig'
./frmts/gdalallregister.cpp:    OGRRegisterAllInternal();
./frmts/mbtiles/mbtilesdataset.cpp:        OGRRegisterAll();
./frmts/pdf/pdfcreatecopy.cpp:        OGRRegisterAll();
./frmts/rasterlite/rasterlitecreatecopy.cpp:        OGRRegisterAll();
./frmts/rasterlite/rasterlitedataset.cpp:        OGRRegisterAll();
./ogr/ogr_geocoding.cpp:            OGRRegisterAll();
./ogr/ogrsf_frmts/generic/ogrregisterall.cpp:/*                           OGRRegisterAll()                           */
./ogr/ogrsf_frmts/generic/ogrregisterall.cpp:void OGRRegisterAll()
./ogr/ogrsf_frmts/generic/ogrregisterall.cpp:void OGRRegisterAllInternal()
./ogr/ogrsf_frmts/generic/ogrregisterall.cpp:} /* OGRRegisterAll */
./ogr/ogrsf_frmts/sqlite/ogrsqlitevirtualogr.cpp:    OGRRegisterAll();
./ogr/ogrutils.cpp: *    OGRRegisterAll();

And it looks like there is one hiding in pdfcreatecopy.cpp.

find . -name \*.cpp | xargs grep GDALAllRegister | egrep -v 'swig|apps|gdalallregister'
./frmts/pdf/pdfcreatecopy.cpp:            GDALAllRegister();
./gcore/gdal_misc.cpp: *    GDALAllRegister();
./gcore/gdaldrivermanager.cpp: * the user a way of unloading undesired drivers.  The GDALAllRegister()
./ogr/ogrsf_frmts/generic/ogrregisterall.cpp:    GDALAllRegister();

Change History (0)

Note: See TracTickets for help on using tickets.