Opened 6 years ago

Closed 5 years ago

#6314 closed defect (fixed)

DB2 compilation warnings with gcc/clang

Reported by: Even Rouault Owned by: dadler
Priority: normal Milestone:
Component: default Version: unspecified
Severity: normal Keywords:
Cc:

Description

David, I just created a Linux GNUmakefile (committed in r33012) to see if GCC would throw interesting things when compiling the DB2 driver. Here it is

In file included from ogrdb2cli.cpp:29:
ogr_db2.h:148: warning: ‘class OGRDB2Session’ has virtual functions and accessible non-virtual destructor
In file included from gdaldb2rasterband.cpp:31:
ogr_db2.h:148: warning: ‘class OGRDB2Session’ has virtual functions and accessible non-virtual destructor
/home/even/gdal/svn/trunk/gdal/ogr/ogrsf_frmts/ogrsf_frmts.h:123: warning: ‘virtual OGRErr OGRLayer::GetExtent(int, OGREnvelope*, int)’ was hidden
ogr_db2.h:572: warning:   by ‘virtual OGRErr OGRDB2SelectLayer::GetExtent(OGREnvelope*, int)’
/home/even/gdal/svn/trunk/gdal/ogr/ogrsf_frmts/ogrsf_frmts.h:123: warning: ‘virtual OGRErr OGRLayer::GetExtent(int, OGREnvelope*, int)’ was hidden
ogr_db2.h:572: warning:   by ‘virtual OGRErr OGRDB2SelectLayer::GetExtent(OGREnvelope*, int)’
gdaldb2rasterband.cpp: In constructor ‘GDALDB2RasterBand::GDALDB2RasterBand(OGRDB2DataSource*, int, int, int)’:
gdaldb2rasterband.cpp:43: warning: declaration of ‘nBand’ shadows a member of 'this'
gdaldb2rasterband.cpp:43: warning: declaration of ‘poDS’ shadows a member of 'this'
In file included from ogrdb2datasourcemd.cpp:31:
ogr_db2.h:148: warning: ‘class OGRDB2Session’ has virtual functions and accessible non-virtual destructor
/home/even/gdal/svn/trunk/gdal/ogr/ogrsf_frmts/ogrsf_frmts.h:123: warning: ‘virtual OGRErr OGRLayer::GetExtent(int, OGREnvelope*, int)’ was hidden
ogr_db2.h:572: warning:   by ‘virtual OGRErr OGRDB2SelectLayer::GetExtent(OGREnvelope*, int)’
ogrdb2datasourcemd.cpp: In member function ‘CPLErr OGRDB2DataSource::FlushMetadata()’:
ogrdb2datasourcemd.cpp:68: warning: too many arguments for format
ogrdb2datasourcemd.cpp:88: warning: too many arguments for format
ogrdb2datasourcemd.cpp:166: warning: too many arguments for format
ogrdb2datasourcemd.cpp:171: warning: too many arguments for format
ogrdb2datasourcemd.cpp:188: warning: too many arguments for format
ogrdb2datasourcemd.cpp:193: warning: too many arguments for format
gdaldb2rasterband.cpp: In member function ‘CPLErr OGRDB2DataSource::WriteTileInternal()’:
gdaldb2rasterband.cpp:1136: warning: declaration of ‘poDriver’ shadows a member of 'this'
gdaldb2rasterband.cpp: At global scope:
gdaldb2rasterband.cpp:1640: warning: unused parameter ‘nRow’
gdaldb2rasterband.cpp:1640: warning: unused parameter ‘nCol’
gdaldb2rasterband.cpp:1640: warning: unused parameter ‘nBand’
gdaldb2rasterband.cpp:1640: warning: unused parameter ‘nDstXOffset’
gdaldb2rasterband.cpp:1640: warning: unused parameter ‘nDstYOffset’
gdaldb2rasterband.cpp:1640: warning: unused parameter ‘nDstXSize’
gdaldb2rasterband.cpp:1640: warning: unused parameter ‘nDstYSize’
gdaldb2rasterband.cpp: In function ‘char* GByteArrayToHexString(const GByte*, int)’:
gdaldb2rasterband.cpp:2151: warning: ‘int sprintf(char*, const char*, ...)’ is deprecated (declared at /home/even/gdal/svn/trunk/gdal/port/cpl_port.h:815)
gdaldb2rasterband.cpp:2151: warning: ‘int sprintf(char*, const char*, ...)’ is deprecated (declared at /home/even/gdal/svn/trunk/gdal/port/cpl_port.h:815)
gdaldb2rasterband.cpp:2156: warning: ‘int sprintf(char*, const char*, ...)’ is deprecated (declared at /home/even/gdal/svn/trunk/gdal/port/cpl_port.h:815)
gdaldb2rasterband.cpp:2156: warning: ‘int sprintf(char*, const char*, ...)’ is deprecated (declared at /home/even/gdal/svn/trunk/gdal/port/cpl_port.h:815)
In file included from ogrdb2driver.cpp:29:
ogr_db2.h:148: warning: ‘class OGRDB2Session’ has virtual functions and accessible non-virtual destructor
/home/even/gdal/svn/trunk/gdal/ogr/ogrsf_frmts/ogrsf_frmts.h:123: warning: ‘virtual OGRErr OGRLayer::GetExtent(int, OGREnvelope*, int)’ was hidden
ogr_db2.h:572: warning:   by ‘virtual OGRErr OGRDB2SelectLayer::GetExtent(OGREnvelope*, int)’
In file included from ogrdb2tablelayer.cpp:30:
ogr_db2.h:148: warning: ‘class OGRDB2Session’ has virtual functions and accessible non-virtual destructor
/home/even/gdal/svn/trunk/gdal/ogr/ogrsf_frmts/ogrsf_frmts.h:123: warning: ‘virtual OGRErr OGRLayer::GetExtent(int, OGREnvelope*, int)’ was hidden
ogr_db2.h:572: warning:   by ‘virtual OGRErr OGRDB2SelectLayer::GetExtent(OGREnvelope*, int)’
ogrdb2tablelayer.cpp: In member function ‘virtual OGRFeature* OGRDB2TableLayer::GetFeature(GIntBig)’:
ogrdb2tablelayer.cpp:652: warning: format ‘%ld’ expects type ‘long int’, but argument 6 has type ‘GIntBig’
ogrdb2tablelayer.cpp: In member function ‘virtual OGRErr OGRDB2TableLayer::CreateField(OGRFieldDefn*, int)’:
ogrdb2tablelayer.cpp:781: warning: ‘int sprintf(char*, const char*, ...)’ is deprecated (declared at /home/even/gdal/svn/trunk/gdal/port/cpl_port.h:815)
ogrdb2tablelayer.cpp:781: warning: ‘int sprintf(char*, const char*, ...)’ is deprecated (declared at /home/even/gdal/svn/trunk/gdal/port/cpl_port.h:815)
ogrdb2tablelayer.cpp:788: warning: ‘int sprintf(char*, const char*, ...)’ is deprecated (declared at /home/even/gdal/svn/trunk/gdal/port/cpl_port.h:815)
ogrdb2tablelayer.cpp:788: warning: ‘int sprintf(char*, const char*, ...)’ is deprecated (declared at /home/even/gdal/svn/trunk/gdal/port/cpl_port.h:815)
ogrdb2tablelayer.cpp:796: warning: ‘int sprintf(char*, const char*, ...)’ is deprecated (declared at /home/even/gdal/svn/trunk/gdal/port/cpl_port.h:815)
ogrdb2tablelayer.cpp:797: warning: ‘int sprintf(char*, const char*, ...)’ is deprecated (declared at /home/even/gdal/svn/trunk/gdal/port/cpl_port.h:815)
ogrdb2tablelayer.cpp:806: warning: ‘int sprintf(char*, const char*, ...)’ is deprecated (declared at /home/even/gdal/svn/trunk/gdal/port/cpl_port.h:815)
ogrdb2tablelayer.cpp:806: warning: ‘int sprintf(char*, const char*, ...)’ is deprecated (declared at /home/even/gdal/svn/trunk/gdal/port/cpl_port.h:815)
ogrdb2tablelayer.cpp: At global scope:
ogrdb2tablelayer.cpp:1308: warning: unused parameter ‘poStatement’
In file included from ogrdb2layer.cpp:30:
ogr_db2.h:148: warning: ‘class OGRDB2Session’ has virtual functions and accessible non-virtual destructor
In file included from ogrdb2datasource.cpp:30:
ogr_db2.h:148: warning: ‘class OGRDB2Session’ has virtual functions and accessible non-virtual destructor
/home/even/gdal/svn/trunk/gdal/ogr/ogrsf_frmts/ogrsf_frmts.h:123: warning: ‘virtual OGRErr OGRLayer::GetExtent(int, OGREnvelope*, int)’ was hidden
ogr_db2.h:572: warning:   by ‘virtual OGRErr OGRDB2SelectLayer::GetExtent(OGREnvelope*, int)’
/home/even/gdal/svn/trunk/gdal/ogr/ogrsf_frmts/ogrsf_frmts.h:123: warning: ‘virtual OGRErr OGRLayer::GetExtent(int, OGREnvelope*, int)’ was hidden
ogr_db2.h:572: warning:   by ‘virtual OGRErr OGRDB2SelectLayer::GetExtent(OGREnvelope*, int)’
ogrdb2layer.cpp: In destructor ‘virtual OGRDB2Layer::~OGRDB2Layer()’:
ogrdb2layer.cpp:60: warning: format ‘%d’ expects type ‘int’, but argument 3 has type ‘GIntBig’
ogrdb2layer.cpp: In member function ‘char* OGRDB2Layer::GByteArrayToHexString(const GByte*, int)’:
ogrdb2layer.cpp:485: warning: ‘int sprintf(char*, const char*, ...)’ is deprecated (declared at /home/even/gdal/svn/trunk/gdal/port/cpl_port.h:815)
ogrdb2layer.cpp:485: warning: ‘int sprintf(char*, const char*, ...)’ is deprecated (declared at /home/even/gdal/svn/trunk/gdal/port/cpl_port.h:815)
ogrdb2layer.cpp:490: warning: ‘int sprintf(char*, const char*, ...)’ is deprecated (declared at /home/even/gdal/svn/trunk/gdal/port/cpl_port.h:815)
ogrdb2layer.cpp:490: warning: ‘int sprintf(char*, const char*, ...)’ is deprecated (declared at /home/even/gdal/svn/trunk/gdal/port/cpl_port.h:815)
ogrdb2datasource.cpp:2273: warning: unused parameter ‘bCheckRasterTable’
ogrdb2datasource.cpp: In function ‘void DumpStringList(char**)’:
ogrdb2datasource.cpp:2562: warning: no previous declaration for ‘void DumpStringList(char**)’
ogrdb2datasource.cpp: In member function ‘virtual CPLErr OGRDB2DataSource::SetProjection(const char*)’:
ogrdb2datasource.cpp:2951: warning: too many arguments for format
ogrdb2datasource.cpp:2956: warning: too many arguments for format
ogrdb2datasource.cpp:2970: warning: too many arguments for format
ogrdb2datasource.cpp:2975: warning: too many arguments for format
ogrdb2datasource.cpp: In member function ‘virtual CPLErr OGRDB2DataSource::IBuildOverviews(const char*, int, int*, int, int*, int (*)(double, const char*, void*), void*)’:
ogrdb2datasource.cpp:3425: warning: too many arguments for format
ogrdb2datasource.cpp:3430: warning: too many arguments for format
ogrdb2datasource.cpp:3451: warning: too many arguments for format
ogrdb2datasource.cpp:3456: warning: too many arguments for format
ogrdb2datasource.cpp:3489: warning: too many arguments for format
ogrdb2datasource.cpp:3494: warning: too many arguments for format
In file included from ogrdb2selectlayer.cpp:32:
ogr_db2.h:148: warning: ‘class OGRDB2Session’ has virtual functions and accessible non-virtual destructor
/home/even/gdal/svn/trunk/gdal/ogr/ogrsf_frmts/ogrsf_frmts.h:123: warning: ‘virtual OGRErr OGRLayer::GetExtent(int, OGREnvelope*, int)’ was hidden
ogr_db2.h:572: warning:   by ‘virtual OGRErr OGRDB2SelectLayer::GetExtent(OGREnvelope*, int)’
ogrdb2selectlayer.cpp: In constructor ‘OGRDB2SelectLayer::OGRDB2SelectLayer(OGRDB2DataSource*, OGRDB2Statement*)’:
ogrdb2selectlayer.cpp:80: warning: ‘int sprintf(char*, const char*, ...)’ is deprecated (declared at /home/even/gdal/svn/trunk/gdal/port/cpl_port.h:815)
ogrdb2selectlayer.cpp:80: warning: ‘int sprintf(char*, const char*, ...)’ is deprecated (declared at /home/even/gdal/svn/trunk/gdal/port/cpl_port.h:815)

