aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorEven Rouault <even.rouault@spatialys.com>2018-03-12 23:57:46 +0100
committerEven Rouault <even.rouault@spatialys.com>2018-03-14 20:25:13 +0100
commita9269cc2aca3cd8851e3860d191eec27ae4a7a56 (patch)
treea41759182891feb4d3e70fd777a998cd477a15f9 /src
parent643a5237908cbb40fd592ac6bfec9a095c267f6e (diff)
downloadPROJ-a9269cc2aca3cd8851e3860d191eec27ae4a7a56.tar.gz
PROJ-a9269cc2aca3cd8851e3860d191eec27ae4a7a56.zip
Use a function to dereference a double value, to avoid false positive warning with older cppcheck versions
Diffstat (limited to 'src')
-rw-r--r--src/pj_gridinfo.c37
1 files changed, 25 insertions, 12 deletions
diff --git a/src/pj_gridinfo.c b/src/pj_gridinfo.c
index e5e08c92..9a8b3dd5 100644
--- a/src/pj_gridinfo.c
+++ b/src/pj_gridinfo.c
@@ -66,6 +66,19 @@ static void swap_words( unsigned char *data, int word_size, int word_count )
}
/************************************************************************/
+/* to_double() */
+/* */
+/* Returns a double from the pointed data. */
+/************************************************************************/
+
+static double to_double( unsigned char* data )
+{
+ double d;
+ memcpy(&d, data, sizeof(d));
+ return d;
+}
+
+/************************************************************************/
/* pj_gridinfo_free() */
/************************************************************************/
@@ -510,14 +523,14 @@ static int pj_gridinfo_init_ntv2( projCtx ctx, PAFile fid, PJ_GRIDINFO *gilist )
strncpy( ct->id, (const char *) header + 8, 8 );
ct->id[8] = '\0';
- ct->ll.lam = - *((double *) (header+7*16+8)); /* W_LONG */
- ct->ll.phi = *((double *) (header+4*16+8)); /* S_LAT */
+ ct->ll.lam = - to_double(header+7*16+8); /* W_LONG */
+ ct->ll.phi = to_double(header+4*16+8); /* S_LAT */
- ur.lam = - *((double *) (header+6*16+8)); /* E_LONG */
- ur.phi = *((double *) (header+5*16+8)); /* N_LAT */
+ ur.lam = - to_double(header+6*16+8); /* E_LONG */
+ ur.phi = to_double(header+5*16+8); /* N_LAT */
- ct->del.lam = *((double *) (header+9*16+8));
- ct->del.phi = *((double *) (header+8*16+8));
+ ct->del.lam = to_double(header+9*16+8);
+ ct->del.phi = to_double(header+8*16+8);
ct->lim.lam = (pj_int32) (fabs(ur.lam-ct->ll.lam)/ct->del.lam + 0.5) + 1;
ct->lim.phi = (pj_int32) (fabs(ur.phi-ct->ll.phi)/ct->del.phi + 0.5) + 1;
@@ -693,12 +706,12 @@ static int pj_gridinfo_init_ntv1( projCtx ctx, PAFile fid, PJ_GRIDINFO *gi )
}
strcpy( ct->id, "NTv1 Grid Shift File" );
- ct->ll.lam = - *((double *) (header+72));
- ct->ll.phi = *((double *) (header+24));
- ur.lam = - *((double *) (header+56));
- ur.phi = *((double *) (header+40));
- ct->del.lam = *((double *) (header+104));
- ct->del.phi = *((double *) (header+88));
+ ct->ll.lam = - to_double(header+72);
+ ct->ll.phi = to_double(header+24);
+ ur.lam = - to_double(header+56);
+ ur.phi = to_double(header+40);
+ ct->del.lam = to_double(header+104);
+ ct->del.phi = to_double(header+88);
ct->lim.lam = (pj_int32) (fabs(ur.lam-ct->ll.lam)/ct->del.lam + 0.5) + 1;
ct->lim.phi = (pj_int32) (fabs(ur.phi-ct->ll.phi)/ct->del.phi + 0.5) + 1;