From f9bc979b0083f81b313eef9c66301bc2510446b7 Mon Sep 17 00:00:00 2001 From: Uwe Schulzweida <uwe.schulzweida@mpimet.mpg.de> Date: Sun, 14 Apr 2019 09:25:10 +0200 Subject: [PATCH] Fix scan-build warning: Result of 'malloc' is converted to a pointer of type 'double', which is incompatible with sizeof operand type 'int'. --- src/stream_cdf_i.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/stream_cdf_i.c b/src/stream_cdf_i.c index f15c5b014..3a3945db4 100644 --- a/src/stream_cdf_i.c +++ b/src/stream_cdf_i.c @@ -3267,7 +3267,7 @@ void cdf_copy_attint(int fileID, int vlistID, nc_type xtype, size_t attlen, char int attint[8]; int *pattint = (attlen > 8) ? (int*) malloc(attlen*sizeof(int)) : attint; cdfGetAttInt(fileID, NC_GLOBAL, attname, attlen, pattint); - int datatype = (xtype == NC_SHORT) ? CDI_DATATYPE_INT16 : CDI_DATATYPE_INT32; + const int datatype = (xtype == NC_SHORT) ? CDI_DATATYPE_INT16 : CDI_DATATYPE_INT32; cdiDefAttInt(vlistID, CDI_GLOBAL, attname, datatype, (int)attlen, pattint); if (attlen > 8) free(pattint); } @@ -3276,9 +3276,9 @@ static void cdf_copy_attflt(int fileID, int vlistID, nc_type xtype, size_t attlen, char *attname) { double attflt[8]; - double *pattflt = (attlen > 8) ? (double*) malloc(attlen*sizeof(int)) : attflt; + double *pattflt = (attlen > 8) ? (double*) malloc(attlen*sizeof(double)) : attflt; cdfGetAttDouble(fileID, NC_GLOBAL, attname, attlen, pattflt); - int datatype = (xtype == NC_FLOAT) ? CDI_DATATYPE_FLT32 : CDI_DATATYPE_FLT64; + const int datatype = (xtype == NC_FLOAT) ? CDI_DATATYPE_FLT32 : CDI_DATATYPE_FLT64; cdiDefAttFlt(vlistID, CDI_GLOBAL, attname, datatype, (int)attlen, pattflt); if (attlen > 8) free(pattflt); } -- GitLab