Most warnings are not critical, but I guess the one about "too many arguments for format" should be fixed. The ones about sprintf() are because we have deprecated sprintf() for snprintf() in GDAL code.

With CLang 3.7 (surely lots of overlap with above warnings):

In file included from ogrdb2driver.cpp:29:
./ogr_db2.h:159:5: In file included from ogrdb2datasourcemd.cpp:warning31: :
./ogr_db2.h'OGRDB2Session': 159has: 5virtual:  functionsIn file included from  gdaldb2rasterband.cpp:but31warning:
 : ./ogr_db2.hnon-virtual: 159'OGRDB2Session'destructor  has: [-Wnon-virtual-dtor]5virtual :functions
  but non-virtualwarning : destructor [-Wnon-virtual-dtor]'OGRDB2Session' 
has virtual functions but non-virtual destructor [-Wnon-virtual-dtor]
    ~OGRDB2Session();
    ^
    ~OGRDB2Session();
    ^
    ~OGRDB2Session();
    ^
ogrdb2datasourcemd.cpp:68:26: warning: data argument not used by format string [-Wformat-extra-args]
                         GetSession()->GetLastError());
                         ^
ogrdb2datasourcemd.cpp:88:26: warning: data argument not used by format string [-Wformat-extra-args]
                         GetSession()->GetLastError());
                         ^
