Skip to content

Commit

Permalink
Raise MSVC warning level to /W4
Browse files Browse the repository at this point in the history
  • Loading branch information
rouault committed Feb 26, 2017
1 parent ac66e57 commit 0cbb3c2
Show file tree
Hide file tree
Showing 19 changed files with 96 additions and 49 deletions.
3 changes: 2 additions & 1 deletion appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion 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
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
11 changes: 7 additions & 4 deletions src/PJ_healpix.c
Original file line number Diff line number Diff line change
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 Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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;
}
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
4 changes: 2 additions & 2 deletions src/PJ_horner.c
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand All @@ -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;
}
Expand Down
18 changes: 16 additions & 2 deletions src/PJ_isea.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -911,16 +921,19 @@ 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);

hex->x = ((int)v.x << 4) + quad;
hex->y = v.y;

return 1;

#ifdef FIXME
d = (int)v.x;
i = (int)v.y;

Expand Down Expand Up @@ -964,6 +977,7 @@ int isea_hex(struct isea_dgg *g, int tri,
}

return 1;
#endif
}

ISEA_STATIC
Expand Down
2 changes: 1 addition & 1 deletion src/PJ_lsat.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion src/PJ_misrsom.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion src/PJ_mod_ster.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/cs2cs.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion src/gen_cheb.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@
/* 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) {
int NU = 15, NV = 15, res = -1, errin = 0, pwr;
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;
Expand Down
2 changes: 1 addition & 1 deletion src/geod.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
2 changes: 1 addition & 1 deletion src/nad2bin.c
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand Down
2 changes: 1 addition & 1 deletion src/nad_init.c
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand Down
5 changes: 5 additions & 0 deletions src/pj_factors.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
26 changes: 25 additions & 1 deletion src/pj_gridinfo.c
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand Down Expand Up @@ -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()" );
Expand Down Expand Up @@ -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()" );
Expand Down Expand Up @@ -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()" );
Expand Down
1 change: 0 additions & 1 deletion src/pj_strerrno.c
Original file line number Diff line number Diff line change
Expand Up @@ -82,5 +82,4 @@ char *pj_strerrno(int err) {
return note;
}
}
return 0;
}
10 changes: 6 additions & 4 deletions src/proj.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 (;;) {
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
}
Expand Down

0 comments on commit 0cbb3c2

Please sign in to comment.