Skip to content

Commit

Permalink
Merge pull request #495 from rouault/misc_warning_fixes
Browse files Browse the repository at this point in the history
Fix warnings related to -Wshadow -Wnull-dereference -Wfloat-conversion -Wmissing-prototypes -Wmissing-declarations
  • Loading branch information
rouault committed Feb 27, 2017
2 parents d64a550 + 0cbb3c2 commit b36451f
Show file tree
Hide file tree
Showing 66 changed files with 371 additions and 258 deletions.
7 changes: 4 additions & 3 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ platform:
environment:
matrix:

- BUILD_TYPE: nmake

# Does not work
# VS 2008
# - BUILD_TYPE: cmake
Expand All @@ -24,6 +22,8 @@ environment:
- BUILD_TYPE: cmake
VS_VERSION: Visual Studio 12

- BUILD_TYPE: nmake

shallow_clone: true

build_script:
Expand All @@ -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
# 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:
Expand Down
3 changes: 3 additions & 0 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions src/PJ_aeqd.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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 {
Expand Down
4 changes: 2 additions & 2 deletions src/PJ_aitoff.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/PJ_bipc.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion src/PJ_bonne.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion src/PJ_calcofi.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down
2 changes: 1 addition & 1 deletion src/PJ_cea.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions src/PJ_chamb.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion src/PJ_fouc_s.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 ) /
Expand Down
4 changes: 2 additions & 2 deletions src/PJ_geos.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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;
Expand Down
6 changes: 3 additions & 3 deletions src/PJ_gn_sinu.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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 {
Expand Down
26 changes: 15 additions & 11 deletions src/PJ_healpix.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -141,7 +141,6 @@ static int pnpoly(int nvert, double vert[][2], double testx, double testy) {
} else {
return 1;
}
return c;
}


Expand All @@ -152,7 +151,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},
Expand Down Expand Up @@ -223,7 +223,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. */
Expand All @@ -247,7 +247,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);
Expand Down Expand Up @@ -275,7 +275,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;
Expand Down Expand Up @@ -516,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;
}
Expand Down Expand Up @@ -562,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;
}
Expand Down Expand Up @@ -614,7 +618,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. */
Expand Down Expand Up @@ -646,7 +650,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. */
Expand Down
47 changes: 23 additions & 24 deletions src/PJ_helmert.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) */
Expand All @@ -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
Expand Down Expand Up @@ -417,8 +418,6 @@ PJ *PROJECTION(helmert) {
trp->scale = 1.0 + scale;
*/

} while (0);


if (transpose) {
double r;
Expand Down
Loading

0 comments on commit b36451f

Please sign in to comment.