diff options
| -rw-r--r-- | configure.ac | 4 | ||||
| -rw-r--r-- | src/geodesic.c | 48 |
2 files changed, 30 insertions, 22 deletions
diff --git a/configure.ac b/configure.ac index 9e4fa3d3..ee5fc507 100644 --- a/configure.ac +++ b/configure.ac @@ -33,8 +33,8 @@ dnl Check flag for accurate arithmetic with Intel compiler. This is dnl needed to stop the compiler from ignoring parentheses in expressions dnl like (a + b) + c and from simplifying 0.0 + x to x (which is wrong if dnl x = -0.0). -AX_CHECK_COMPILE_FLAG([-Werror -fprotect-parens -fsigned-zeros], - [CFLAGS="$CFLAGS -fprotect-parens -fsigned-zeros"]) +AX_CHECK_COMPILE_FLAG([-fprotect-parens -fsigned-zeros], + [CFLAGS="$CFLAGS -fprotect-parens -fsigned-zeros"],,[-Werror]) dnl Check for C99 math functions save_CFLAGS="$CFLAGS" CFLAGS="$CFLAGS -Wall -Werror" diff --git a/src/geodesic.c b/src/geodesic.c index fc0b5aea..91af23f9 100644 --- a/src/geodesic.c +++ b/src/geodesic.c @@ -193,12 +193,12 @@ static real AngNormalize(real x) { real y = fmod(x, (real)(360)); #if defined(_MSC_VER) && _MSC_VER < 1900 /* - Before version 14 (2015), Visual Studio had problems dealing - with -0.0. Specifically - VC 10,11,12 and 32-bit compile: fmod(-0.0, 360.0) -> +0.0 - sincosdx has a similar fix. - python 2.7 on Windows 32-bit machines has the same problem. - */ + * Before version 14 (2015), Visual Studio had problems dealing + * with -0.0. Specifically + * VC 10,11,12 and 32-bit compile: fmod(-0.0, 360.0) -> +0.0 + * sincosdx has a similar fix. + * python 2.7 on Windows 32-bit machines has the same problem. + */ if (x == 0) y = x; #endif return y <= -180 ? y + 360 : (y <= 180 ? y : y - 360); @@ -249,13 +249,13 @@ static void sincosdx(real x, real* sinx, real* cosx) { s = sin(r); c = cos(r); #if defined(_MSC_VER) && _MSC_VER < 1900 /* - Before version 14 (2015), Visual Studio had problems dealing - with -0.0. Specifically - VC 10,11,12 and 32-bit compile: fmod(-0.0, 360.0) -> +0.0 - VC 12 and 64-bit compile: sin(-0.0) -> +0.0 - AngNormalize has a similar fix. - python 2.7 on Windows 32-bit machines has the same problem. - */ + * Before version 14 (2015), Visual Studio had problems dealing + * with -0.0. Specifically + * VC 10,11,12 and 32-bit compile: fmod(-0.0, 360.0) -> +0.0 + * VC 12 and 64-bit compile: sin(-0.0) -> +0.0 + * AngNormalize has a similar fix. + * python 2.7 on Windows 32-bit machines has the same problem. + */ if (x == 0) s = x; #endif switch ((unsigned)q & 3U) { @@ -659,21 +659,29 @@ real geod_genposition(const struct geod_geodesicline* l, S12 = l->c2 * atan2(salp12, calp12) + l->A4 * (B42 - l->B41); } - if ((outmask & GEOD_LATITUDE) && plat2) /* plat2 check redundant */ + /* In the pattern + * + * if ((outmask & GEOD_XX) && pYY) + * *pYY = YY; + * + * the second check "&& pYY" is redundant. It's there to make the CLang + * static analyzer happy. + */ + if ((outmask & GEOD_LATITUDE) && plat2) *plat2 = lat2; - if ((outmask & GEOD_LONGITUDE) && plon2) /* plon2 check redundant */ + if ((outmask & GEOD_LONGITUDE) && plon2) *plon2 = lon2; - if ((outmask & GEOD_AZIMUTH) && pazi2) /* pazi2 check redundant */ + if ((outmask & GEOD_AZIMUTH) && pazi2) *pazi2 = azi2; - if ((outmask & GEOD_DISTANCE) && ps12) /* ps12 check redundant */ + if ((outmask & GEOD_DISTANCE) && ps12) *ps12 = s12; - if ((outmask & GEOD_REDUCEDLENGTH) && pm12) /* pm12 check redundant */ + if ((outmask & GEOD_REDUCEDLENGTH) && pm12) *pm12 = m12; if (outmask & GEOD_GEODESICSCALE) { if (pM12) *pM12 = M12; if (pM21) *pM21 = M21; } - if ((outmask & GEOD_AREA) && pS12) /* pS12 check redundant */ + if ((outmask & GEOD_AREA) && pS12) *pS12 = S12; return (flags & GEOD_ARCMODE) ? s12_a12 : sig12 / degree; @@ -1896,7 +1904,7 @@ void geod_polygon_addedge(const struct geod_geodesic* g, real azi, real s) { if (p->num) { /* Do nothing is num is zero */ /* Initialize S12 to stop Visual Studio warning. Initialization of lat and - lon is to make CLang static analyzer happy. */ + * lon is to make CLang static analyzer happy. */ real lat = 0, lon = 0, S12 = 0; geod_gendirect(g, p->lat, p->lon, azi, GEOD_LONG_UNROLL, s, &lat, &lon, 0, |