ogrdb2datasourcemd.cpp:166:26: warning: data argument not used by format string [-Wformat-extra-args]
                         GetSession()->GetLastError());
                         ^
ogrdb2datasourcemd.cpp:171:26: warning: data argument not used by format string [-Wformat-extra-args]
                         GetSession()->GetLastError());
                         ^
ogrdb2datasourcemd.cpp:188:26: warning: data argument not used by format string [-Wformat-extra-args]
                         GetSession()->GetLastError());
                         ^
ogrdb2datasourcemd.cpp:193:26: warning: data argument not used by format string [-Wformat-extra-args]
                         GetSession()->GetLastError());
                         ^
In file included from ogrdb2cli.cpp:29:
./ogr_db2.h:159:5: warning: 'OGRDB2Session' has virtual functions but non-virtual destructor [-Wnon-virtual-dtor]
    ~OGRDB2Session();
    ^
1 warning generated.
7 warnings generated.
1 warning generated.
gdaldb2rasterband.cpp:1640:47: warning: unused parameter 'nRow' [-Wunused-parameter]
CPLErr OGRDB2DataSource::WriteShiftedTile(int nRow, int nCol, int nBand,
                                              ^
gdaldb2rasterband.cpp:1640:57: warning: unused parameter 'nCol' [-Wunused-parameter]
CPLErr OGRDB2DataSource::WriteShiftedTile(int nRow, int nCol, int nBand,
                                                        ^
gdaldb2rasterband.cpp:1640:67: warning: unused parameter 'nBand' [-Wunused-parameter]
CPLErr OGRDB2DataSource::WriteShiftedTile(int nRow, int nCol, int nBand,
                                                                  ^
gdaldb2rasterband.cpp:1641:13: warning: unused parameter 'nDstXOffset' [-Wunused-parameter]
        int nDstXOffset, int nDstYOffset,
            ^
gdaldb2rasterband.cpp:1641:30: warning: unused parameter 'nDstYOffset' [-Wunused-parameter]
        int nDstXOffset, int nDstYOffset,
                             ^
gdaldb2rasterband.cpp:1642:13: warning: unused parameter 'nDstXSize' [-Wunused-parameter]
        int nDstXSize, int nDstYSize)
            ^
gdaldb2rasterband.cpp:1642:28: warning: unused parameter 'nDstYSize' [-Wunused-parameter]
        int nDstXSize, int nDstYSize)
                           ^
gdaldb2rasterband.cpp:2151:13: warning: 'sprintf' is deprecated: Use snprintf() or CPLsnprintf() instead [-Wdeprecated-declarations]
            sprintf( pszTextBuf+iDst, "0x%02x", pabyData[iSrc] );
            ^
/home/even/gdal/svn/trunk/gdal/port/cpl_port.h:815:5: note: 'sprintf' has been explicitly marked deprecated here
int sprintf(char *str, const char* fmt, ...) CPL_PRINT_FUNC_FORMAT(2, 3) CPL_WARN_DEPRECATED("Use snprintf() or CPLsnprintf() instead");
    ^
gdaldb2rasterband.cpp:2156:13: warning: 'sprintf' is deprecated: Use snprintf() or CPLsnprintf() instead [-Wdeprecated-declarations]
            sprintf( pszTextBuf+iDst, "%02x", pabyData[iSrc] );
            ^
/home/even/gdal/svn/trunk/gdal/port/cpl_port.h:815:5: note: 'sprintf' has been explicitly marked deprecated here
int sprintf(char *str, const char* fmt, ...) CPL_PRINT_FUNC_FORMAT(2, 3) CPL_WARN_DEPRECATED("Use snprintf() or CPLsnprintf() instead");
    ^
In file included from ogrdb2datasource.cpp:30:
./ogr_db2.h:159:5: warning: 'OGRDB2Session' has virtual functions but non-virtual destructor [-Wnon-virtual-dtor]
    ~OGRDB2Session();
    ^
ogrdb2datasource.cpp:188:17: warning: implicit conversion of NULL constant to 'int' [-Wnull-conversion]
    m_hTempDB = NULL;
              ~ ^~~~
                0
10 warnings generated.
ogrdb2datasource.cpp:816:20: warning: implicit conversion of NULL constant to 'int' [-Wnull-conversion]
            return NULL;
            ~~~~~~ ^~~~
                   0
In file included from ogrdb2layer.cpp:30:
./ogr_db2.h:159:5: warning: 'OGRDB2Session' has virtual functions but non-virtual destructor [-Wnon-virtual-dtor]
    ~OGRDB2Session();
    ^
ogrdb2layer.cpp:60:56: warning: format specifies type 'int' but the argument has type 'GIntBig' (aka 'long long') [-Wformat]
             "m_nFeaturesRead: %d; poFeatureDefn: %p", m_nFeaturesRead,poFeatureDefn);
                               ~~                      ^~~~~~~~~~~~~~~
                               %lld
