Commit 68b83be2 authored by Thomas Jahns's avatar Thomas Jahns 🤸
Browse files

Fix multiple int->string conversions and implicit type conversions.

parent a1f63b00
...@@ -17,19 +17,26 @@ ...@@ -17,19 +17,26 @@
#define STRING(x) XSTRING(x) #define STRING(x) XSTRING(x)
static char gribapi_libvers[64] = ""; static char gribapi_libvers[64] = "";
#if defined (HAVE_LIBGRIB_API)
static int gribapi_libvers_init;
#endif
const char *gribapiLibraryVersion(void) const char *gribapiLibraryVersion(void)
{ {
#if defined (HAVE_LIBGRIB_API) #if defined (HAVE_LIBGRIB_API)
if (!gribapi_libvers_init)
{
long version = grib_get_api_version(); long version = grib_get_api_version();
int major_version, minor_version, revision_version; int major_version, minor_version, revision_version;
major_version = version/10000; major_version = (int)(version/10000L);
minor_version = (version-major_version*10000)/100; minor_version = (int)(version-(long)major_version*10000L)/100;
revision_version = (version-major_version*10000-minor_version*100); revision_version = (int)(version-(long)major_version*10000L - minor_version*100);
sprintf(gribapi_libvers, "%d.%d.%d", sprintf(gribapi_libvers, "%d.%d.%d",
major_version, minor_version, revision_version); major_version, minor_version, revision_version);
gribapi_libvers_init = 1;
}
#endif #endif
return (gribapi_libvers); return (gribapi_libvers);
...@@ -69,8 +76,8 @@ void gribContainersNew(stream_t * streamptr) ...@@ -69,8 +76,8 @@ void gribContainersNew(stream_t * streamptr)
streamptr->gribContainers = (void **) gribContainers; streamptr->gribContainers = (void **) gribContainers;
#else #else
gribContainer_t *gribContainers; gribContainer_t *gribContainers
gribContainers = (gribContainer_t *) malloc(nvars*sizeof(gribContainer_t)); = (gribContainer_t *)xmalloc((size_t)nvars*sizeof(gribContainer_t));
for ( int varID = 0; varID < nvars; ++varID ) for ( int varID = 0; varID < nvars; ++varID )
{ {
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment