Opened 9 years ago
Closed 9 years ago
#5787 closed defect (fixed)
Where is CPLvsprintf defined?
Reported by: | Kurt Schwehr | Owned by: | Kurt Schwehr |
---|---|---|---|
Priority: | normal | Milestone: | |
Component: | default | Version: | svn-trunk |
Severity: | normal | Keywords: | |
Cc: |
Description
Not sure why I wasn't seeing this error earlier. Perhaps it's my switching to clang? Whatever the cause, where is the CPLvsprintf function? I'm pretty sure this is supposed to be CPLvsnprintf ("n" was missing).
Possible fix (I have not yet run the test suite on it):
Index: port/cplstring.cpp =================================================================== --- port/cplstring.cpp (revision 28195) +++ port/cplstring.cpp (working copy) @@ -69,9 +69,9 @@ #if !defined(HAVE_VSNPRINTF) char *pszBuffer = (char *) CPLMalloc(30000); - if( CPLvsprintf( pszBuffer, pszFormat, args) > 29998 ) + if( CPLvsnprintf( pszBuffer, 30000, pszFormat, args) > 29998 ) { CPLError( CE_Fatal, CPLE_AppDefined, Index: port/cpl_error.cpp =================================================================== --- port/cpl_error.cpp (revision 28195) +++ port/cpl_error.cpp (working copy) @@ -235,7 +235,8 @@ va_end( wrk_args ); } #else - CPLvsprintf( psCtx->szLastErrMsg, fmt, args); + // !HAVE_VSNPRINTF + CPLvsnprintf( psCtx->szLastErrMsg, psCtx->nLastErrMsgMax, fmt, args); #endif
svn info | egrep 'Revision|Relative' Relative URL: ^/trunk/gdal Revision: 28194 find . -type f | grep -v svn | xargs grep -i CPLvsprintf ./port/cpl_error.cpp: CPLvsprintf( psCtx->szLastErrMsg, fmt, args); ./port/cplstring.cpp: if( CPLvsprintf( pszBuffer, pszFormat, args) > 29998 )
CPPFLAGS="-Wall -Wextra -Werror" CC=clang CXX=clang++ ./configure --prefix=$HOME/src/gdal/inst --mandir='${prefix}/share/man' --with-local=/sw --with-libz=/sw --with-liblzma=yes --with-cfitsio=/sw --with-netcdf=/sw --with-png=/sw --with-libtiff=/sw --with-geotiff=internal --with-jpeg=/sw --with-gif=/sw --with-ogdi=/sw --without-jasper --without-bsb --with-ogr --without-sqlite3 --without-spatialite --without-hdf5 --with-geos=/sw/opt/libgeos3.4.2/bin/geos-config --with-xerces=yes --with-xerces-inc=/sw/include --with-xerces-lib='-L/sw/lib -lxerces-c -lpthread' --with-static-proj4=/sw --without-pg --with-odbc=/sw --with-grass=no --with-pcraster=no --with-hdf4=no --with-oci=no --with-fme=no --with-ecw=no --with-kakadu=no --with-mrsid=no --with-dods-root=no --with-webp=no --without-php --without-perl --without-ruby --with-python --with-poppler=/sw --with-libjson-c=internal make /bin/sh /Users/schwehr/src/gdal/gdal/libtool --mode=compile --tag=CXX clang++ -I/Users/schwehr/src/gdal/gdal/port -I/Users/schwehr/src/gdal/gdal/gcore -I/Users/schwehr/src/gdal/gdal/alg -I/Users/schwehr/src/gdal/gdal/ogr -I/Users/schwehr/src/gdal/gdal/ogr/ogrsf_frmts -g -O2 -Wall -DOGR_ENABLED -Wall -Wextra -Werror -I/sw/include -I/Users/schwehr/src/gdal/gdal/port -I/sw -I/sw/include -I/sw/include -I/sw -I/sw/include -I/sw -I/sw/include -I/sw/include -I/sw -I/sw/include -I/sw -I/sw/include -I/sw -I/sw/include -DGDAL_COMPILATION -I/sw/include -DHAVE_CURL -DHAVE_LIBZ -I/sw/include/libxml2 -I/sw/include -DHAVE_LIBXML2 -c -o cpl_error.lo cpl_error.cpp libtool: compile: clang++ -I/Users/schwehr/src/gdal/gdal/port -I/Users/schwehr/src/gdal/gdal/gcore -I/Users/schwehr/src/gdal/gdal/alg -I/Users/schwehr/src/gdal/gdal/ogr -I/Users/schwehr/src/gdal/gdal/ogr/ogrsf_frmts -g -O2 -Wall -DOGR_ENABLED -Wall -Wextra -Werror -I/sw/include -I/Users/schwehr/src/gdal/gdal/port -I/sw -I/sw/include -I/sw/include -I/sw -I/sw/include -I/sw -I/sw/include -I/sw/include -I/sw -I/sw/include -I/sw -I/sw/include -I/sw -I/sw/include -DGDAL_COMPILATION -I/sw/include -DHAVE_CURL -DHAVE_LIBZ -I/sw/include/libxml2 -I/sw/include -DHAVE_LIBXML2 -c cpl_error.cpp -fno-common -DPIC -o .libs/cpl_error.o cpl_error.cpp:238:5: error: use of undeclared identifier 'CPLvsprintf'; did you mean 'CPLsnprintf'? CPLvsprintf( psCtx->szLastErrMsg, fmt, args); ^~~~~~~~~~~ CPLsnprintf /Users/schwehr/src/gdal/gdal/port/cpl_string.h:158:13: note: 'CPLsnprintf' declared here int CPL_DLL CPLsnprintf(char *str, size_t size, const char* fmt, ...) CPL_PRINT_FUNC_FORMAT(3,4); ^ cpl_error.cpp:238:39: error: cannot initialize a parameter of type 'size_t' (aka 'unsigned long') with an lvalue of type 'const char *' CPLvsprintf( psCtx->szLastErrMsg, fmt, args); ^~~ /Users/schwehr/src/gdal/gdal/port/cpl_string.h:158:43: note: passing argument to parameter 'size' here int CPL_DLL CPLsnprintf(char *str, size_t size, const char* fmt, ...) CPL_PRINT_FUNC_FORMAT(3,4); ^ 2 errors generated. make: *** [cpl_error.lo] Error 1
Change History (5)
comment:1 by , 9 years ago
comment:2 by , 9 years ago
Owner: | changed from | to
---|---|
Status: | new → assigned |
The test for vsnprintf is failing like this with clang:
configure:17158: result: no configure:17158: checking for vsnprintf configure:17158: clang -o conftest -g -O2 -Wall -Wextra -Werror conftest.c -ldl >&5 conftest.c:69:6: error: incompatible redeclaration of library function 'vsnprintf' [-Werror,-Wincompatible-library-redeclaration] char vsnprintf (); ^ conftest.c:69:6: note: 'vsnprintf' is a builtin with type 'int (char *, unsigned long, const char *, __va_list_tag *)' 1 error generated. configure:17158: $? = 1 configure: failed program was: | /* confdefs.h */ | #define PACKAGE_NAME "" [SNIP] | #define HAVE_IEEEFP 1 | #define HOST_FILLORDER FILLORDER_LSB2MSB | /* end confdefs.h. */ | /* Define vsnprintf to an innocuous variant, in case <limits.h> declares vsnprintf. | For example, HP-UX 11i <limits.h> declares gettimeofday. */ | #define vsnprintf innocuous_vsnprintf | | /* System header to define __stub macros and hopefully few prototypes, | which can conflict with char vsnprintf (); below. | Prefer <limits.h> to <assert.h> if __STDC__ is defined, since | <limits.h> exists even on freestanding compilers. */ | | #ifdef __STDC__ | # include <limits.h> | #else | # include <assert.h> | #endif | | #undef vsnprintf | | /* Override any GCC internal prototype to avoid an error. | Use char because int might match the return type of a GCC | builtin and then its argument prototype would still apply. */ | #ifdef __cplusplus | extern "C" | #endif | char vsnprintf (); | /* The GNU C library defines this for functions which it implements | to always fail with ENOSYS. Some functions are actually named | something starting with __ and the normal name is an alias. */ | #if defined __stub_vsnprintf || defined __stub___vsnprintf | choke me | #endif | | int | main () | { | return vsnprintf (); | ; | return 0; | }
clang --version Apple LLVM version 6.0 (clang-600.0.54) (based on LLVM 3.5svn) Target: x86_64-apple-darwin13.4.0 Thread model: posix
comment:5 by , 9 years ago
Resolution: | → fixed |
---|---|
Status: | assigned → closed |
Note:
See TracTickets
for help on using tickets.
Your patch looks good. CPLvsprintf() hasn't been implemented indeed, so using CPLvsnprintf() instead is OK. Starnge that with clang you don't have HAVE_VSNPRINTF defined