ogrdb2layer.cpp:485:13: warning: 'sprintf' is deprecated: Use snprintf() or CPLsnprintf() instead [-Wdeprecated-declarations]
            sprintf( pszTextBuf+iDst, "0x%02x", pabyData[iSrc] );
            ^
/home/even/gdal/svn/trunk/gdal/port/cpl_port.h:815:5: note: 'sprintf' has been explicitly marked deprecated here
int sprintf(char *str, const char* fmt, ...) CPL_PRINT_FUNC_FORMAT(2, 3) CPL_WARN_DEPRECATED("Use snprintf() or CPLsnprintf() instead");
    ^
ogrdb2layer.cpp:490:13: warning: 'sprintf' is deprecated: Use snprintf() or CPLsnprintf() instead [-Wdeprecated-declarations]
            sprintf( pszTextBuf+iDst, "%02x", pabyData[iSrc] );
            ^
/home/even/gdal/svn/trunk/gdal/port/cpl_port.h:815:5: note: 'sprintf' has been explicitly marked deprecated here
int sprintf(char *str, const char* fmt, ...) CPL_PRINT_FUNC_FORMAT(2, 3) CPL_WARN_DEPRECATED("Use snprintf() or CPLsnprintf() instead");
    ^
ogrdb2datasource.cpp:2273:51: warning: unused parameter 'bCheckRasterTable' [-Wunused-parameter]
void OGRDB2DataSource::CheckUnknownExtensions(int bCheckRasterTable)
                                                  ^
In file included from ogrdb2tablelayer.cpp:30:
./ogr_db2.h:159:5: warning: 'OGRDB2Session' has virtual functions but non-virtual destructor [-Wnon-virtual-dtor]
    ~OGRDB2Session();
    ^
ogrdb2datasource.cpp:2951:22: warning: data argument not used by format string [-Wformat-extra-args]
                     GetSession()->GetLastError());
                     ^
ogrdb2datasource.cpp:2956:22: warning: data argument not used by format string [-Wformat-extra-args]
                     GetSession()->GetLastError());
                     ^
ogrdb2datasource.cpp:2970:22: warning: data argument not used by format string [-Wformat-extra-args]
                     GetSession()->GetLastError());
                     ^
ogrdb2datasource.cpp:2975:22: warning: data argument not used by format string [-Wformat-extra-args]
                     GetSession()->GetLastError());
                     ^
4 warnings generated.
ogrdb2datasource.cpp:3425:34: warning: data argument not used by format string [-Wformat-extra-args]
                                 GetSession()->GetLastError());
                                 ^
ogrdb2datasource.cpp:3430:34: warning: data argument not used by format string [-Wformat-extra-args]
                                 GetSession()->GetLastError());
                                 ^
ogrdb2datasource.cpp:3451:34: warning: data argument not used by format string [-Wformat-extra-args]
                                 GetSession()->GetLastError());
                                 ^
