From 8ee165bc2875061add577bf290b2ba1629a1cd7a Mon Sep 17 00:00:00 2001 From: Roland Winklmeier Date: Mon, 11 Jan 2016 16:01:57 +0100 Subject: [PATCH] [g2clib] Fix up type detection and printf arguments on 64-bit machines Patch from Fedora 23 http://pkgs.fedoraproject.org/cgit/rpms/g2clib.git/tree/g2clib-64bit.patch --- src/plugins/weatherdata/gfs/g2clib/g2_addfield.c | 7 ++++--- src/plugins/weatherdata/gfs/g2clib/g2_addgrid.c | 5 +++-- src/plugins/weatherdata/gfs/g2clib/g2_addlocal.c | 7 ++++--- src/plugins/weatherdata/gfs/g2clib/g2_getfld.c | 9 +++++---- src/plugins/weatherdata/gfs/g2clib/g2_gribend.c | 3 ++- src/plugins/weatherdata/gfs/g2clib/g2_info.c | 3 ++- src/plugins/weatherdata/gfs/g2clib/grib2.h | 10 +++------- 7 files changed, 23 insertions(+), 21 deletions(-) diff --git a/src/plugins/weatherdata/gfs/g2clib/g2_addfield.c b/src/plugins/weatherdata/gfs/g2clib/g2_addfield.c index db2853a4e..14a0301b0 100644 --- a/src/plugins/weatherdata/gfs/g2clib/g2_addfield.c +++ b/src/plugins/weatherdata/gfs/g2clib/g2_addfield.c @@ -1,3 +1,4 @@ +#include #include #include #include "grib2.h" @@ -190,8 +191,8 @@ g2int g2_addfield(unsigned char *cgrib,g2int ipdsnum,g2int *ipdstmpl, // total length, then there is a problem. if ( len > lencurr ) { printf("g2_addfield: Section byte counts don''t add to total.\n"); - printf("g2_addfield: Sum of section byte counts = %ld\n",len); - printf("g2_addfield: Total byte count in Section 0 = %ld\n",lencurr); + printf("g2_addfield: Sum of section byte counts = %"PRId32"\n",len); + printf("g2_addfield: Total byte count in Section 0 = %"PRId32"\n",lencurr); ierr=-3; return(ierr); } @@ -392,7 +393,7 @@ g2int g2_addfield(unsigned char *cgrib,g2int ipdsnum,g2int *ipdstmpl, } #endif /* USE_PNG */ else { - printf("g2_addfield: Data Representation Template 5.%ld not yet implemented.\n",idrsnum); + printf("g2_addfield: Data Representation Template 5.%"PRId32" not yet implemented.\n",idrsnum); ierr=-7; return(ierr); } diff --git a/src/plugins/weatherdata/gfs/g2clib/g2_addgrid.c b/src/plugins/weatherdata/gfs/g2clib/g2_addgrid.c index 55fb8f752..8feb2f585 100644 --- a/src/plugins/weatherdata/gfs/g2clib/g2_addgrid.c +++ b/src/plugins/weatherdata/gfs/g2clib/g2_addgrid.c @@ -1,3 +1,4 @@ +#include #include #include #include "grib2.h" @@ -125,8 +126,8 @@ g2int g2_addgrid(unsigned char *cgrib,g2int *igds,g2int *igdstmpl,g2int *ideflis // total length, then there is a problem. if ( len > lencurr ) { printf("g2_addgrid: Section byte counts don''t add to total.\n"); - printf("g2_addgrid: Sum of section byte counts = %ld\n",len); - printf("g2_addgrid: Total byte count in Section 0 = %ld\n",lencurr); + printf("g2_addgrid: Sum of section byte counts = %"PRId32"\n",len); + printf("g2_addgrid: Total byte count in Section 0 = %"PRId32"\n",lencurr); ierr=-3; return(ierr); } diff --git a/src/plugins/weatherdata/gfs/g2clib/g2_addlocal.c b/src/plugins/weatherdata/gfs/g2clib/g2_addlocal.c index c291367b2..e4f295142 100644 --- a/src/plugins/weatherdata/gfs/g2clib/g2_addlocal.c +++ b/src/plugins/weatherdata/gfs/g2clib/g2_addlocal.c @@ -1,3 +1,4 @@ +#include #include #include "grib2.h" @@ -102,8 +103,8 @@ g2int g2_addlocal(unsigned char *cgrib,unsigned char *csec2,g2int lcsec2) // total length, then there is a problem. if ( len > lencurr ) { printf("g2_addlocal: Section byte counts don't add to total.\n"); - printf("g2_addlocal: Sum of section byte counts = %ld\n",len); - printf("g2_addlocal: Total byte count in Section 0 = %ld\n",lencurr); + printf("g2_addlocal: Sum of section byte counts = %"PRId32"\n",len); + printf("g2_addlocal: Total byte count in Section 0 = %"PRId32"\n",lencurr); ierr=-3; return(ierr); } @@ -113,7 +114,7 @@ g2int g2_addlocal(unsigned char *cgrib,unsigned char *csec2,g2int lcsec2) // if ( (isecnum!=1) && (isecnum!=7) ) { printf("g2_addlocal: Section 2 can only be added after Section 1 or Section 7.\n"); - printf("g2_addlocal: Section %ld was the last found in given GRIB message.\n",isecnum); + printf("g2_addlocal: Section %"PRId32" was the last found in given GRIB message.\n",isecnum); ierr=-4; return(ierr); } diff --git a/src/plugins/weatherdata/gfs/g2clib/g2_getfld.c b/src/plugins/weatherdata/gfs/g2clib/g2_getfld.c index 239c2f768..2bfb1cfd8 100644 --- a/src/plugins/weatherdata/gfs/g2clib/g2_getfld.c +++ b/src/plugins/weatherdata/gfs/g2clib/g2_getfld.c @@ -1,3 +1,4 @@ +#include #include #include #include "grib2.h" @@ -345,12 +346,12 @@ g2int g2_getfld(unsigned char *cgrib,g2int ifldnum,g2int unpack,g2int expand, iofst=iofst+32; gbit(cgrib,&isecnum,iofst,8); // Get Section number iofst=iofst+8; - //printf(" lensec= %ld secnum= %ld \n",lensec,isecnum); + //printf(" lensec= %"PRId32" secnum= %"PRId32" \n",lensec,isecnum); // // Check to see if section number is valid // if ( isecnum<1 || isecnum>7 ) { - printf("g2_getfld: Unrecognized Section Encountered=%ld\n",isecnum); + printf("g2_getfld: Unrecognized Section Encountered=%"PRId32"\n",isecnum); ierr=8; return(ierr); } @@ -543,8 +544,8 @@ g2int g2_getfld(unsigned char *cgrib,g2int ifldnum,g2int unpack,g2int expand, // If exited from above loop, the end of the GRIB message was reached // before the requested field was found. // - printf("g2_getfld: GRIB message contained %ld different fields.\n",numfld); - printf("g2_getfld: The request was for field %ld.\n",ifldnum); + printf("g2_getfld: GRIB message contained %"PRId32" different fields.\n",numfld); + printf("g2_getfld: The request was for field %"PRId32".\n",ifldnum); ierr=6; return(ierr); diff --git a/src/plugins/weatherdata/gfs/g2clib/g2_gribend.c b/src/plugins/weatherdata/gfs/g2clib/g2_gribend.c index 5373aaada..b50f2c001 100644 --- a/src/plugins/weatherdata/gfs/g2clib/g2_gribend.c +++ b/src/plugins/weatherdata/gfs/g2clib/g2_gribend.c @@ -1,3 +1,4 @@ +#include #include #include "grib2.h" @@ -97,7 +98,7 @@ g2int g2_gribend(unsigned char *cgrib) // if ( isecnum != 7 ) { printf("g2_gribend: Section 8 can only be added after Section 7.\n"); - printf("g2_gribend: Section %ld was the last found in given GRIB message.\n",isecnum); + printf("g2_gribend: Section %"PRId32" was the last found in given GRIB message.\n",isecnum); ierr=-4; return (ierr); } diff --git a/src/plugins/weatherdata/gfs/g2clib/g2_info.c b/src/plugins/weatherdata/gfs/g2clib/g2_info.c index 443a5b868..4b9fdeb56 100644 --- a/src/plugins/weatherdata/gfs/g2clib/g2_info.c +++ b/src/plugins/weatherdata/gfs/g2clib/g2_info.c @@ -1,3 +1,4 @@ +#include #include #include #include "grib2.h" @@ -178,7 +179,7 @@ g2int g2_info(unsigned char *cgrib,g2int *listsec0,g2int *listsec1, (*numfields)++; } else { - printf("g2_info: Invalid section number found in GRIB message: %ld\n" ,isecnum); + printf("g2_info: Invalid section number found in GRIB message: %"PRId32"\n" ,isecnum); ierr=6; return(ierr); } diff --git a/src/plugins/weatherdata/gfs/g2clib/grib2.h b/src/plugins/weatherdata/gfs/g2clib/grib2.h index 7d40f349c..ddbebd446 100644 --- a/src/plugins/weatherdata/gfs/g2clib/grib2.h +++ b/src/plugins/weatherdata/gfs/g2clib/grib2.h @@ -5,6 +5,7 @@ extern "C" { #endif +#include #include #define G2_VERSION "g2clib-1.5.0" @@ -156,13 +157,8 @@ extern "C" { // that holds the data. */ -#ifdef __64BIT__ -typedef int g2int; -typedef unsigned int g2intu; -#else -typedef long g2int; -typedef unsigned long g2intu; -#endif +typedef int32_t g2int; +typedef uint32_t g2intu; typedef float g2float; struct gtemplate {