From 66e04bf4e5cdb27a44e9bea6bacad22c02df2f0d Mon Sep 17 00:00:00 2001 From: Even Rouault Date: Sun, 26 Feb 2017 00:22:03 +0100 Subject: [PATCH 01/12] Fix warnings related to -Wshadow -Wnull-dereference -Wfloat-conversionr -Wmissing-prototypes -Wmissing-declarations --- src/PJ_healpix.c | 11 +++--- src/PJ_horner.c | 4 ++ src/PJ_isea.c | 17 +++++---- src/PJ_qsc.c | 2 +- src/PJ_robin.c | 82 ++++++++++++++++++++-------------------- src/cs2cs.c | 9 +++-- src/emess.h | 3 +- src/gen_cheb.c | 9 ++++- src/nad2bin.c | 14 +++---- src/nad_intr.c | 4 +- src/p_series.c | 7 +++- src/pj_apply_gridshift.c | 2 +- src/pj_fileapi.c | 2 +- src/pj_gridinfo.c | 8 ++-- src/pj_log.c | 1 + src/pj_malloc.c | 2 +- src/pj_obs_api.c | 8 ++-- src/pj_transform.c | 4 +- src/proj.c | 7 +++- src/proj_api.h | 2 +- src/projects.h | 2 + src/rtodms.c | 6 +-- 22 files changed, 115 insertions(+), 91 deletions(-) diff --git a/src/PJ_healpix.c b/src/PJ_healpix.c index 781fbb7a73..fc2122c53a 100644 --- a/src/PJ_healpix.c +++ b/src/PJ_healpix.c @@ -68,7 +68,7 @@ double rot[7][2][2] = ROT; * @param v the parameter whose sign is returned. * @return 1 for positive number, -1 for negative, and 0 for zero. **/ -double pj_sign (double v) { +static double pj_sign (double v) { return v > 0 ? 1 : (v < 0 ? -1 : 0); } @@ -152,7 +152,8 @@ static int pnpoly(int nvert, double vert[][2], double testx, double testy) { * @param north_square the position of the north polar square (rHEALPix only) * @param south_square the position of the south polar square (rHEALPix only) **/ -int in_image(double x, double y, int proj, int north_square, int south_square) { +static int in_image(double x, double y, int proj, int north_square, + int south_square) { if (proj == 0) { double healpixVertsJit[][2] = { {-M_PI - EPS, M_FORTPI}, @@ -223,7 +224,7 @@ int in_image(double x, double y, int proj, int north_square, int south_square) { * return the approximate latitude of authalic latitude alpha (if inverse=1). * P contains the relevant ellipsoid parameters. **/ -double auth_lat(PJ *P, double alpha, int inverse) { +static double auth_lat(PJ *P, double alpha, int inverse) { struct pj_opaque *Q = P->opaque; if (inverse == 0) { /* Authalic latitude. */ @@ -247,7 +248,7 @@ double auth_lat(PJ *P, double alpha, int inverse) { * Return the HEALPix projection of the longitude-latitude point lp on * the unit sphere. **/ -XY healpix_sphere(LP lp) { +static XY healpix_sphere(LP lp) { double lam = lp.lam; double phi = lp.phi; double phi0 = asin(2.0/3.0); @@ -275,7 +276,7 @@ XY healpix_sphere(LP lp) { /** * Return the inverse of healpix_sphere(). **/ -LP healpix_sphere_inverse(XY xy) { +static LP healpix_sphere_inverse(XY xy) { LP lp; double x = xy.x; double y = xy.y; diff --git a/src/PJ_horner.c b/src/PJ_horner.c index 08b64ab9a5..3dde29c8a4 100644 --- a/src/PJ_horner.c +++ b/src/PJ_horner.c @@ -451,6 +451,10 @@ PJ *PROJECTION(horner) { complex_horner = 1; Q = horner_alloc (degree, complex_horner); + if (Q == 0) + { + return horner_freeup (P); + } P->opaque = (void *) Q; if (complex_horner) { diff --git a/src/PJ_isea.c b/src/PJ_isea.c index ab9a5a8c28..cd87d56556 100644 --- a/src/PJ_isea.c +++ b/src/PJ_isea.c @@ -75,9 +75,12 @@ int hexbin2(double width, double x, double y, z = -x - y; - ix = rx = floor(x + 0.5); - iy = ry = floor(y + 0.5); - iz = rz = floor(z + 0.5); + rx = floor(x + 0.5); + ix = (int)rx; + ry = floor(y + 0.5); + iy = (int)ry; + rz = floor(z + 0.5); + iz = (int)rz; s = ix + iy + iz; @@ -126,7 +129,7 @@ struct isea_dgg { int triangle; /* triangle of last transformed point */ int quad; /* quad of last transformed point */ unsigned long serial; -}; +}; struct isea_pt { double x, y; @@ -892,7 +895,7 @@ int isea_disn(struct isea_dgg *g, int quad, struct isea_pt *di) { sn += 2; } else { sidelength = (int) (pow(g->aperture, g->resolution / 2.0) + 0.5); - sn = (quad - 1) * hexes + sidelength * di->x + di->y + 2; + sn = (int) ((quad - 1) * hexes + sidelength * di->x + di->y + 2); } g->serial = sn; @@ -918,8 +921,8 @@ int isea_hex(struct isea_dgg *g, int tri, return 1; - d = v.x; - i = v.y; + d = (int)v.x; + i = (int)v.y; /* Aperture 3 odd resolutions */ if (g->aperture == 3 && g->resolution % 2 != 0) { diff --git a/src/PJ_qsc.c b/src/PJ_qsc.c index 5881290ba2..faf60114f4 100644 --- a/src/PJ_qsc.c +++ b/src/PJ_qsc.c @@ -292,7 +292,7 @@ static LP e_inverse (XY xy, PJ *P) { /* Ellipsoidal, inverse */ } } else { /* Compute phi and lam via cartesian unit sphere coordinates. */ - double q, r, s, t; + double q, r, s; q = cosphi; t = q * q; if (t >= 1.0) { diff --git a/src/PJ_robin.c b/src/PJ_robin.c index 8f6371e734..93330072db 100644 --- a/src/PJ_robin.c +++ b/src/PJ_robin.c @@ -20,47 +20,47 @@ struct COEFS { }; static const struct COEFS X[] = { - {1, 2.2199e-17, -7.15515e-05, 3.1103e-06}, - {0.9986, -0.000482243, -2.4897e-05, -1.3309e-06}, - {0.9954, -0.00083103, -4.48605e-05, -9.86701e-07}, - {0.99, -0.00135364, -5.9661e-05, 3.6777e-06}, - {0.9822, -0.00167442, -4.49547e-06, -5.72411e-06}, - {0.973, -0.00214868, -9.03571e-05, 1.8736e-08}, - {0.96, -0.00305085, -9.00761e-05, 1.64917e-06}, - {0.9427, -0.00382792, -6.53386e-05, -2.6154e-06}, - {0.9216, -0.00467746, -0.00010457, 4.81243e-06}, - {0.8962, -0.00536223, -3.23831e-05, -5.43432e-06}, - {0.8679, -0.00609363, -0.000113898, 3.32484e-06}, - {0.835, -0.00698325, -6.40253e-05, 9.34959e-07}, - {0.7986, -0.00755338, -5.00009e-05, 9.35324e-07}, - {0.7597, -0.00798324, -3.5971e-05, -2.27626e-06}, - {0.7186, -0.00851367, -7.01149e-05, -8.6303e-06}, - {0.6732, -0.00986209, -0.000199569, 1.91974e-05}, - {0.6213, -0.010418, 8.83923e-05, 6.24051e-06}, - {0.5722, -0.00906601, 0.000182, 6.24051e-06}, - {0.5322, -0.00677797, 0.000275608, 6.24051e-06} + {1.0f, 2.2199e-17f, -7.15515e-05f, 3.1103e-06f}, + {0.9986f, -0.000482243f, -2.4897e-05f, -1.3309e-06f}, + {0.9954f, -0.00083103f, -4.48605e-05f, -9.86701e-07f}, + {0.99f, -0.00135364f, -5.9661e-05f, 3.6777e-06f}, + {0.9822f, -0.00167442f, -4.49547e-06f, -5.72411e-06f}, + {0.973f, -0.00214868f, -9.03571e-05f, 1.8736e-08f}, + {0.96f, -0.00305085f, -9.00761e-05f, 1.64917e-06f}, + {0.9427f, -0.00382792f, -6.53386e-05f, -2.6154e-06f}, + {0.9216f, -0.00467746f, -0.00010457f, 4.81243e-06f}, + {0.8962f, -0.00536223f, -3.23831e-05f, -5.43432e-06f}, + {0.8679f, -0.00609363f, -0.000113898f, 3.32484e-06f}, + {0.835f, -0.00698325f, -6.40253e-05f, 9.34959e-07f}, + {0.7986f, -0.00755338f, -5.00009e-05f, 9.35324e-07f}, + {0.7597f, -0.00798324f, -3.5971e-05f, -2.27626e-06f}, + {0.7186f, -0.00851367f, -7.01149e-05f, -8.6303e-06f}, + {0.6732f, -0.00986209f, -0.000199569f, 1.91974e-05f}, + {0.6213f, -0.010418f, 8.83923e-05f, 6.24051e-06f}, + {0.5722f, -0.00906601f, 0.000182f, 6.24051e-06f}, + {0.5322f, -0.00677797f, 0.000275608f, 6.24051e-06f} }; static const struct COEFS Y[] = { - {-5.20417e-18, 0.0124, 1.21431e-18, -8.45284e-11}, - {0.062, 0.0124, -1.26793e-09, 4.22642e-10}, - {0.124, 0.0124, 5.07171e-09, -1.60604e-09}, - {0.186, 0.0123999, -1.90189e-08, 6.00152e-09}, - {0.248, 0.0124002, 7.10039e-08, -2.24e-08}, - {0.31, 0.0123992, -2.64997e-07, 8.35986e-08}, - {0.372, 0.0124029, 9.88983e-07, -3.11994e-07}, - {0.434, 0.0123893, -3.69093e-06, -4.35621e-07}, - {0.4958, 0.0123198, -1.02252e-05, -3.45523e-07}, - {0.5571, 0.0121916, -1.54081e-05, -5.82288e-07}, - {0.6176, 0.0119938, -2.41424e-05, -5.25327e-07}, - {0.6769, 0.011713, -3.20223e-05, -5.16405e-07}, - {0.7346, 0.0113541, -3.97684e-05, -6.09052e-07}, - {0.7903, 0.0109107, -4.89042e-05, -1.04739e-06}, - {0.8435, 0.0103431, -6.4615e-05, -1.40374e-09}, - {0.8936, 0.00969686, -6.4636e-05, -8.547e-06}, - {0.9394, 0.00840947, -0.000192841, -4.2106e-06}, - {0.9761, 0.00616527, -0.000256, -4.2106e-06}, - {1, 0.00328947, -0.000319159, -4.2106e-06} + {-5.20417e-18f, 0.0124f, 1.21431e-18f, -8.45284e-11f}, + {0.062f, 0.0124f, -1.26793e-09f, 4.22642e-10f}, + {0.124f, 0.0124f, 5.07171e-09f, -1.60604e-09f}, + {0.186f, 0.0123999f, -1.90189e-08f, 6.00152e-09f}, + {0.248f, 0.0124002f, 7.10039e-08f, -2.24e-08f}, + {0.31f, 0.0123992f, -2.64997e-07f, 8.35986e-08f}, + {0.372f, 0.0124029f, 9.88983e-07f, -3.11994e-07f}, + {0.434f, 0.0123893f, -3.69093e-06f, -4.35621e-07f}, + {0.4958f, 0.0123198f, -1.02252e-05f, -3.45523e-07f}, + {0.5571f, 0.0121916f, -1.54081e-05f, -5.82288e-07f}, + {0.6176f, 0.0119938f, -2.41424e-05f, -5.25327e-07f}, + {0.6769f, 0.011713f, -3.20223e-05f, -5.16405e-07f}, + {0.7346f, 0.0113541f, -3.97684e-05f, -6.09052e-07f}, + {0.7903f, 0.0109107f, -4.89042e-05f, -1.04739e-06f}, + {0.8435f, 0.0103431f, -6.4615e-05f, -1.40374e-09f}, + {0.8936f, 0.00969686f, -6.4636e-05f, -8.547e-06f}, + {0.9394f, 0.00840947f, -0.000192841f, -4.2106e-06f}, + {0.9761f, 0.00616527f, -0.000256f, -4.2106e-06f}, + {1.0f, 0.00328947f, -0.000319159f, -4.2106e-06f} }; #define FXC 0.8487 @@ -78,7 +78,7 @@ static XY s_forward (LP lp, PJ *P) { /* Spheroidal, forward */ double dphi; (void) P; - i = floor((dphi = fabs(lp.phi)) * C1); + i = (int)floor((dphi = fabs(lp.phi)) * C1); if( i < 0 ) F_ERROR; if (i >= NODES) i = NODES - 1; @@ -107,7 +107,7 @@ static LP s_inverse (XY xy, PJ *P) { /* Spheroidal, inverse */ } } else { /* general problem */ /* in Y space, reduce to table interval */ - i = floor(lp.phi * NODES); + i = (int)floor(lp.phi * NODES); if( i < 0 || i >= NODES ) I_ERROR; for (;;) { @@ -119,7 +119,7 @@ static LP s_inverse (XY xy, PJ *P) { /* Spheroidal, inverse */ /* first guess, linear interp */ t = 5. * (lp.phi - T.c0)/(Y[i+1].c0 - T.c0); /* make into root */ - T.c0 -= lp.phi; + T.c0 = (float)(T.c0 - lp.phi); for (;;) { /* Newton-Raphson reduction */ t -= t1 = V(T,t) / DV(T,t); if (fabs(t1) < EPS) diff --git a/src/cs2cs.c b/src/cs2cs.c index 83e2d3f06c..ac72b0a07c 100644 --- a/src/cs2cs.c +++ b/src/cs2cs.c @@ -166,7 +166,7 @@ int main(int argc, char **argv) { char *arg, **eargv = argv, *from_argv[MAX_PARGS], *to_argv[MAX_PARGS]; FILE *fid; - int from_argc=0, to_argc=0, eargc = 0, c, mon = 0; + int from_argc=0, to_argc=0, eargc = 0, mon = 0; int have_to_flag = 0, inverse = 0, i; int use_env_locale = 0; @@ -271,12 +271,15 @@ int main(int argc, char **argv) continue; case 'W': /* specify seconds precision */ case 'w': /* -W for constant field width */ - if ((c = arg[1]) != 0 && isdigit(c)) { + { + char c = arg[1]; + if (c != 0 && isdigit(c)) { set_rtodms(c - '0', *arg == 'W'); ++arg; } else emess(1,"-W argument missing or non-digit"); continue; + } case 'f': /* alternate output format degrees or xy */ if (--argc <= 0) goto noargument; oform = *++argv; @@ -331,8 +334,6 @@ int main(int argc, char **argv) for( i = 0; i < MAX_PARGS; i++ ) { - char *arg; - arg = from_argv[i]; from_argv[i] = to_argv[i]; to_argv[i] = arg; diff --git a/src/emess.h b/src/emess.h index b8203246a4..b694d61ea1 100644 --- a/src/emess.h +++ b/src/emess.h @@ -21,8 +21,9 @@ extern char *sys_errlist[]; #else /* for for calling procedures */ extern struct EMESS emess_dat; -void emess(int, char *, ...); #endif /* use type */ +void emess(int, char *, ...); + #endif /* end EMESS_H */ diff --git a/src/gen_cheb.c b/src/gen_cheb.c index b7c41d822a..6422afc90f 100644 --- a/src/gen_cheb.c +++ b/src/gen_cheb.c @@ -8,8 +8,13 @@ #ifndef COEF_LINE_MAX #define COEF_LINE_MAX 60 #endif - void -gen_cheb(int inverse, projUV (*proj)(projUV), char *s, PJ *P, int iargc, char **iargv) { + +/* FIXME: put the declaration in a header. Also used in proj.c */ +void gen_cheb(int inverse, projUV (*proj)(projUV), char *s, PJ *P, + int iargc, char **iargv); + +void gen_cheb(int inverse, projUV (*proj)(projUV), char *s, PJ *P, + int iargc, char **iargv) { int NU = 15, NV = 15, res = -1, errin = 0, pwr; char *arg, fmt[15]; projUV low, upp, resid; diff --git a/src/nad2bin.c b/src/nad2bin.c index 59ec165825..859134e6c1 100644 --- a/src/nad2bin.c +++ b/src/nad2bin.c @@ -127,16 +127,16 @@ int main(int argc, char **argv) { fprintf(stderr,"format check on row\n"); exit(1); } - t.lam = laml * U_SEC_TO_RAD; - t.phi = phil * U_SEC_TO_RAD; + t.lam = (float) (laml * U_SEC_TO_RAD); + t.phi = (float) (phil * U_SEC_TO_RAD); *p++ = t; for (j = 1; j < ct.lim.lam; ++j) { if ( EOF == scanf("%ld %ld", &lam, &phi) ) { perror("scanf on column"); exit(1); } - t.lam = (laml += lam) * U_SEC_TO_RAD; - t.phi = (phil += phi) * U_SEC_TO_RAD; + t.lam = (float) ((laml += lam) * U_SEC_TO_RAD); + t.phi = (float) ((phil += phi) * U_SEC_TO_RAD); *p++ = t; } } @@ -342,16 +342,14 @@ int main(int argc, char **argv) { for( row = 0; row < ct.lim.phi; row++ ) { - int i; - for( i = 0; i < ct.lim.lam; i++ ) { FLP *cvs = ct.cvs + (row) * ct.lim.lam + (ct.lim.lam - i - 1); /* convert radians to seconds */ - row_buf[i*4+0] = cvs->phi * (3600.0 / (M_PI/180.0)); - row_buf[i*4+1] = cvs->lam * (3600.0 / (M_PI/180.0)); + row_buf[i*4+0] = (float) (cvs->phi * (3600.0 / (M_PI/180.0))); + row_buf[i*4+1] = (float) (cvs->lam * (3600.0 / (M_PI/180.0))); /* We leave the accuracy values as zero */ } diff --git a/src/nad_intr.c b/src/nad_intr.c index 299f1806b3..37b628b5c2 100644 --- a/src/nad_intr.c +++ b/src/nad_intr.c @@ -10,8 +10,8 @@ nad_intr(LP t, struct CTABLE *ct) { long index; int in; - indx.lam = floor(t.lam /= ct->del.lam); - indx.phi = floor(t.phi /= ct->del.phi); + indx.lam = (int)floor(t.lam /= ct->del.lam); + indx.phi = (int)floor(t.phi /= ct->del.phi); frct.lam = t.lam - indx.lam; frct.phi = t.phi - indx.phi; val.lam = val.phi = HUGE_VAL; diff --git a/src/p_series.c b/src/p_series.c index 7499ab49f0..cddea888cf 100644 --- a/src/p_series.c +++ b/src/p_series.c @@ -4,8 +4,11 @@ #include #define NF 20 /* length of final format string */ #define CUT 60 /* check length of line */ - void -p_series(Tseries *T, FILE *file, char *fmt) { + +/* FIXME: put the declaration in a header. Also used in gen_cheb.c */ +void p_series(Tseries *T, FILE *file, char *fmt); + +void p_series(Tseries *T, FILE *file, char *fmt) { int i, j, n, L; char format[NF+1]; diff --git a/src/pj_apply_gridshift.c b/src/pj_apply_gridshift.c index 40fe7cdcaa..91e2de26be 100644 --- a/src/pj_apply_gridshift.c +++ b/src/pj_apply_gridshift.c @@ -162,7 +162,7 @@ int pj_apply_gridshift_3( projCtx ctx, PJ_GRIDINFO **tables, int grid_count, for( child = gi->child; child != NULL; child = child->next ) { struct CTABLE *ct1 = child->ct; - double epsilon = + epsilon = (fabs(ct1->del.phi)+fabs(ct1->del.lam))/10000.0; if( ct1->ll.phi - epsilon > input.phi diff --git a/src/pj_fileapi.c b/src/pj_fileapi.c index fa35f30acb..1e5bfa51e4 100644 --- a/src/pj_fileapi.c +++ b/src/pj_fileapi.c @@ -54,7 +54,7 @@ typedef struct { /* pj_get_default_fileapi() */ /************************************************************************/ -projFileAPI *pj_get_default_fileapi() +projFileAPI *pj_get_default_fileapi(void) { return &default_fileapi; } diff --git a/src/pj_gridinfo.c b/src/pj_gridinfo.c index 5f528de148..d54aadceb8 100644 --- a/src/pj_gridinfo.c +++ b/src/pj_gridinfo.c @@ -244,8 +244,8 @@ int pj_gridinfo_load( projCtx ctx, PJ_GRIDINFO *gi ) cvs = ct_tmp.cvs + (row) * gi->ct->lim.lam + (gi->ct->lim.lam - i - 1); - cvs->phi = *(diff_seconds++) * ((M_PI/180.0) / 3600.0); - cvs->lam = *(diff_seconds++) * ((M_PI/180.0) / 3600.0); + cvs->phi = (float) (*(diff_seconds++) * ((M_PI/180.0) / 3600.0)); + cvs->lam = (float) (*(diff_seconds++) * ((M_PI/180.0) / 3600.0)); } } @@ -324,8 +324,8 @@ int pj_gridinfo_load( projCtx ctx, PJ_GRIDINFO *gi ) cvs = ct_tmp.cvs + (row) * gi->ct->lim.lam + (gi->ct->lim.lam - i - 1); - cvs->phi = *(diff_seconds++) * ((M_PI/180.0) / 3600.0); - cvs->lam = *(diff_seconds++) * ((M_PI/180.0) / 3600.0); + cvs->phi = (float) (*(diff_seconds++) * ((M_PI/180.0) / 3600.0)); + cvs->lam = (float) (*(diff_seconds++) * ((M_PI/180.0) / 3600.0)); diff_seconds += 2; /* skip accuracy values */ } } diff --git a/src/pj_log.c b/src/pj_log.c index 0c711e52ba..5b59e7a50d 100644 --- a/src/pj_log.c +++ b/src/pj_log.c @@ -25,6 +25,7 @@ * DEALINGS IN THE SOFTWARE. *****************************************************************************/ +#include "proj.h" #include #include #include diff --git a/src/pj_malloc.c b/src/pj_malloc.c index b9d8f825be..9dd4e40563 100644 --- a/src/pj_malloc.c +++ b/src/pj_malloc.c @@ -115,7 +115,7 @@ pointer" to signal an error in a multi level allocation: /*****************************************************************************/ -void *pj_freeup_msg_plain (PJ *P, int errlev) { /* Destructor */ +static void *pj_freeup_msg_plain (PJ *P, int errlev) { /* Destructor */ /***************************************************************************** Does memory deallocation for "plain" PJ objects, i.e. that vast majority of PJs where the opaque object does not contain any additionally diff --git a/src/pj_obs_api.c b/src/pj_obs_api.c index 4a6e98a5f6..37e55bc341 100644 --- a/src/pj_obs_api.c +++ b/src/pj_obs_api.c @@ -71,13 +71,13 @@ double pj_xyz_dist (XYZ a, XYZ b) { /* Work around non-constness of MSVC HUGE_VAL by providing functions rather than constants */ -PJ_COORD pj_coo_error (void) { +static PJ_COORD pj_coo_error (void) { PJ_COORD c; c.v[0] = c.v[1] = c.v[2] = c.v[3] = HUGE_VAL; return c; } -PJ_OBS pj_obs_error (void) { +static PJ_OBS pj_obs_error (void) { PJ_OBS obs; obs.coo = pj_coo_error (); obs.anc.v[0] = obs.anc.v[1] = obs.anc.v[2] = HUGE_VAL; @@ -87,7 +87,7 @@ PJ_OBS pj_obs_error (void) { -PJ_OBS pj_fwdobs (PJ_OBS obs, PJ *P) { +static PJ_OBS pj_fwdobs (PJ_OBS obs, PJ *P) { if (0!=P->fwdobs) { obs = P->fwdobs (obs, P); return obs; @@ -105,7 +105,7 @@ PJ_OBS pj_fwdobs (PJ_OBS obs, PJ *P) { } -PJ_OBS pj_invobs (PJ_OBS obs, PJ *P) { +static PJ_OBS pj_invobs (PJ_OBS obs, PJ *P) { if (0!=P->invobs) { obs = P->invobs (obs, P); return obs; diff --git a/src/pj_transform.c b/src/pj_transform.c index 26a22ab96c..86e0e70fd4 100644 --- a/src/pj_transform.c +++ b/src/pj_transform.c @@ -85,7 +85,6 @@ int pj_transform( PJ *srcdefn, PJ *dstdefn, long point_count, int point_offset, { long i; - int err; srcdefn->ctx->last_errno = 0; dstdefn->ctx->last_errno = 0; @@ -121,6 +120,7 @@ int pj_transform( PJ *srcdefn, PJ *dstdefn, long point_count, int point_offset, /* -------------------------------------------------------------------- */ if( srcdefn->is_geocent ) { + int err; if( z == NULL ) { pj_ctx_set_errno( pj_get_ctx(srcdefn), PJD_ERR_GEOCENTRIC); @@ -588,6 +588,7 @@ int pj_compare_datums( PJ *srcdefn, PJ *dstdefn ) /* pj_geocentic_to_wgs84() */ /************************************************************************/ +static int pj_geocentric_to_wgs84( PJ *defn, long point_count, int point_offset, double *x, double *y, double *z ) @@ -636,6 +637,7 @@ int pj_geocentric_to_wgs84( PJ *defn, /* pj_geocentic_from_wgs84() */ /************************************************************************/ +static int pj_geocentric_from_wgs84( PJ *defn, long point_count, int point_offset, double *x, double *y, double *z ) diff --git a/src/proj.c b/src/proj.c index 2a6cc6ef4d..10eb0f8d5e 100644 --- a/src/proj.c +++ b/src/proj.c @@ -247,7 +247,7 @@ vprocess(FILE *fid) { int main(int argc, char **argv) { char *arg, **eargv = argv, *pargv[MAX_PARGS], **iargv = argv; FILE *fid; - int pargc = 0, iargc = argc, eargc = 0, c, mon = 0; + int pargc = 0, iargc = argc, eargc = 0, mon = 0; if ( (emess_dat.Prog_name = strrchr(*argv,DIR_CHAR)) != NULL) ++emess_dat.Prog_name; @@ -381,12 +381,15 @@ int main(int argc, char **argv) { continue; case 'W': /* specify seconds precision */ case 'w': /* -W for constant field width */ - if ((c = arg[1]) != 0 && isdigit(c)) { + { + int c = arg[1]; + if (c != 0 && isdigit(c)) { set_rtodms(c - '0', *arg == 'W'); ++arg; } else emess(1,"-W argument missing or non-digit"); continue; + } case 'f': /* alternate output format degrees or xy */ if (--argc <= 0) goto noargument; oform = *++argv; diff --git a/src/proj_api.h b/src/proj_api.h index 863795f0ea..033c1282ca 100644 --- a/src/proj_api.h +++ b/src/proj_api.h @@ -192,7 +192,7 @@ void pj_log( projCtx ctx, int level, const char *fmt, ... ); void pj_stderr_logger( void *, int, const char * ); /* file api */ -projFileAPI *pj_get_default_fileapi(); +projFileAPI *pj_get_default_fileapi(void); PAFile pj_ctx_fopen(projCtx ctx, const char *filename, const char *access); size_t pj_ctx_fread(projCtx ctx, void *buffer, size_t size, size_t nmemb, PAFile file); diff --git a/src/projects.h b/src/projects.h index 33af9ca70a..be10268c52 100644 --- a/src/projects.h +++ b/src/projects.h @@ -512,6 +512,8 @@ extern struct PJ_PRIME_MERIDIANS pj_prime_meridians[]; #define PROJECTION(name) \ pj_projection_specific_setup_##name (PJ *P); \ C_NAMESPACE_VAR const char * const pj_s_##name = des_##name; \ +C_NAMESPACE PJ *pj_##name (PJ *P); \ +int pj_ ## name ## _selftest (void); \ C_NAMESPACE PJ *pj_##name (PJ *P) { \ if (P) \ return pj_projection_specific_setup_##name (P); \ diff --git a/src/rtodms.c b/src/rtodms.c index fa5c3cd104..5e88ca1476 100644 --- a/src/rtodms.c +++ b/src/rtodms.c @@ -49,9 +49,9 @@ rtodms(char *s, double r, int pos, int neg) { r = floor(r * CONV + .5); sec = fmod(r / RES, 60.); r = floor(r / RES60); - min = fmod(r, 60.); - r = floor(r / 60.); - deg = r; + min = (int)fmod(r, 60.); + r = floor(r / 60.); + deg = (int)r; if (dolong) (void)sprintf(ss,format,deg,min,sec,sign); From 01193fff75d838449ce201673ccaaec9c33e63ca Mon Sep 17 00:00:00 2001 From: Even Rouault Date: Sun, 26 Feb 2017 00:44:29 +0100 Subject: [PATCH 02/12] proj.def: remove symbols no longer public. See https://ci.appveyor.com/project/OSGeo/proj-4/build/1.0.513/job/chsb12mrfkpbkbqj --- src/proj.def | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/proj.def b/src/proj.def index b01b846c2c..0a68827675 100644 --- a/src/proj.def +++ b/src/proj.def @@ -92,8 +92,6 @@ EXPORTS pj_create @90 pj_create_argv @91 pj_trans @92 - pj_fwdobs @93 - pj_invobs @94 pj_roundtrip @95 pj_log_level @96 pj_err_level @97 @@ -108,5 +106,3 @@ EXPORTS pj_lp_dist @106 pj_xy_dist @107 pj_xyz_dist @108 - pj_coo_error @109 - pj_obs_error @110 From b711758edb40af70630d1df8000eab592a295542 Mon Sep 17 00:00:00 2001 From: Even Rouault Date: Sun, 26 Feb 2017 11:27:50 +0100 Subject: [PATCH 03/12] travis/install.sh: use super pedantic warning flags for autoconf build --- travis/install.sh | 1 + travis/linux_clang/install.sh | 2 +- travis/linux_gcc/install.sh | 3 ++- travis/osx/install.sh | 2 +- 4 files changed, 5 insertions(+), 3 deletions(-) diff --git a/travis/install.sh b/travis/install.sh index 1728045153..41f9fcb67c 100755 --- a/travis/install.sh +++ b/travis/install.sh @@ -88,6 +88,7 @@ mkdir share ln -s nad share/proj pwd # install pyproj +export CFLAGS= PROJ_DIR=`pwd` pip3 install -v --user pyproj cd test/gigs diff --git a/travis/linux_clang/install.sh b/travis/linux_clang/install.sh index fad21a16f3..56e16ce624 100755 --- a/travis/linux_clang/install.sh +++ b/travis/linux_clang/install.sh @@ -4,4 +4,4 @@ set -e export CCACHE_CPP2=yes -CC="ccache clang" ./travis/install.sh +CC="ccache clang" CFLAGS="-g -Wall -Wextra -Werror -Wunused-parameter -Wmissing-prototypes -Wmissing-declarations -Wformat -Werror=format-security -Wshadow -Wfloat-conversion -O2" ./travis/install.sh diff --git a/travis/linux_gcc/install.sh b/travis/linux_gcc/install.sh index f5e12dbd96..571e02b7b4 100755 --- a/travis/linux_gcc/install.sh +++ b/travis/linux_gcc/install.sh @@ -4,4 +4,5 @@ set -e export CCACHE_CPP2=yes -CC="ccache gcc" ./travis/install.sh +# -Wfloat-conversion not available for gcc 4.8 +CC="ccache gcc" CFLAGS="-g -Wall -Wextra -Werror -Wunused-parameter -Wmissing-prototypes -Wmissing-declarations -Wformat -Werror=format-security -Wshadow -O2" ./travis/install.sh diff --git a/travis/osx/install.sh b/travis/osx/install.sh index fad21a16f3..56e16ce624 100755 --- a/travis/osx/install.sh +++ b/travis/osx/install.sh @@ -4,4 +4,4 @@ set -e export CCACHE_CPP2=yes -CC="ccache clang" ./travis/install.sh +CC="ccache clang" CFLAGS="-g -Wall -Wextra -Werror -Wunused-parameter -Wmissing-prototypes -Wmissing-declarations -Wformat -Werror=format-security -Wshadow -Wfloat-conversion -O2" ./travis/install.sh From 0dd7f86fc4e4ed7cbc1d54c02cfffdf4b449b5cd Mon Sep 17 00:00:00 2001 From: Even Rouault Date: Sun, 26 Feb 2017 11:46:45 +0100 Subject: [PATCH 04/12] configure.ac: remove -Werror from CFLAGS when detecting exp symbol in libm --- configure.ac | 3 +++ 1 file changed, 3 insertions(+) diff --git a/configure.ac b/configure.ac index 7c77490e1a..68df28ecef 100644 --- a/configure.ac +++ b/configure.ac @@ -21,7 +21,10 @@ AC_PROG_MAKE_SET AM_PROG_LIBTOOL dnl Checks for libraries. +save_CFLAGS="$CFLAGS" +CFLAGS=`echo "$CFLAGS" | sed "s/-Werror/ /"` AC_CHECK_LIB(m,exp,,,) +CFLAGS="$save_CFLAGS" dnl We check for headers AC_HEADER_STDC From 4aa7a999cb0aa490781c721fa031a2fbbe906c48 Mon Sep 17 00:00:00 2001 From: Even Rouault Date: Sun, 26 Feb 2017 12:04:33 +0100 Subject: [PATCH 05/12] Fix warnings in geodtest.c --- src/geodtest.c | 70 +++++++++++++++++++++++++------------------------- 1 file changed, 35 insertions(+), 35 deletions(-) diff --git a/src/geodtest.c b/src/geodtest.c index c94683f69d..5fd00cb830 100644 --- a/src/geodtest.c +++ b/src/geodtest.c @@ -22,7 +22,7 @@ double wgs84_a = 6378137, wgs84_f = 1/298.257223563; /* WGS84 */ -int assertEquals(double x, double y, double d) { +static int assertEquals(double x, double y, double d) { if (fabs(x - y) <= d) return 0; printf("assertEquals fails: %.7g != %.7g +/- %.7g\n", x, y, d); @@ -112,7 +112,7 @@ double testcases[20][12] = { 13487015.8381145492, 121.294026715742277, 5481428.9945736388, -0.51527225545373252, -0.51556587964721788, 104679964020340.318}}; -int testinverse() { +static int testinverse() { double lat1, lon1, azi1, lat2, lon2, azi2, s12, a12, m12, M12, M21, S12; double azi1a, azi2a, s12a, a12a, m12a, M12a, M21a, S12a; struct geod_geodesic g; @@ -137,7 +137,7 @@ int testinverse() { return result; } -int testdirect() { +static int testdirect() { double lat1, lon1, azi1, lat2, lon2, azi2, s12, a12, m12, M12, M21, S12; double lat2a, lon2a, azi2a, a12a, m12a, M12a, M21a, S12a; struct geod_geodesic g; @@ -164,7 +164,7 @@ int testdirect() { return result; } -int testarcdirect() { +static int testarcdirect() { double lat1, lon1, azi1, lat2, lon2, azi2, s12, a12, m12, M12, M21, S12; double lat2a, lon2a, azi2a, s12a, m12a, M12a, M21a, S12a; struct geod_geodesic g; @@ -190,7 +190,7 @@ int testarcdirect() { return result; } -int GeodSolve0() { +static int GeodSolve0() { double azi1, azi2, s12; struct geod_geodesic g; int result = 0; @@ -202,7 +202,7 @@ int GeodSolve0() { return result; } -int GeodSolve1() { +static int GeodSolve1() { double lat2, lon2, azi2; struct geod_geodesic g; int result = 0; @@ -215,7 +215,7 @@ int GeodSolve1() { return result; } -int GeodSolve2() { +static int GeodSolve2() { /* Check fix for antipodal prolate bug found 2010-09-04 */ double azi1, azi2, s12; struct geod_geodesic g; @@ -232,7 +232,7 @@ int GeodSolve2() { return result; } -int GeodSolve4() { +static int GeodSolve4() { /* Check fix for short line bug found 2010-05-21 */ double s12; struct geod_geodesic g; @@ -244,7 +244,7 @@ int GeodSolve4() { return result; } -int GeodSolve5() { +static int GeodSolve5() { /* Check fix for point2=pole bug found 2010-05-03 */ double lat2, lon2, azi2; struct geod_geodesic g; @@ -262,7 +262,7 @@ int GeodSolve5() { return result; } -int GeodSolve6() { +static int GeodSolve6() { /* Check fix for volatile sbet12a bug found 2011-06-25 (gcc 4.4.4 * x86 -O3). Found again on 2012-03-27 with tdm-mingw32 (g++ 4.6.1). */ double s12; @@ -281,7 +281,7 @@ int GeodSolve6() { return result; } -int GeodSolve9() { +static int GeodSolve9() { /* Check fix for volatile x bug found 2011-06-25 (gcc 4.4.4 x86 -O3) */ double s12; struct geod_geodesic g; @@ -293,7 +293,7 @@ int GeodSolve9() { return result; } -int GeodSolve10() { +static int GeodSolve10() { /* Check fix for adjust tol1_ bug found 2011-06-25 (Visual Studio * 10 rel + debug) */ double s12; @@ -306,7 +306,7 @@ int GeodSolve10() { return result; } -int GeodSolve11() { +static int GeodSolve11() { /* Check fix for bet2 = -bet1 bug found 2011-06-25 (Visual Studio * 10 rel + debug) */ double s12; @@ -319,7 +319,7 @@ int GeodSolve11() { return result; } -int GeodSolve12() { +static int GeodSolve12() { /* Check fix for inverse geodesics on extreme prolate/oblate * ellipsoids Reported 2012-08-29 Stefan Guenther * ; fixed 2012-10-07 */ @@ -334,7 +334,7 @@ int GeodSolve12() { return result; } -int GeodSolve14() { +static int GeodSolve14() { /* Check fix for inverse ignoring lon12 = nan */ double azi1, azi2, s12, nan = sqrt(-1.0); struct geod_geodesic g; @@ -347,7 +347,7 @@ int GeodSolve14() { return result; } -int GeodSolve15() { +static int GeodSolve15() { /* Initial implementation of Math::eatanhe was wrong for e^2 < 0. This * checks that this is fixed. */ double S12; @@ -360,7 +360,7 @@ int GeodSolve15() { return result; } -int GeodSolve17() { +static int GeodSolve17() { /* Check fix for LONG_UNROLL bug found on 2015-05-07 */ double lat2, lon2, azi2; struct geod_geodesic g; @@ -389,7 +389,7 @@ int GeodSolve17() { return result; } -int GeodSolve26() { +static int GeodSolve26() { /* Check 0/0 problem with area calculation on sphere 2015-09-08 */ double S12; struct geod_geodesic g; @@ -400,7 +400,7 @@ int GeodSolve26() { return result; } -int GeodSolve28() { +static int GeodSolve28() { /* Check for bad placement of assignment of r.a12 with |f| > 0.01 (bug in * Java implementation fixed on 2015-05-19). */ double a12; @@ -412,7 +412,7 @@ int GeodSolve28() { return result; } -int GeodSolve33() { +static int GeodSolve33() { /* Check max(-0.0,+0.0) issues 2015-08-22 (triggered by bugs in Octave -- * sind(-0.0) = +0.0 -- and in some version of Visual Studio -- * fmod(-0.0, 360.0) = +0.0. */ @@ -470,7 +470,7 @@ int GeodSolve33() { return result; } -int GeodSolve55() { +static int GeodSolve55() { /* Check fix for nan + point on equator or pole not returning all nans in * Geodesic::Inverse, found 2015-09-23. */ double azi1, azi2, s12, nan = sqrt(-1.0); @@ -488,7 +488,7 @@ int GeodSolve55() { return result; } -int GeodSolve59() { +static int GeodSolve59() { /* Check for points close with longitudes close to 180 deg apart. */ double azi1, azi2, s12; struct geod_geodesic g; @@ -501,7 +501,7 @@ int GeodSolve59() { return result; } -int GeodSolve61() { +static int GeodSolve61() { /* Make sure small negative azimuths are west-going */ double lat2, lon2, azi2; struct geod_geodesic g; @@ -522,7 +522,7 @@ int GeodSolve61() { return result; } -int GeodSolve65() { +static int GeodSolve65() { /* Check for bug in east-going check in GeodesicLine (needed to check for * sign of 0) and sign error in area calculation due to a bogus override of * the code for alp12. Found/fixed on 2015-12-19. */ @@ -558,7 +558,7 @@ int GeodSolve65() { return result; } -int GeodSolve67() { +static int GeodSolve67() { /* Check for InverseLine if line is slightly west of S and that s13 is correctly set. */ double lat2, lon2, azi2; @@ -579,7 +579,7 @@ int GeodSolve67() { return result; } -int GeodSolve71() { +static int GeodSolve71() { /* Check that DirectLine sets s13. */ double lat2, lon2, azi2; struct geod_geodesic g; @@ -594,7 +594,7 @@ int GeodSolve71() { return result; } -int GeodSolve73() { +static int GeodSolve73() { /* Check for backwards from the pole bug reported by Anon on 2016-02-13. * This only affected the Java implementation. It was introduced in Java * version 1.44 and fixed in 1.46-SNAPSHOT on 2016-01-17. */ @@ -610,7 +610,7 @@ int GeodSolve73() { return result; } -void planimeter(const struct geod_geodesic* g, double points[][2], int N, +static void planimeter(const struct geod_geodesic* g, double points[][2], int N, double* perimeter, double* area) { struct geod_polygon p; int i; @@ -620,7 +620,7 @@ void planimeter(const struct geod_geodesic* g, double points[][2], int N, geod_polygon_compute(g, &p, 0, 1, area, perimeter); } -void polylength(const struct geod_geodesic* g, double points[][2], int N, +static void polylength(const struct geod_geodesic* g, double points[][2], int N, double* perimeter) { struct geod_polygon p; int i; @@ -630,7 +630,7 @@ void polylength(const struct geod_geodesic* g, double points[][2], int N, geod_polygon_compute(g, &p, 0, 1, 0, perimeter); } -int GeodSolve74() { +static int GeodSolve74() { /* Check fix for inaccurate areas, bug introduced in v1.46, fixed 2015-10-16. */ double a12, s12, azi1, azi2, m12, M12, M21, S12; @@ -650,7 +650,7 @@ int GeodSolve74() { return result; } -int Planimeter0() { +static int Planimeter0() { /* Check fix for pole-encircling bug found 2011-03-16 */ double pa[4][2] = {{89, 0}, {89, 90}, {89, 180}, {89, 270}}; double pb[4][2] = {{-89, 0}, {-89, 90}, {-89, 180}, {-89, 270}}; @@ -683,7 +683,7 @@ int Planimeter0() { return result; } -int Planimeter5() { +static int Planimeter5() { /* Check fix for Planimeter pole crossing bug found 2011-06-24 */ double points[3][2] = {{89, 0.1}, {89, 90.1}, {89, -179.9}}; struct geod_geodesic g; @@ -696,7 +696,7 @@ int Planimeter5() { return result; } -int Planimeter6() { +static int Planimeter6() { /* Check fix for Planimeter lon12 rounding bug found 2012-12-03 */ double pa[3][2] = {{9, -0.00000000000001}, {9, 180}, {9, 0}}; double pb[3][2] = {{9, 0.00000000000001}, {9, 0}, {9, 180}}; @@ -722,7 +722,7 @@ int Planimeter6() { return result; } -int Planimeter12() { +static int Planimeter12() { /* Area of arctic circle (not really -- adjunct to rhumb-area test) */ double points[2][2] = {{66.562222222, 0}, {66.562222222, 180}}; struct geod_geodesic g; @@ -735,7 +735,7 @@ int Planimeter12() { return result; } -int Planimeter13() { +static int Planimeter13() { /* Check encircling pole twice */ double points[6][2] = {{89,-360}, {89,-240}, {89,-120}, {89,0}, {89,120}, {89,240}}; From d7f5a338a472abff69a61499276ed087ff5e8058 Mon Sep 17 00:00:00 2001 From: Even Rouault Date: Sun, 26 Feb 2017 12:06:36 +0100 Subject: [PATCH 06/12] Fix warnings related to -Werror=maybe-uninitialized --- src/PJ_imw_p.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/PJ_imw_p.c b/src/PJ_imw_p.c index b3ca185e23..5d37b16d5c 100644 --- a/src/PJ_imw_p.c +++ b/src/PJ_imw_p.c @@ -95,7 +95,7 @@ static LP e_inverse (XY xy, PJ *P) { /* Ellipsoidal, inverse */ LP lp = {0.0,0.0}; struct pj_opaque *Q = P->opaque; XY t; - double yc; + double yc = 0.0; lp.phi = Q->phi_2; lp.lam = xy.x / cos(lp.phi); From 3a647a4f7d64246327e2a9e6114762067068862f Mon Sep 17 00:00:00 2001 From: Even Rouault Date: Sun, 26 Feb 2017 12:15:40 +0100 Subject: [PATCH 07/12] multistresstest.c: warning fixes --- src/multistresstest.c | 49 ++++++++++++++++++++++++++++++++++++------- 1 file changed, 41 insertions(+), 8 deletions(-) diff --git a/src/multistresstest.c b/src/multistresstest.c index 8c5df18f14..8fb764e28e 100644 --- a/src/multistresstest.c +++ b/src/multistresstest.c @@ -59,83 +59,115 @@ TestItem test_list[] = { "+proj=utm +zone=11 +datum=WGS84", "+proj=latlong +datum=WGS84", 150000.0, 3000000.0, 0.0, + 0.0, 0.0, 0.0, + 0, 0 }, { "+proj=utm +zone=11 +datum=NAD83", "+proj=latlong +datum=NAD27", - 150000.0, 3000000.0, 0.0, + 150000.0, 3000000.0, 0.0, + 0.0, 0.0, 0.0, + 0, 0 }, { "+proj=utm +zone=11 +datum=NAD83", "+proj=latlong +nadgrids=@null +ellps=WGS84", 150000.0, 3000000.0, 0.0, + 0.0, 0.0, 0.0, + 0, 0 }, { "+proj=utm +zone=11 +datum=WGS84", "+proj=merc +datum=potsdam", 150000.0, 3000000.0, 0.0, + 0.0, 0.0, 0.0, + 0, 0 }, { "+proj=latlong +nadgrids=nzgd2kgrid0005.gsb", "+proj=latlong +datum=WGS84", 150000.0, 3000000.0, 0.0, + 0.0, 0.0, 0.0, + 0, 0 }, { "+proj=latlong +nadgrids=nzgd2kgrid0005.gsb", "+proj=latlong +datum=WGS84", 170 * DEG_TO_RAD, -40 * DEG_TO_RAD, 0.0, + 0.0, 0.0, 0.0, + 0, 0 }, { "+proj=latlong +ellps=GRS80 +towgs84=2,3,5", "+proj=latlong +ellps=intl +towgs84=10,12,15", 170 * DEG_TO_RAD, -40 * DEG_TO_RAD, 0.0, + 0.0, 0.0, 0.0, + 0, 0 }, { "+proj=eqc +lat_0=11 +lon_0=12 +x_0=100000 +y_0=200000 +datum=WGS84 ", "+proj=stere +lat_0=11 +lon_0=12 +x_0=100000 +y_0=200000 +datum=WGS84 ", 150000.0, 250000.0, 0.0, + 0.0, 0.0, 0.0, + 0, 0 }, { "+proj=cea +lat_ts=11 +lon_0=12 +y_0=200000 +datum=WGS84 ", "+proj=merc +lon_0=12 +k=0.999 +x_0=100000 +y_0=200000 +datum=WGS84 ", 150000.0, 250000.0, 0.0, + 0.0, 0.0, 0.0, + 0, 0 }, { "+proj=bonne +lat_1=11 +lon_0=12 +y_0=200000 +datum=WGS84 ", "+proj=cass +lat_0=11 +lon_0=12 +x_0=100000 +y_0=200000 +datum=WGS84 ", 150000.0, 250000.0, 0.0, + 0.0, 0.0, 0.0, + 0, 0 }, { "+proj=nzmg +lat_0=11 +lon_0=12 +y_0=200000 +datum=WGS84 ", "+proj=gnom +lat_0=11 +lon_0=12 +x_0=100000 +y_0=200000 +datum=WGS84 ", 150000.0, 250000.0, 0.0, + 0.0, 0.0, 0.0, + 0, 0 }, { "+proj=ortho +lat_0=11 +lon_0=12 +y_0=200000 +datum=WGS84 ", "+proj=laea +lat_0=11 +lon_0=12 +x_0=100000 +y_0=200000 +datum=WGS84 ", 150000.0, 250000.0, 0.0, + 0.0, 0.0, 0.0, + 0, 0 }, { "+proj=aeqd +lat_0=11 +lon_0=12 +y_0=200000 +datum=WGS84 ", "+proj=eqdc +lat_1=20 +lat_2=5 +lat_0=11 +lon_0=12 +x_0=100000 +y_0=200000 +datum=WGS84 ", 150000.0, 250000.0, 0.0, + 0.0, 0.0, 0.0, + 0, 0 }, { "+proj=mill +lat_0=11 +lon_0=12 +y_0=200000 +datum=WGS84 ", "+proj=moll +lon_0=12 +x_0=100000 +y_0=200000 +datum=WGS84 ", 150000.0, 250000.0, 0.0, + 0.0, 0.0, 0.0, + 0, 0 }, { "+init=epsg:3309", "+init=epsg:4326", 150000.0, 30000.0, 0.0, + 0.0, 0.0, 0.0, + 0, 0 }, - { - //Bad projection (invalid ellipsoid parameter +R_A=0) - "+proj=utm +zone=11 +datum=WGS84", - "+proj=merc +datum=potsdam +R_A=0", - 150000.0, 3000000.0, 0.0, - } + { + //Bad projection (invalid ellipsoid parameter +R_A=0) + "+proj=utm +zone=11 +datum=WGS84", + "+proj=merc +datum=potsdam +R_A=0", + 150000.0, 3000000.0, 0.0, + 0.0, 0.0, 0.0, + 0, 0 + } }; static volatile int active_thread_count = 0; @@ -297,6 +329,7 @@ static DWORD WINAPI WinTestThread( LPVOID lpParameter ) static void *PosixTestThread( void *pData ) { + (void)pData; TestThread(); return NULL; } @@ -308,7 +341,7 @@ static void *PosixTestThread( void *pData ) #ifdef _WIN32 static DWORD WINAPI do_main( LPVOID unused ) #else -int do_main(void) +static int do_main(void) #endif { /* -------------------------------------------------------------------- */ From 89b273a10a5ca97510d7bf2c6970c4c2ff5cd740 Mon Sep 17 00:00:00 2001 From: Even Rouault Date: Sun, 26 Feb 2017 12:22:38 +0100 Subject: [PATCH 08/12] test228.c: warning fixes --- src/test228.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/test228.c b/src/test228.c index a8e55c4ca5..483d8ea2c0 100644 --- a/src/test228.c +++ b/src/test228.c @@ -20,11 +20,12 @@ int main(int argc, char* argv[]) volatile int run = 0; volatile int started = 0; -void* thread_main(void* unused) +static void* thread_main(void* unused) { projCtx p_proj_ctxt; projPJ p_WGS84_proj; projPJ p_OSGB36_proj; + (void)unused; __sync_add_and_fetch(&started, 1); while(run == 0); @@ -59,9 +60,13 @@ void* thread_main(void* unused) int main(int argc, char* argv[]) { int i; + pthread_t tid1, tid2; pthread_attr_t attr1, attr2; + (void)argc; + (void)argv; + pthread_attr_init(&attr1); pthread_attr_init(&attr2); From 8eb46dbbb63d7a880ac787561c907491cffc0917 Mon Sep 17 00:00:00 2001 From: Even Rouault Date: Sun, 26 Feb 2017 12:05:24 +0100 Subject: [PATCH 09/12] Recent clang (e.g MacOSX) warning fixes related to double to _Bool implicit conversions --- src/PJ_aeqd.c | 2 +- src/PJ_aitoff.c | 4 ++-- src/PJ_bonne.c | 2 +- src/PJ_calcofi.c | 2 +- src/PJ_cea.c | 2 +- src/PJ_chamb.c | 4 ++-- src/PJ_fouc_s.c | 2 +- src/PJ_geos.c | 4 ++-- src/PJ_gn_sinu.c | 6 +++--- src/PJ_healpix.c | 4 ++-- src/PJ_imw_p.c | 8 +++++--- src/PJ_laea.c | 4 ++-- src/PJ_merc.c | 2 +- src/PJ_mod_ster.c | 6 +++--- src/PJ_poly.c | 2 +- src/PJ_qsc.c | 6 +++--- src/PJ_stere.c | 4 ++-- src/PJ_sterea.c | 2 +- src/PJ_tmerc.c | 4 ++-- src/geod_set.c | 2 +- src/mk_cheby.c | 4 ++-- src/pj_ell_set.c | 4 ++-- src/pj_factors.c | 4 ++-- src/pj_init.c | 8 ++++---- src/proj.c | 2 +- src/proj_etmerc.c | 2 +- src/rtodms.c | 2 +- 27 files changed, 50 insertions(+), 48 deletions(-) diff --git a/src/PJ_aeqd.c b/src/PJ_aeqd.c index 92b81748a3..b10bfd62cc 100644 --- a/src/PJ_aeqd.c +++ b/src/PJ_aeqd.c @@ -278,7 +278,7 @@ PJ *PROJECTION(aeqd) { Q->sinph0 = sin(P->phi0); Q->cosph0 = cos(P->phi0); } - if (! P->es) { + if (P->es == 0.0) { P->inv = s_inverse; P->fwd = s_forward; } else { diff --git a/src/PJ_aitoff.c b/src/PJ_aitoff.c index e85f639197..faab9aba44 100644 --- a/src/PJ_aitoff.c +++ b/src/PJ_aitoff.c @@ -53,7 +53,7 @@ static XY s_forward (LP lp, PJ *P) { /* Spheroidal, forward */ struct pj_opaque *Q = P->opaque; double c, d; - if((d = acos(cos(lp.phi) * cos(c = 0.5 * lp.lam)))) {/* basic Aitoff */ + if((d = acos(cos(lp.phi) * cos(c = 0.5 * lp.lam))) != 0.0) {/* basic Aitoff */ xy.x = 2. * d * cos(lp.phi) * sin(c) * (xy.y = 1. / sin(d)); xy.y *= d * sin(lp.phi); } else @@ -129,7 +129,7 @@ static LP s_inverse (XY xy, PJ *P) { /* Spheroidal, inverse */ if ((fabs(fabs(lp.phi) - M_PI_2) < EPSILON) && (!Q->mode)) lp.lam = 0.; /* if pole in Aitoff, return longitude of 0 */ /* calculate x,y coordinates with solution obtained */ - if((D = acos(cos(lp.phi) * cos(C = 0.5 * lp.lam)))) {/* Aitoff */ + if((D = acos(cos(lp.phi) * cos(C = 0.5 * lp.lam))) != 0.0) {/* Aitoff */ x = 2. * D * cos(lp.phi) * sin(C) * (y = 1. / sin(D)); y *= D * sin(lp.phi); } else diff --git a/src/PJ_bonne.c b/src/PJ_bonne.c index 47793ed63c..ca076f56dd 100644 --- a/src/PJ_bonne.c +++ b/src/PJ_bonne.c @@ -102,7 +102,7 @@ PJ *PROJECTION(bonne) { Q->phi1 = pj_param(P->ctx, P->params, "rlat_1").f; if (fabs(Q->phi1) < EPS10) E_ERROR(-23); - if (P->es) { + if (P->es != 0.0) { Q->en = pj_enfn(P->es); Q->m1 = pj_mlfn(Q->phi1, Q->am1 = sin(Q->phi1), c = cos(Q->phi1), Q->en); diff --git a/src/PJ_calcofi.c b/src/PJ_calcofi.c index 0f20615508..ebffd4f521 100644 --- a/src/PJ_calcofi.c +++ b/src/PJ_calcofi.c @@ -155,7 +155,7 @@ static void freeup (PJ *P) { PJ *PROJECTION(calcofi) { P->opaque = 0; - if (P->es) { /* ellipsoid */ + if (P->es != 0.0) { /* ellipsoid */ P->inv = e_inverse; P->fwd = e_forward; } else { /* sphere */ diff --git a/src/PJ_cea.c b/src/PJ_cea.c index eb6435ab7e..d6dcd47107 100644 --- a/src/PJ_cea.c +++ b/src/PJ_cea.c @@ -79,7 +79,7 @@ PJ *PROJECTION(cea) { E_ERROR(-24); } } - if (P->es) { + if (P->es != 0.0) { t = sin(t); P->k0 /= sqrt(1. - P->es * t * t); P->e = sqrt(P->es); diff --git a/src/PJ_chamb.c b/src/PJ_chamb.c index 6bacbbe97d..eb3ed479c0 100644 --- a/src/PJ_chamb.c +++ b/src/PJ_chamb.c @@ -59,7 +59,7 @@ static XY s_forward (LP lp, PJ *P) { /* Spheroidal, forward */ for (i = 0; i < 3; ++i) { /* dist/azimiths from control */ v[i] = vect(P->ctx, lp.phi - Q->c[i].phi, Q->c[i].cosphi, Q->c[i].sinphi, cosphi, sinphi, lp.lam - Q->c[i].lam); - if ( ! v[i].r) + if (v[i].r == 0.0) break; v[i].Az = adjlon(v[i].Az - Q->c[i].v.Az); } @@ -130,7 +130,7 @@ PJ *PROJECTION(chamb) { j = i == 2 ? 0 : i + 1; Q->c[i].v = vect(P->ctx,Q->c[j].phi - Q->c[i].phi, Q->c[i].cosphi, Q->c[i].sinphi, Q->c[j].cosphi, Q->c[j].sinphi, Q->c[j].lam - Q->c[i].lam); - if (! Q->c[i].v.r) E_ERROR(-25); + if (Q->c[i].v.r == 0.0) E_ERROR(-25); /* co-linearity problem ignored for now */ } Q->beta_0 = lc(P->ctx,Q->c[0].v.r, Q->c[2].v.r, Q->c[1].v.r); diff --git a/src/PJ_fouc_s.c b/src/PJ_fouc_s.c index 4392a6ec6e..f5df5d84bc 100644 --- a/src/PJ_fouc_s.c +++ b/src/PJ_fouc_s.c @@ -29,7 +29,7 @@ static LP s_inverse (XY xy, PJ *P) { /* Spheroidal, inverse */ double V; int i; - if (Q->n) { + if (Q->n != 0.0) { lp.phi = xy.y; for (i = MAX_ITER; i ; --i) { lp.phi -= V = (Q->n * lp.phi + Q->n1 * sin(lp.phi) - xy.y ) / diff --git a/src/PJ_geos.c b/src/PJ_geos.c index b7caacc390..56357c2b8d 100644 --- a/src/PJ_geos.c +++ b/src/PJ_geos.c @@ -204,7 +204,7 @@ PJ *PROJECTION(geos) { if ((Q->h = pj_param(P->ctx, P->params, "dh").f) <= 0.) E_ERROR(-30); - if (P->phi0) E_ERROR(-46); + if (P->phi0 != 0.0) E_ERROR(-46); Q->sweep_axis = pj_param(P->ctx, P->params, "ssweep").s; if (Q->sweep_axis == NULL) @@ -223,7 +223,7 @@ PJ *PROJECTION(geos) { Q->radius_g_1 = Q->h / P->a; Q->radius_g = 1. + Q->radius_g_1; Q->C = Q->radius_g * Q->radius_g - 1.0; - if (P->es) { + if (P->es != 0.0) { Q->radius_p = sqrt (P->one_es); Q->radius_p2 = P->one_es; Q->radius_p_inv2 = P->rone_es; diff --git a/src/PJ_gn_sinu.c b/src/PJ_gn_sinu.c index 5dad9787f8..3b2c89936c 100644 --- a/src/PJ_gn_sinu.c +++ b/src/PJ_gn_sinu.c @@ -47,7 +47,7 @@ static XY s_forward (LP lp, PJ *P) { /* Spheroidal, forward */ XY xy = {0.0,0.0}; struct pj_opaque *Q = P->opaque; - if (!Q->m) + if (Q->m == 0.0) lp.phi = Q->n != 1. ? aasin(P->ctx,Q->n * sin(lp.phi)): lp.phi; else { double k, V; @@ -75,7 +75,7 @@ static LP s_inverse (XY xy, PJ *P) { /* Spheroidal, inverse */ struct pj_opaque *Q = P->opaque; xy.y /= Q->C_y; - lp.phi = Q->m ? aasin(P->ctx,(Q->m * xy.y + sin(xy.y)) / Q->n) : + lp.phi = (Q->m != 0.0) ? aasin(P->ctx,(Q->m * xy.y + sin(xy.y)) / Q->n) : ( Q->n != 1. ? aasin(P->ctx,sin(xy.y) / Q->n) : xy.y ); lp.lam = xy.x / (Q->C_x * (Q->m + cos(xy.y))); return lp; @@ -122,7 +122,7 @@ PJ *PROJECTION(sinu) { if (!(Q->en = pj_enfn(P->es))) E_ERROR_0; - if (P->es) { + if (P->es != 0.0) { P->inv = e_inverse; P->fwd = e_forward; } else { diff --git a/src/PJ_healpix.c b/src/PJ_healpix.c index fc2122c53a..1513d455fd 100644 --- a/src/PJ_healpix.c +++ b/src/PJ_healpix.c @@ -615,7 +615,7 @@ PJ *PROJECTION(healpix) { return freeup_new (P); P->opaque = Q; - if (P->es) { + if (P->es != 0.0) { Q->apa = pj_authset(P->es); /* For auth_lat(). */ Q->qp = pj_qsfn(1.0, P->e, P->one_es); /* For auth_lat(). */ P->a = P->a*sqrt(0.5*Q->qp); /* Set P->a to authalic radius. */ @@ -647,7 +647,7 @@ PJ *PROJECTION(rhealpix) { if (Q->south_square < 0 || Q->south_square > 3) { E_ERROR(-47); } - if (P->es) { + if (P->es != 0.0) { Q->apa = pj_authset(P->es); /* For auth_lat(). */ Q->qp = pj_qsfn(1.0, P->e, P->one_es); /* For auth_lat(). */ P->a = P->a*sqrt(0.5*Q->qp); /* Set P->a to authalic radius. */ diff --git a/src/PJ_imw_p.c b/src/PJ_imw_p.c index 5d37b16d5c..126dd1906b 100644 --- a/src/PJ_imw_p.c +++ b/src/PJ_imw_p.c @@ -37,7 +37,7 @@ static XY loc_for(LP lp, PJ *P, double *yc) { struct pj_opaque *Q = P->opaque; XY xy; - if (! lp.phi) { + if (lp.phi == 0.0) { xy.x = lp.lam; xy.y = 0.; } else { @@ -162,13 +162,15 @@ PJ *PROJECTION(imw_p) { Q->lam_1 = sig * DEG_TO_RAD; } Q->mode = 0; - if (Q->phi_1) xy(P, Q->phi_1, &x1, &y1, &Q->sphi_1, &Q->R_1); + if (Q->phi_1 != 0.0) + xy(P, Q->phi_1, &x1, &y1, &Q->sphi_1, &Q->R_1); else { Q->mode = 1; y1 = 0.; x1 = Q->lam_1; } - if (Q->phi_2) xy(P, Q->phi_2, &x2, &T2, &Q->sphi_2, &Q->R_2); + if (Q->phi_2 != 0.0) + xy(P, Q->phi_2, &x2, &T2, &Q->sphi_2, &Q->R_2); else { Q->mode = -1; T2 = 0.; diff --git a/src/PJ_laea.c b/src/PJ_laea.c index d4535dd063..f4976cabe2 100644 --- a/src/PJ_laea.c +++ b/src/PJ_laea.c @@ -152,7 +152,7 @@ static LP e_inverse (XY xy, PJ *P) { /* Ellipsoidal, inverse */ /*-fallthrough*/ case S_POLE: q = (xy.x * xy.x + xy.y * xy.y); - if (!q) { + if (q == 0.0) { lp.lam = 0.; lp.phi = P->phi0; return (lp); @@ -237,7 +237,7 @@ PJ *PROJECTION(laea) { Q->mode = EQUIT; else Q->mode = OBLIQ; - if (P->es) { + if (P->es != 0.0) { double sinphi; P->e = sqrt(P->es); diff --git a/src/PJ_merc.c b/src/PJ_merc.c index e0ec965865..aafe7b8508 100644 --- a/src/PJ_merc.c +++ b/src/PJ_merc.c @@ -56,7 +56,7 @@ PJ *PROJECTION(merc) { if (phits >= M_HALFPI) E_ERROR(-24); } - if (P->es) { /* ellipsoid */ + if (P->es != 0.0) { /* ellipsoid */ if (is_phits) P->k0 = pj_msfn(sin(phits), cos(phits), P->es); P->inv = e_inverse; diff --git a/src/PJ_mod_ster.c b/src/PJ_mod_ster.c index 5d66fb414c..d979b41e6a 100644 --- a/src/PJ_mod_ster.c +++ b/src/PJ_mod_ster.c @@ -116,7 +116,7 @@ static PJ *setup(PJ *P) { /* general initialization */ struct pj_opaque *Q = P->opaque; double esphi, chio; - if (P->es) { + if (P->es != 0.0) { esphi = P->e * sin(P->phi0); chio = 2. * atan(tan((M_HALFPI + P->phi0) * .5) * pow((1. - esphi) / (1. + esphi), P->e * .5)) - M_HALFPI; @@ -230,7 +230,7 @@ PJ *PROJECTION(alsk) { Q->n = 5; P->lam0 = DEG_TO_RAD * -152.; P->phi0 = DEG_TO_RAD * 64.; - if (P->es) { /* fixed ellipsoid/sphere */ + if (P->es != 0.0) { /* fixed ellipsoid/sphere */ Q->zcoeff = ABe; P->a = 6378206.4; P->e = sqrt(P->es = 0.00676866); @@ -278,7 +278,7 @@ PJ *PROJECTION(gs50) { Q->n = 9; P->lam0 = DEG_TO_RAD * -120.; P->phi0 = DEG_TO_RAD * 45.; - if (P->es) { /* fixed ellipsoid/sphere */ + if (P->es != 0.0) { /* fixed ellipsoid/sphere */ Q->zcoeff = ABe; P->a = 6378206.4; P->e = sqrt(P->es = 0.00676866); diff --git a/src/PJ_poly.c b/src/PJ_poly.c index 5a679d615a..8fb671afd6 100644 --- a/src/PJ_poly.c +++ b/src/PJ_poly.c @@ -142,7 +142,7 @@ PJ *PROJECTION(poly) { return freeup_new (P); P->opaque = Q; - if (P->es) { + if (P->es != 0.0) { if (!(Q->en = pj_enfn(P->es))) E_ERROR_0; Q->ml0 = pj_mlfn(P->phi0, sin(P->phi0), cos(P->phi0), Q->en); P->inv = e_inverse; diff --git a/src/PJ_qsc.c b/src/PJ_qsc.c index faf60114f4..e5fee0ea97 100644 --- a/src/PJ_qsc.c +++ b/src/PJ_qsc.c @@ -115,7 +115,7 @@ static XY e_forward (LP lp, PJ *P) { /* Ellipsoidal, forward */ /* Convert the geodetic latitude to a geocentric latitude. * This corresponds to the shift from the ellipsoid to the sphere * described in [LK12]. */ - if (P->es) { + if (P->es != 0.0) { lat = atan(Q->one_minus_f_squared * tan(lp.phi)); } else { lat = lp.phi; @@ -346,7 +346,7 @@ static LP e_inverse (XY xy, PJ *P) { /* Ellipsoidal, inverse */ /* Apply the shift from the sphere to the ellipsoid as described * in [LK12]. */ - if (P->es) { + if (P->es != 0.0) { int invert_sign; double tanphi, xa; invert_sign = (lp.phi < 0.0 ? 1 : 0); @@ -400,7 +400,7 @@ PJ *PROJECTION(qsc) { } /* Fill in useful values for the ellipsoid <-> sphere shift * described in [LK12]. */ - if (P->es) { + if (P->es != 0.0) { Q->a_squared = P->a * P->a; Q->b = P->a * sqrt(1.0 - P->es); Q->one_minus_f = 1.0 - (P->a - Q->b) / P->a; diff --git a/src/PJ_stere.c b/src/PJ_stere.c index 5ca1b9d996..c7fb02e32a 100644 --- a/src/PJ_stere.c +++ b/src/PJ_stere.c @@ -222,7 +222,7 @@ static PJ *setup(PJ *P) { /* general initialization */ Q->mode = t > EPS10 ? OBLIQ : EQUIT; Q->phits = fabs (Q->phits); - if (P->es) { + if (P->es != 0.0) { double X; switch (Q->mode) { @@ -295,7 +295,7 @@ PJ *PROJECTION(ups) { /* International Ellipsoid */ P->phi0 = pj_param(P->ctx, P->params, "bsouth").i ? - M_HALFPI: M_HALFPI; - if (!P->es) E_ERROR(-34); + if (P->es == 0.0) E_ERROR(-34); P->k0 = .994; P->x0 = 2000000.; P->y0 = 2000000.; diff --git a/src/PJ_sterea.c b/src/PJ_sterea.c index 6e450899ab..73c6b48c05 100644 --- a/src/PJ_sterea.c +++ b/src/PJ_sterea.c @@ -64,7 +64,7 @@ static LP e_inverse (XY xy, PJ *P) { /* Ellipsoidal, inverse */ xy.x /= P->k0; xy.y /= P->k0; - if ( (rho = hypot (xy.x, xy.y)) ) { + if ( (rho = hypot (xy.x, xy.y)) != 0.0 ) { c = 2. * atan2 (rho, Q->R2); sinc = sin (c); cosc = cos (c); diff --git a/src/PJ_tmerc.c b/src/PJ_tmerc.c index dcade171e8..5cbb2b5d96 100644 --- a/src/PJ_tmerc.c +++ b/src/PJ_tmerc.c @@ -150,7 +150,7 @@ static LP s_inverse (XY xy, PJ *P) { /* Spheroidal, inverse */ /* Make sure that phi is on the correct hemisphere when false northing is used */ if (xy.y < 0. && -lp.phi+P->phi0 < 0.0) lp.phi = -lp.phi; - lp.lam = (g || h) ? atan2 (g, h) : 0.; + lp.lam = (g != 0.0 || h != 0.0) ? atan2 (g, h) : 0.; return lp; } @@ -172,7 +172,7 @@ static void freeup (PJ *P) { static PJ *setup(PJ *P) { /* general initialization */ struct pj_opaque *Q = P->opaque; - if (P->es) { + if (P->es != 0.0) { if (!(Q->en = pj_enfn(P->es))) E_ERROR_0; Q->ml0 = pj_mlfn(P->phi0, sin(P->phi0), cos(P->phi0), Q->en); diff --git a/src/geod_set.c b/src/geod_set.c index f61ab437a7..60f19990b8 100644 --- a/src/geod_set.c +++ b/src/geod_set.c @@ -51,7 +51,7 @@ geod_set(int argc, char **argv) { geod_for(); } else emess(1,"incomplete geodesic/arc info"); if ((n_alpha = pj_param(NULL,start, "in_A").i) > 0) { - if (!(del_alpha = pj_param(NULL,start, "rdel_A").f)) + if ((del_alpha = pj_param(NULL,start, "rdel_A").f) == 0.0) emess(1,"del azimuth == 0"); } else if ((del_S = fabs(pj_param(NULL,start, "ddel_S").f)) != 0.) { n_S = (int)(geod_S / del_S + .5); diff --git a/src/mk_cheby.c b/src/mk_cheby.c index 32f22f1a41..a7cd75c5c4 100644 --- a/src/mk_cheby.c +++ b/src/mk_cheby.c @@ -83,9 +83,9 @@ mk_cheby(projUV a, projUV b, double res, projUV *resid, projUV (*func)(projUV), for (j = 0; j < nu; ++j) { ncu[j] = ncv[j] = 0; /* clear column maxes */ for (s = w[j], i = 0; i < nv; ++i, ++s) { - if (s->u) + if (s->u != 0.0) ncu[j] = i + 1; /* update column max */ - if (s->v) + if (s->v != 0.0) ncv[j] = i + 1; } if (ncu[j]) nru = j + 1; /* update row max */ diff --git a/src/pj_ell_set.c b/src/pj_ell_set.c index 87fb6e414a..865726fa67 100644 --- a/src/pj_ell_set.c +++ b/src/pj_ell_set.c @@ -45,7 +45,7 @@ int pj_ell_set(projCtx ctx, paralist *pl, double *a, double *es) { *es = e * e; } else if (pj_param(ctx,pl, "trf").i) { /* recip flattening */ *es = pj_param(ctx,pl, "drf").f; - if (!*es) { + if (*es == 0.0) { pj_ctx_set_errno( ctx, -10); goto bomb; } @@ -58,7 +58,7 @@ int pj_ell_set(projCtx ctx, paralist *pl, double *a, double *es) { b = pj_param(ctx,pl, "db").f; *es = 1. - (b * b) / (*a * *a); } /* else *es == 0. and sphere of radius *a */ - if (!b) + if (b == 0.0) b = *a * sqrt(1. - *es); /* following options turn ellipsoid into equivalent sphere */ if (pj_param(ctx,pl, "bR_A").i) { /* sphere--area of ellipsoid */ diff --git a/src/pj_factors.c b/src/pj_factors.c index ac23ed7197..d959494ed3 100644 --- a/src/pj_factors.c +++ b/src/pj_factors.c @@ -47,7 +47,7 @@ pj_factors(LP lp, PJ *P, double h, struct FACTORS *fac) { if (!(fac->code & IS_ANAL_HK)) { fac->h = hypot(fac->der.x_p, fac->der.y_p); fac->k = hypot(fac->der.x_l, fac->der.y_l) / cosphi; - if (P->es) { + if (P->es != 0.0) { t = sin(lp.phi); t = 1. - P->es * t * t; n = sqrt(t); @@ -56,7 +56,7 @@ pj_factors(LP lp, PJ *P, double h, struct FACTORS *fac) { r = t * t / P->one_es; } else r = 1.; - } else if (P->es) { + } else if (P->es != 0.0) { r = sin(lp.phi); r = 1. - P->es * r * r; r = r * r / P->one_es; diff --git a/src/pj_init.c b/src/pj_init.c index b6be52d928..24aece8461 100644 --- a/src/pj_init.c +++ b/src/pj_init.c @@ -512,15 +512,15 @@ pj_init_ctx(projCtx ctx, int argc, char **argv) { /* flattening */ PIN->f = 1 - cos (PIN->alpha); /* = 1 - sqrt (1 - PIN->es); */ - PIN->rf = PIN->f? 1.0/PIN->f: HUGE_VAL; + PIN->rf = PIN->f != 0.0 ? 1.0/PIN->f: HUGE_VAL; /* second flattening */ PIN->f2 = 1/cos (PIN->alpha) - 1; - PIN->rf2 = PIN->f2? 1/PIN->f2: HUGE_VAL; + PIN->rf2 = PIN->f2 != 0.0 ? 1/PIN->f2: HUGE_VAL; /* third flattening */ PIN->n = pow (tan (PIN->alpha/2), 2); - PIN->rn = PIN->n? 1/PIN->n: HUGE_VAL; + PIN->rn = PIN->n != 0.0 ? 1/PIN->n: HUGE_VAL; /* ...and a few more */ PIN->b = (1 - PIN->f)*PIN->a; @@ -545,7 +545,7 @@ pj_init_ctx(projCtx ctx, int argc, char **argv) { } /* set PIN->geoc coordinate system */ - PIN->geoc = (PIN->es && pj_param(ctx, start, "bgeoc").i); + PIN->geoc = (PIN->es != 0.0 && pj_param(ctx, start, "bgeoc").i); /* over-ranging flag */ PIN->over = pj_param(ctx, start, "bover").i; diff --git a/src/proj.c b/src/proj.c index 10eb0f8d5e..18355125c1 100644 --- a/src/proj.c +++ b/src/proj.c @@ -450,7 +450,7 @@ int main(int argc, char **argv) { pj_pr_list(Proj); if (very_verby) { (void)printf("#Final Earth figure: "); - if (Proj->es) { + if (Proj->es != 0.0) { (void)printf("ellipsoid\n# Major axis (a): "); (void)printf(oform ? oform : "%.3f", Proj->a); (void)printf("\n# 1/flattening: %.6f\n", diff --git a/src/proj_etmerc.c b/src/proj_etmerc.c index aed1499ed2..2c07808b7d 100644 --- a/src/proj_etmerc.c +++ b/src/proj_etmerc.c @@ -411,7 +411,7 @@ PJ *PROJECTION(utm) { return freeup_new (P); P->opaque = Q; - if (!P->es) + if (P->es == 0.0) E_ERROR(-34); P->y0 = pj_param (P->ctx, P->params, "bsouth").i ? 10000000. : 0.; P->x0 = 500000.; diff --git a/src/rtodms.c b/src/rtodms.c index 5e88ca1476..b6ad9721c1 100644 --- a/src/rtodms.c +++ b/src/rtodms.c @@ -55,7 +55,7 @@ rtodms(char *s, double r, int pos, int neg) { if (dolong) (void)sprintf(ss,format,deg,min,sec,sign); - else if (sec) { + else if (sec != 0.0) { char *p, *q; /* double prime + pos/neg suffix (if included) + NUL */ size_t suffix_len = sign ? 3 : 2; From abb21adb39de752b427e1e6fc66d94cfc9c3ee04 Mon Sep 17 00:00:00 2001 From: Even Rouault Date: Sun, 26 Feb 2017 13:36:32 +0100 Subject: [PATCH 10/12] Fix MSVC warnings and add /Wx to appveyor.yml --- appveyor.yml | 6 +++--- src/PJ_horner.c | 6 +++--- src/PJ_pipeline.c | 4 ++-- src/nad_init.c | 6 +++--- src/pj_init.c | 6 +++--- src/pj_open_lib.c | 4 ++-- src/pj_param.c | 2 +- src/pj_pr_list.c | 4 ++-- 8 files changed, 19 insertions(+), 19 deletions(-) diff --git a/appveyor.yml b/appveyor.yml index 9397d627aa..a203949c19 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -5,8 +5,6 @@ platform: environment: matrix: - - BUILD_TYPE: nmake - # Does not work # VS 2008 # - BUILD_TYPE: cmake @@ -24,6 +22,8 @@ environment: - BUILD_TYPE: cmake VS_VERSION: Visual Studio 12 + - BUILD_TYPE: nmake + shallow_clone: true build_script: @@ -40,7 +40,7 @@ build_script: - if "%BUILD_TYPE%" == "cmake" if "%platform%" == "x64" SET VS_FULL=%VS_VERSION% Win64 - if "%BUILD_TYPE%" == "cmake" if "%platform%" == "x86" SET VS_FULL=%VS_VERSION% - if "%BUILD_TYPE%" == "cmake" echo "%VS_FULL%" - - if "%BUILD_TYPE%" == "cmake" cmake -G "%VS_FULL%" . -DSELFTEST=ON -DCMAKE_BUILD_TYPE=Release -DCMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE=../bin -DBUILD_LIBPROJ_SHARED=ON + - if "%BUILD_TYPE%" == "cmake" cmake -G "%VS_FULL%" . -DSELFTEST=ON -DCMAKE_BUILD_TYPE=Release -DCMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE=../bin -DBUILD_LIBPROJ_SHARED=ON -DCMAKE_C_FLAGS="/W3 /WX /D_CRT_SECURE_NO_WARNINGS" - if "%BUILD_TYPE%" == "cmake" cmake --build . --config Release test_script: diff --git a/src/PJ_horner.c b/src/PJ_horner.c index 3dde29c8a4..4ee2e78abf 100644 --- a/src/PJ_horner.c +++ b/src/PJ_horner.c @@ -134,7 +134,7 @@ static void horner_free (HORNER *h) { static HORNER *horner_alloc (size_t order, int complex_polynomia) { /* size_t is unsigned, so we need not check for order > 0 */ - int n = horner_number_of_coefficients(order); + int n = (int)horner_number_of_coefficients(order); int polynomia_ok = 0; HORNER *h = horner_calloc (1, sizeof (HORNER)); @@ -142,8 +142,8 @@ static HORNER *horner_alloc (size_t order, int complex_polynomia) { return 0; if (complex_polynomia) - n = 2*order + 2; - h->order = order; + n = 2*(int)order + 2; + h->order = (int)order; h->coefs = n; if (complex_polynomia) { diff --git a/src/PJ_pipeline.c b/src/PJ_pipeline.c index 0dae0e595c..e61954a091 100644 --- a/src/PJ_pipeline.c +++ b/src/PJ_pipeline.c @@ -309,7 +309,7 @@ static PJ *pj_create_pipeline (PJ *P, size_t steps) { if (0==P->opaque->pipeline) return 0; - P->opaque->steps = steps; + P->opaque->steps = (int)steps; P->opaque->reverse_step = pj_calloc (steps + 2, sizeof(int)); if (0==P->opaque->reverse_step) @@ -369,7 +369,7 @@ PJ *PROJECTION(pipeline) { if (0==P->opaque) return 0; - argc = argc_params (P->params); + argc = (int)argc_params (P->params); P->opaque->argv = argv = argv_params (P->params, argc); if (0==argv) return pipeline_freeup (P, ENOMEM); diff --git a/src/nad_init.c b/src/nad_init.c index 3b35ea639b..14fa5226f0 100644 --- a/src/nad_init.c +++ b/src/nad_init.c @@ -134,7 +134,7 @@ struct CTABLE *nad_ctable_init( projCtx ctx, PAFile fid ) } /* trim white space and newlines off id */ - for( id_end = strlen(ct->id)-1; id_end > 0; id_end-- ) + for( id_end = (int)strlen(ct->id)-1; id_end > 0; id_end-- ) { if( ct->id[id_end] == '\n' || ct->id[id_end] == ' ' ) ct->id[id_end] = '\0'; @@ -181,7 +181,7 @@ int nad_ctable2_load( projCtx ctx, struct CTABLE *ct, PAFile fid ) if( !IS_LSB ) { - swap_words( ct->cvs, 4, a_size * 2 ); + swap_words( ct->cvs, 4, (int)a_size * 2 ); } return 1; @@ -243,7 +243,7 @@ struct CTABLE *nad_ctable2_init( projCtx ctx, PAFile fid ) } /* trim white space and newlines off id */ - for( id_end = strlen(ct->id)-1; id_end > 0; id_end-- ) + for( id_end = (int)strlen(ct->id)-1; id_end > 0; id_end-- ) { if( ct->id[id_end] == '\n' || ct->id[id_end] == ' ' ) ct->id[id_end] = '\0'; diff --git a/src/pj_init.c b/src/pj_init.c index 24aece8461..62901fdf0f 100644 --- a/src/pj_init.c +++ b/src/pj_init.c @@ -73,7 +73,7 @@ static const char *fill_buffer(pj_read_state *state, const char *last_char) /* Move the existing data to the start of the buffer. */ /* -------------------------------------------------------------------- */ memmove(state->buffer, last_char, char_remaining); - state->buffer_filled = char_remaining; + state->buffer_filled = (int)char_remaining; last_char = state->buffer; /* -------------------------------------------------------------------- */ @@ -116,7 +116,7 @@ static const char *fill_buffer(pj_read_state *state, const char *last_char) *w++ = *r++; } *w = 0; - state->buffer_filled += (bytes_read - (r-w)); + state->buffer_filled += (int)(bytes_read - (r-w)); return last_char; } @@ -139,7 +139,7 @@ get_opt(projCtx ctx, paralist **start, PAFile fid, char *name, paralist *next, if(found_def) *found_def = 0; - len = strlen(name); + len = (int)strlen(name); *sword = 't'; if (0==next_char) diff --git a/src/pj_open_lib.c b/src/pj_open_lib.c index 0a2e7fecac..d5ad2549e4 100644 --- a/src/pj_open_lib.c +++ b/src/pj_open_lib.c @@ -113,7 +113,7 @@ pj_open_lib(projCtx ctx, const char *name, const char *mode) { if (*name == '~' && strchr(dir_chars,name[1]) ) if ((sysname = getenv("HOME")) != NULL) { (void)strcpy(fname, sysname); - fname[n = strlen(fname)] = DIR_CHAR; + fname[n = (int)strlen(fname)] = DIR_CHAR; fname[++n] = '\0'; (void)strcpy(fname+n, name + 1); sysname = fname; @@ -134,7 +134,7 @@ pj_open_lib(projCtx ctx, const char *name, const char *mode) { /* or is environment PROJ_LIB defined */ else if ((sysname = getenv("PROJ_LIB")) || (sysname = proj_lib_name)) { (void)strcpy(fname, sysname); - fname[n = strlen(fname)] = DIR_CHAR; + fname[n = (int)strlen(fname)] = DIR_CHAR; fname[++n] = '\0'; (void)strcpy(fname+n, name); sysname = fname; diff --git a/src/pj_param.c b/src/pj_param.c index 24c2354e31..93f5cf53e2 100644 --- a/src/pj_param.c +++ b/src/pj_param.c @@ -45,7 +45,7 @@ pj_param(projCtx ctx, paralist *pl, const char *opt) { type = *opt++; /* simple linear lookup */ - l = strlen(opt); + l = (int)strlen(opt); while (pl && !(!strncmp(pl->param, opt, l) && (!pl->param[l] || pl->param[l] == '='))) pl = pl->next; diff --git a/src/pj_pr_list.c b/src/pj_pr_list.c index 95aab4a08a..5ccfbe5b9a 100644 --- a/src/pj_pr_list.c +++ b/src/pj_pr_list.c @@ -11,7 +11,7 @@ pr_list(PJ *P, int not_used) { (void)putchar('#'); for (t = P->params; t; t = t->next) if ((!not_used && t->used) || (not_used && !t->used)) { - l = strlen(t->param) + 1; + l = (int)strlen(t->param) + 1; if (n + l > LINE_LEN) { (void)fputs("\n#", stdout); n = 2; @@ -71,7 +71,7 @@ char *pj_get_def( PJ *P, int options ) continue; /* grow the resulting string if needed */ - l = strlen(t->param) + 1; + l = (int)strlen(t->param) + 1; if( strlen(definition) + l + 5 > def_max ) { char *def2; From ac66e57366f11cd76d187dbc1e482d3f131dcd72 Mon Sep 17 00:00:00 2001 From: Even Rouault Date: Sun, 26 Feb 2017 13:50:07 +0100 Subject: [PATCH 11/12] PJ_lsat.c: restore d__1 computation that was lost in conversion done in c9f12e0033474518fa460444b9948f36ce47d51f. Issue raised by VS12 --- src/PJ_lsat.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/PJ_lsat.c b/src/PJ_lsat.c index 292a582702..a58bb3cbf9 100644 --- a/src/PJ_lsat.c +++ b/src/PJ_lsat.c @@ -22,6 +22,7 @@ static void seraz0(double lam, double mult, PJ *P) { s = Q->p22 * Q->sa * cos(lam) * sqrt((1. + Q->t * sdsq) / ((1. + Q->w * sdsq) * (1. + Q->q * sdsq))); + d__1 = 1. + Q->q * sdsq; h = sqrt((1. + Q->q * sdsq) / (1. + Q->w * sdsq)) * ((1. + Q->w * sdsq) / (d__1 * d__1) - Q->p22 * Q->ca); From 0cbb3c200d467a520783b07c0774bf3c62cac9b9 Mon Sep 17 00:00:00 2001 From: Even Rouault Date: Sun, 26 Feb 2017 14:07:30 +0100 Subject: [PATCH 12/12] Raise MSVC warning level to /W4 --- appveyor.yml | 3 ++- src/PJ_aeqd.c | 2 +- src/PJ_bipc.c | 2 +- src/PJ_healpix.c | 11 +++++++---- src/PJ_helmert.c | 47 +++++++++++++++++++++++------------------------ src/PJ_horner.c | 4 ++-- src/PJ_isea.c | 18 ++++++++++++++++-- src/PJ_lsat.c | 2 +- src/PJ_misrsom.c | 2 +- src/PJ_mod_ster.c | 2 +- src/cs2cs.c | 2 +- src/gen_cheb.c | 2 +- src/geod.c | 2 +- src/nad2bin.c | 2 +- src/nad_init.c | 2 +- src/pj_factors.c | 5 +++++ src/pj_gridinfo.c | 26 +++++++++++++++++++++++++- src/pj_strerrno.c | 1 - src/proj.c | 10 ++++++---- 19 files changed, 96 insertions(+), 49 deletions(-) diff --git a/appveyor.yml b/appveyor.yml index a203949c19..e1d230253e 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -40,7 +40,8 @@ build_script: - if "%BUILD_TYPE%" == "cmake" if "%platform%" == "x64" SET VS_FULL=%VS_VERSION% Win64 - if "%BUILD_TYPE%" == "cmake" if "%platform%" == "x86" SET VS_FULL=%VS_VERSION% - if "%BUILD_TYPE%" == "cmake" echo "%VS_FULL%" - - if "%BUILD_TYPE%" == "cmake" cmake -G "%VS_FULL%" . -DSELFTEST=ON -DCMAKE_BUILD_TYPE=Release -DCMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE=../bin -DBUILD_LIBPROJ_SHARED=ON -DCMAKE_C_FLAGS="/W3 /WX /D_CRT_SECURE_NO_WARNINGS" +# warning C4706: assignment within conditional expression + - if "%BUILD_TYPE%" == "cmake" cmake -G "%VS_FULL%" . -DSELFTEST=ON -DCMAKE_BUILD_TYPE=Release -DCMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE=../bin -DBUILD_LIBPROJ_SHARED=ON -DCMAKE_C_FLAGS="/W4 /wd4706 /WX /D_CRT_SECURE_NO_WARNINGS" - if "%BUILD_TYPE%" == "cmake" cmake --build . --config Release test_script: diff --git a/src/PJ_aeqd.c b/src/PJ_aeqd.c index b10bfd62cc..225acfdd51 100644 --- a/src/PJ_aeqd.c +++ b/src/PJ_aeqd.c @@ -153,7 +153,7 @@ static XY s_forward (LP lp, PJ *P) { /* Spheroidal, forward */ static LP e_guam_inv(XY xy, PJ *P) { /* Guam elliptical */ LP lp = {0.0,0.0}; struct pj_opaque *Q = P->opaque; - double x2, t; + double x2, t = 0.0; int i; x2 = 0.5 * xy.x * xy.x; diff --git a/src/PJ_bipc.c b/src/PJ_bipc.c index f370b4f9bb..2d015de1ce 100644 --- a/src/PJ_bipc.c +++ b/src/PJ_bipc.c @@ -94,7 +94,7 @@ static XY s_forward (LP lp, PJ *P) { /* Spheroidal, forward */ static LP s_inverse (XY xy, PJ *P) { /* Spheroidal, inverse */ LP lp = {0.0,0.0}; struct pj_opaque *Q = P->opaque; - double t, r, rp, rl, al, z, fAz, Az, s, c, Av; + double t, r, rp, rl, al, z = 0.0, fAz, Az, s, c, Av; int neg, i; if (Q->noskew) { diff --git a/src/PJ_healpix.c b/src/PJ_healpix.c index 1513d455fd..edd0d9783f 100644 --- a/src/PJ_healpix.c +++ b/src/PJ_healpix.c @@ -106,7 +106,7 @@ static int get_rotate_index(int index) { * @param vert the (x, y)-coordinates of the polygon's vertices **/ static int pnpoly(int nvert, double vert[][2], double testx, double testy) { - int i, c = 0; + int i; int counter = 0; double xinters; XY p1, p2; @@ -141,7 +141,6 @@ static int pnpoly(int nvert, double vert[][2], double testx, double testy) { } else { return 1; } - return c; } @@ -517,7 +516,9 @@ static XY e_healpix_forward(LP lp, PJ *P) { /* ellipsoid */ static LP s_healpix_inverse(XY xy, PJ *P) { /* sphere */ /* Check whether (x, y) lies in the HEALPix image */ if (in_image(xy.x, xy.y, 0, 0, 0) == 0) { - LP lp = {HUGE_VAL, HUGE_VAL}; + LP lp; + lp.lam = HUGE_VAL; + lp.phi = HUGE_VAL; pj_ctx_set_errno(P->ctx, -15); return lp; } @@ -563,7 +564,9 @@ static LP s_rhealpix_inverse(XY xy, PJ *P) { /* sphere */ /* Check whether (x, y) lies in the rHEALPix image. */ if (in_image(xy.x, xy.y, 1, Q->north_square, Q->south_square) == 0) { - LP lp = {HUGE_VAL, HUGE_VAL}; + LP lp; + lp.lam = HUGE_VAL; + lp.phi = HUGE_VAL; pj_ctx_set_errno(P->ctx, -15); return lp; } diff --git a/src/PJ_helmert.c b/src/PJ_helmert.c index 8ae0a7859b..af35582a48 100644 --- a/src/PJ_helmert.c +++ b/src/PJ_helmert.c @@ -346,7 +346,7 @@ PJ *PROJECTION(helmert) { between the conventions. ***************************************************************************/ - do { + { double f, t, p; /* phi/fi , theta, psi */ double cf, ct, cp; /* cos (fi, theta, psi) */ double sf, st, sp; /* sin (fi, theta, psi) */ @@ -368,28 +368,29 @@ PJ *PROJECTION(helmert) { R20 = t; R21 = -f; R22 = 1; - break; } - - cf = cos(f); - sf = sin(f); - ct = cos(t); - st = sin(t); - cp = cos(p); - sp = sin(p); - - - R00 = ct*cp; - R01 = cf*sp + sf*st*cp; - R02 = sf*sp - cf*st*cp; - - R10 = -ct*sp; - R11 = cf*cp - sf*st*sp; - R12 = sf*cp + cf*st*sp; - - R20 = st; - R21 = -sf*ct; - R22 = cf*ct; + else { + cf = cos(f); + sf = sin(f); + ct = cos(t); + st = sin(t); + cp = cos(p); + sp = sin(p); + + + R00 = ct*cp; + R01 = cf*sp + sf*st*cp; + R02 = sf*sp - cf*st*cp; + + R10 = -ct*sp; + R11 = cf*cp - sf*st*sp; + R12 = sf*cp + cf*st*sp; + + R20 = st; + R21 = -sf*ct; + R22 = cf*ct; + } + } /* For comparison: Description from Engsager/Poder implementation @@ -417,8 +418,6 @@ PJ *PROJECTION(helmert) { trp->scale = 1.0 + scale; */ - } while (0); - if (transpose) { double r; diff --git a/src/PJ_horner.c b/src/PJ_horner.c index 4ee2e78abf..1b055a4e79 100644 --- a/src/PJ_horner.c +++ b/src/PJ_horner.c @@ -396,7 +396,7 @@ static void freeup (PJ *P) { static int parse_coefs (PJ *P, double *coefs, char *param, int ncoefs) { - char *buf, *init, *next; + char *buf, *init, *next = 0; int i; buf = pj_calloc (strlen (param) + 2, sizeof(char)); @@ -414,7 +414,7 @@ static int parse_coefs (PJ *P, double *coefs, char *param, int ncoefs) { for (i = 0; i < ncoefs; i++) { if (i > 0) { - if (','!=*next) { + if ( next == 0 || ','!=*next) { pj_log_error (P, "Horner: Malformed polynomium set %s. need %d coefs", param, ncoefs); return 0; } diff --git a/src/PJ_isea.c b/src/PJ_isea.c index cd87d56556..6bc6a66c61 100644 --- a/src/PJ_isea.c +++ b/src/PJ_isea.c @@ -317,6 +317,12 @@ sph_azimuth(double f_lon, double f_lat, double t_lon, double t_lat) return az; } +#ifdef _MSC_VER +#pragma warning( push ) +/* disable unreachable code warning for return 0 */ +#pragma warning( disable : 4702 ) +#endif + /* coord needs to be in radians */ ISEA_STATIC int @@ -491,6 +497,10 @@ isea_snyder_forward(struct isea_geo * ll, struct isea_pt * out) return 0; /* suppresses a warning */ } +#ifdef _MSC_VER +#pragma warning( pop ) +#endif + /* * return the new coordinates of any point in original coordinate system. * Define a point (newNPold) in original coordinate system as the North Pole in @@ -911,8 +921,11 @@ ISEA_STATIC int isea_hex(struct isea_dgg *g, int tri, struct isea_pt *pt, struct isea_pt *hex) { struct isea_pt v; +#ifdef FIXME int sidelength; - int d, i, x, y, quad; + int d, i, x, y; +#endif + int quad; quad = isea_ptdi(g, tri, pt, &v); @@ -920,7 +933,7 @@ int isea_hex(struct isea_dgg *g, int tri, hex->y = v.y; return 1; - +#ifdef FIXME d = (int)v.x; i = (int)v.y; @@ -964,6 +977,7 @@ int isea_hex(struct isea_dgg *g, int tri, } return 1; +#endif } ISEA_STATIC diff --git a/src/PJ_lsat.c b/src/PJ_lsat.c index a58bb3cbf9..665c066201 100644 --- a/src/PJ_lsat.c +++ b/src/PJ_lsat.c @@ -41,7 +41,7 @@ static XY e_forward (LP lp, PJ *P) { /* Ellipsoidal, forward */ XY xy = {0.0,0.0}; struct pj_opaque *Q = P->opaque; int l, nn; - double lamt, xlam, sdsq, c, d, s, lamdp, phidp, lampp, tanph; + double lamt = 0.0, xlam, sdsq, c, d, s, lamdp = 0.0, phidp, lampp, tanph; double lamtp, cl, sd, sp, fac, sav, tanphi; if (lp.phi > M_HALFPI) diff --git a/src/PJ_misrsom.c b/src/PJ_misrsom.c index 4d910b4a14..358c036ad8 100644 --- a/src/PJ_misrsom.c +++ b/src/PJ_misrsom.c @@ -59,7 +59,7 @@ static XY e_forward (LP lp, PJ *P) { /* Ellipsoidal, forward */ XY xy = {0.0,0.0}; struct pj_opaque *Q = P->opaque; int l, nn; - double lamt, xlam, sdsq, c, d, s, lamdp, phidp, lampp, tanph; + double lamt = 0.0, xlam, sdsq, c, d, s, lamdp = 0.0, phidp, lampp, tanph; double lamtp, cl, sd, sp, fac, sav, tanphi; if (lp.phi > M_HALFPI) diff --git a/src/PJ_mod_ster.c b/src/PJ_mod_ster.c index d979b41e6a..bcf2bf9ccf 100644 --- a/src/PJ_mod_ster.c +++ b/src/PJ_mod_ster.c @@ -46,7 +46,7 @@ static LP e_inverse (XY xy, PJ *P) { /* Ellipsoidal, inverse */ struct pj_opaque *Q = P->opaque; int nn; COMPLEX p, fxy, fpxy, dp; - double den, rh, z, sinz, cosz, chi, phi, dphi, esphi; + double den, rh = 0.0, z, sinz = 0.0, cosz = 0.0, chi, phi = 0.0, dphi, esphi; p.r = xy.x; p.i = xy.y; diff --git a/src/cs2cs.c b/src/cs2cs.c index ac72b0a07c..7afeea732c 100644 --- a/src/cs2cs.c +++ b/src/cs2cs.c @@ -100,7 +100,7 @@ static void process(FILE *fid) if (!*s && (s > line)) --s; /* assumed we gobbled \n */ if ( echoin) { - int t; + char t; t = *s; *s = '\0'; (void)fputs(line, stdout); diff --git a/src/gen_cheb.c b/src/gen_cheb.c index 6422afc90f..9b2d8cb3ba 100644 --- a/src/gen_cheb.c +++ b/src/gen_cheb.c @@ -12,6 +12,7 @@ /* FIXME: put the declaration in a header. Also used in proj.c */ void gen_cheb(int inverse, projUV (*proj)(projUV), char *s, PJ *P, int iargc, char **iargv); +extern void p_series(Tseries *, FILE *, char *); void gen_cheb(int inverse, projUV (*proj)(projUV), char *s, PJ *P, int iargc, char **iargv) { @@ -19,7 +20,6 @@ void gen_cheb(int inverse, projUV (*proj)(projUV), char *s, PJ *P, char *arg, fmt[15]; projUV low, upp, resid; Tseries *F; - extern void p_series(Tseries *, FILE *, char *); double (*input)(const char *, char **); input = inverse ? strtod : dmstor; diff --git a/src/geod.c b/src/geod.c index 12513cb030..755afbd724 100644 --- a/src/geod.c +++ b/src/geod.c @@ -127,7 +127,7 @@ static char *pargv[MAX_PARGS]; static int pargc = 0; int main(int argc, char **argv) { - char *arg, **eargv = argv, *strnchr(); + char *arg, **eargv = argv; FILE *fid; static int eargc = 0, c; diff --git a/src/nad2bin.c b/src/nad2bin.c index 859134e6c1..0001189c2a 100644 --- a/src/nad2bin.c +++ b/src/nad2bin.c @@ -28,7 +28,7 @@ static void swap_words( void *data_in, int word_size, int word_count ) for( i = 0; i < word_size/2; i++ ) { - int t; + unsigned char t; t = data[i]; data[i] = data[word_size-i-1]; diff --git a/src/nad_init.c b/src/nad_init.c index 14fa5226f0..a84b038709 100644 --- a/src/nad_init.c +++ b/src/nad_init.c @@ -63,7 +63,7 @@ static void swap_words( void *data_in, int word_size, int word_count ) for( i = 0; i < word_size/2; i++ ) { - int t; + unsigned char t; t = data[i]; data[i] = data[word_size-i-1]; diff --git a/src/pj_factors.c b/src/pj_factors.c index d959494ed3..b87b49ff98 100644 --- a/src/pj_factors.c +++ b/src/pj_factors.c @@ -11,6 +11,11 @@ pj_factors(LP lp, PJ *P, double h, struct FACTORS *fac) { struct DERIVS der; double cosphi, t, n, r; + der.x_l = 0.0; + der.x_p = 0.0; + der.y_l = 0.0; + der.y_p = 0.0; + /* check for forward and latitude or longitude overange */ if ((t = fabs(lp.phi)-M_HALFPI) > EPS || fabs(lp.lam) > 10.) { pj_ctx_set_errno( P->ctx, -14); diff --git a/src/pj_gridinfo.c b/src/pj_gridinfo.c index d54aadceb8..458f0f2b90 100644 --- a/src/pj_gridinfo.c +++ b/src/pj_gridinfo.c @@ -63,7 +63,7 @@ static void swap_words( unsigned char *data, int word_size, int word_count ) for( i = 0; i < word_size/2; i++ ) { - int t; + unsigned char t; t = data[i]; data[i] = data[word_size-i-1]; @@ -427,7 +427,15 @@ static int pj_gridinfo_init_ntv2( projCtx ctx, PAFile fid, PJ_GRIDINFO *gilist ) assert( sizeof(int) == 4 ); assert( sizeof(double) == 8 ); +#ifdef _MSC_VER +#pragma warning( push ) +/* disable conditional expression is constant */ +#pragma warning( disable : 4127 ) +#endif if( sizeof(int) != 4 || sizeof(double) != 8 ) +#ifdef _MSC_VER +#pragma warning( pop ) +#endif { pj_log( ctx, PJ_LOG_ERROR, "basic types of inappropraiate size in pj_gridinfo_init_ntv2()" ); @@ -640,7 +648,15 @@ static int pj_gridinfo_init_ntv1( projCtx ctx, PAFile fid, PJ_GRIDINFO *gi ) assert( sizeof(int) == 4 ); assert( sizeof(double) == 8 ); +#ifdef _MSC_VER +#pragma warning( push ) +/* disable conditional expression is constant */ +#pragma warning( disable : 4127 ) +#endif if( sizeof(int) != 4 || sizeof(double) != 8 ) +#ifdef _MSC_VER +#pragma warning( pop ) +#endif { pj_log( ctx, PJ_LOG_ERROR, "basic types of inappropraiate size in nad_load_ntv1()" ); @@ -728,7 +744,15 @@ static int pj_gridinfo_init_gtx( projCtx ctx, PAFile fid, PJ_GRIDINFO *gi ) assert( sizeof(int) == 4 ); assert( sizeof(double) == 8 ); +#ifdef _MSC_VER +#pragma warning( push ) +/* disable conditional expression is constant */ +#pragma warning( disable : 4127 ) +#endif if( sizeof(int) != 4 || sizeof(double) != 8 ) +#ifdef _MSC_VER +#pragma warning( pop ) +#endif { pj_log( ctx, PJ_LOG_ERROR, "basic types of inappropraiate size in nad_load_gtx()" ); diff --git a/src/pj_strerrno.c b/src/pj_strerrno.c index bef42882ee..8a2a9c4be2 100644 --- a/src/pj_strerrno.c +++ b/src/pj_strerrno.c @@ -82,5 +82,4 @@ char *pj_strerrno(int err) { return note; } } - return 0; } diff --git a/src/proj.c b/src/proj.c index 18355125c1..ed5d523251 100644 --- a/src/proj.c +++ b/src/proj.c @@ -20,6 +20,10 @@ #define MAX_LINE 1000 #define MAX_PARGS 100 #define PJ_INVERS(P) (P->inv ? 1 : 0) + +extern void gen_cheb(int, projUV(*)(projUV), char *, PJ *, int, char **); + + static PJ *Proj; static projUV @@ -58,7 +62,7 @@ int_proj(projUV data) { } static void /* file processing function */ process(FILE *fid) { - char line[MAX_LINE+3], *s, pline[40]; + char line[MAX_LINE+3], *s = 0, pline[40]; projUV data; for (;;) { @@ -91,7 +95,7 @@ process(FILE *fid) { data.u = HUGE_VAL; if (!*s && (s > line)) --s; /* assumed we gobbled \n */ if (!bin_out && echoin) { - int t; + char t; t = *s; *s = '\0'; (void)fputs(line, stdout); @@ -440,8 +444,6 @@ int main(int argc, char **argv) { } else proj = pj_fwd; if (cheby_str) { - extern void gen_cheb(int, projUV(*)(projUV), char *, PJ *, int, char **); - gen_cheb(inverse, int_proj, cheby_str, Proj, iargc, iargv); exit(0); }