ogrdb2datasource.cpp:3456:34: warning: data argument not used by format string [-Wformat-extra-args]
                                 GetSession()->GetLastError());
                                 ^
ogrdb2datasource.cpp:3489:30: warning: data argument not used by format string [-Wformat-extra-args]
                             GetSession()->GetLastError());
                             ^
ogrdb2datasource.cpp:3494:30: warning: data argument not used by format string [-Wformat-extra-args]
                             GetSession()->GetLastError());
                             ^
ogrdb2tablelayer.cpp:652:64: warning: format specifies type 'long' but the argument has type 'GIntBig' (aka 'long long') [-Wformat]
                       poFeatureDefn->GetName(), pszFIDColumn, nFeatureId );
                                                               ^~~~~~~~~~
ogrdb2tablelayer.cpp:781:13: warning: 'sprintf' is deprecated: Use snprintf() or CPLsnprintf() instead [-Wdeprecated-declarations]
            sprintf( szFieldType, "numeric(%d,0)", oField.GetWidth() );
            ^
/home/even/gdal/svn/trunk/gdal/port/cpl_port.h:815:5: note: 'sprintf' has been explicitly marked deprecated here
int sprintf(char *str, const char* fmt, ...) CPL_PRINT_FUNC_FORMAT(2, 3) CPL_WARN_DEPRECATED("Use snprintf() or CPLsnprintf() instead");
    ^
ogrdb2tablelayer.cpp:788:13: warning: 'sprintf' is deprecated: Use snprintf() or CPLsnprintf() instead [-Wdeprecated-declarations]
            sprintf( szFieldType, "numeric(%d,0)", oField.GetWidth() );
            ^
/home/even/gdal/svn/trunk/gdal/port/cpl_port.h:815:5: note: 'sprintf' has been explicitly marked deprecated here
int sprintf(char *str, const char* fmt, ...) CPL_PRINT_FUNC_FORMAT(2, 3) CPL_WARN_DEPRECATED("Use snprintf() or CPLsnprintf() instead");
    ^
ogrdb2tablelayer.cpp:796:13: warning: 'sprintf' is deprecated: Use snprintf() or CPLsnprintf() instead [-Wdeprecated-declarations]
            sprintf( szFieldType, "numeric(%d,%d)",
            ^
/home/even/gdal/svn/trunk/gdal/port/cpl_port.h:815:5: note: 'sprintf' has been explicitly marked deprecated here
int sprintf(char *str, const char* fmt, ...) CPL_PRINT_FUNC_FORMAT(2, 3) CPL_WARN_DEPRECATED("Use snprintf() or CPLsnprintf() instead");
    ^
ogrdb2tablelayer.cpp:806:13: warning: 'sprintf' is deprecated: Use snprintf() or CPLsnprintf() instead [-Wdeprecated-declarations]
            sprintf( szFieldType, "varchar(%d)", oField.GetWidth() );
            ^
/home/even/gdal/svn/trunk/gdal/port/cpl_port.h:815:5: note: 'sprintf' has been explicitly marked deprecated here
int sprintf(char *str, const char* fmt, ...) CPL_PRINT_FUNC_FORMAT(2, 3) CPL_WARN_DEPRECATED("Use snprintf() or CPLsnprintf() instead");
    ^
ogrdb2tablelayer.cpp:1308:58: warning: unused parameter 'poStatement' [-Wunused-parameter]
OGRErr OGRDB2TableLayer::BindFieldValue(OGRDB2Statement *poStatement,
                                                         ^
7 warnings generated.
14 warnings generated.
In file included from ogrdb2selectlayer.cpp:32:
./ogr_db2.h:159:5: warning: 'OGRDB2Session' has virtual functions but non-virtual destructor [-Wnon-virtual-dtor]
    ~OGRDB2Session();
    ^
ogrdb2selectlayer.cpp:80:9: warning: 'sprintf' is deprecated: Use snprintf() or CPLsnprintf() instead [-Wdeprecated-declarations]
        sprintf(szLayerName, "%s.%s",szSchemaName, szTableName);
        ^
/home/even/gdal/svn/trunk/gdal/port/cpl_port.h:815:5: note: 'sprintf' has been explicitly marked deprecated here
int sprintf(char *str, const char* fmt, ...) CPL_PRINT_FUNC_FORMAT(2, 3) CPL_WARN_DEPRECATED("Use snprintf() or CPLsnprintf() instead");
    ^
2 warnings generated.

I also ran CLang Static Analyzer and it emits:

gdaldb2rasterband.cpp:134:13: warning: Value stored to 'nRetCode' is never read
            nRetCode = SQLGetData(oStatement.GetStatement(),
            ^          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
gdaldb2rasterband.cpp:598:9: warning: Value stored to 'nRetCode' is never read
        nRetCode = SQLGetData(oStatement.GetStatement(),
        ^          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
gdaldb2rasterband.cpp:676:17: warning: Value stored to 'nRetCode' is never read
                nRetCode = SQLGetData(oStatement.GetStatement(),
                ^          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
ogrdb2datasource.cpp:750:9: warning: Value stored to 'bFileExists' is never read
        bFileExists = TRUE;
        ^             ~~~~
ogrdb2datasource.cpp:1351:54: warning: Array access (from variable 'papszTypes') results in a null pointer dereference
                     m_papszGeomColumnNames[iTable], papszTypes[iTable],
                                                     ^~~~~~~~~~~~~~~~~~
ogrdb2datasource.cpp:2912:9: warning: Value stored to 'nSRID' is never read
        nSRID = FetchSRSId( &oSRS );
        ^       ~~~~~~~~~~~~~~~~~~~
ogrdb2tablelayer.cpp:42:36: warning: Null pointer passed as an argument to a 'nonnull' parameter
    size_t  iIn, iOut , nTextLen = strlen(pszStrValue);
                                   ^~~~~~~~~~~~~~~~~~~

Some might be false positives.

If the above was fixed, we could potentially include the db2 driver in Linux builds for running those kinds of checks regularly (perhaps with an explict --with-db2 in the ./configure if the DB2 driver doesn't make sense at runtime due to unavailable ODBC driver), and for Coverity Scan too.

Change History (2)

comment:1 Changed 6 years ago by dadler

Even, thank you for trying this out. It is amazing the warnings that vary from compiler to compiler.

I'm tied up with adding DB2 support to QGIS right now but will take a look at these as soon as I can. I also need to look at the GPKG raster fixes that may be applicable to DB2.

It is my intent to add plugin support for DB2 on Linux using the DB2 CLI interface.

comment:2 Changed 5 years ago by Even Rouault

Resolution: fixed
Status: newclosed

It seems I have fixed the warnings a few months ago. Closing

Note: See TracTickets for help on using tickets.