diff options
| author | Even Rouault <even.rouault@spatialys.com> | 2018-05-29 22:45:18 +0200 |
|---|---|---|
| committer | Even Rouault <even.rouault@spatialys.com> | 2018-05-30 11:48:28 +0200 |
| commit | f773897a3025438326c1131e1586d9ddae080c4f (patch) | |
| tree | 989e9619ac1f1ad140298bef5327df3f2d417d92 /src | |
| parent | e692e1567fb6117bd3e1380a80e10b72b7af3710 (diff) | |
| download | PROJ-f773897a3025438326c1131e1586d9ddae080c4f.tar.gz PROJ-f773897a3025438326c1131e1586d9ddae080c4f.zip | |
Fix warnings found by clang with new warning flags to be added in later commit
Fixes consist in:
- no use of comma operator for multi statement purpose
- avoid confusing comma in for loops first and third clauses
- avoid implicit long to int casts by storing to long, or explicit bound checking before cast
Diffstat (limited to 'src')
| -rw-r--r-- | src/PJ_axisswap.c | 4 | ||||
| -rw-r--r-- | src/PJ_horner.c | 8 | ||||
| -rw-r--r-- | src/PJ_isea.c | 18 | ||||
| -rw-r--r-- | src/PJ_pipeline.c | 3 | ||||
| -rw-r--r-- | src/PJ_poly.c | 3 | ||||
| -rw-r--r-- | src/PJ_unitconvert.c | 10 | ||||
| -rw-r--r-- | src/dmstor.c | 8 | ||||
| -rw-r--r-- | src/gen_cheb.c | 14 | ||||
| -rw-r--r-- | src/geodesic.c | 5 | ||||
| -rw-r--r-- | src/geodesic.h | 4 | ||||
| -rw-r--r-- | src/gie.c | 24 | ||||
| -rw-r--r-- | src/mk_cheby.c | 15 | ||||
| -rw-r--r-- | src/nad2bin.c | 3 | ||||
| -rw-r--r-- | src/optargpm.h | 38 | ||||
| -rw-r--r-- | src/pj_internal.c | 10 | ||||
| -rw-r--r-- | src/pj_strtod.c | 1 | ||||
| -rw-r--r-- | src/pj_transform.c | 2 | ||||
| -rw-r--r-- | src/proj_etmerc.c | 15 | ||||
| -rw-r--r-- | src/proj_strtod.c | 8 | ||||
| -rw-r--r-- | src/projects.h | 2 |
20 files changed, 129 insertions, 66 deletions
diff --git a/src/PJ_axisswap.c b/src/PJ_axisswap.c index d31e927e..6db4a7d2 100644 --- a/src/PJ_axisswap.c +++ b/src/PJ_axisswap.c @@ -193,7 +193,9 @@ PJ *CONVERSION(axisswap,0) { } /* read axes numbers and signs */ - for ( s = order, n = 0; *s != '\0' && n < 4; ) { + s = order; + n = 0; + while ( *s != '\0' && n < 4 ) { Q->axis[n] = abs(atoi(s))-1; if (Q->axis[n] > 3) { proj_log_error(P, "axisswap: invalid axis '%d'", Q->axis[n]); diff --git a/src/PJ_horner.c b/src/PJ_horner.c index 09554a7f..a6a26e52 100644 --- a/src/PJ_horner.c +++ b/src/PJ_horner.c @@ -270,8 +270,12 @@ summing the tiny high order elements first. double u, v, N, E; /* Double Horner's scheme: N = n*Cy*e -> yout, E = e*Cx*n -> xout */ - for (N = *--tcy, E = *--tcx; r > 0; r--) { - for (c = g, u = *--tcy, v = *--tcx; c >= r; c--) { + N = *--tcy; + E = *--tcx; + for (; r > 0; r--) { + u = *--tcy; + v = *--tcx; + for (c = g; c >= r; c--) { u = n*u + *--tcy; v = e*v + *--tcx; } diff --git a/src/PJ_isea.c b/src/PJ_isea.c index 3c811a18..4ffd2983 100644 --- a/src/PJ_isea.c +++ b/src/PJ_isea.c @@ -48,7 +48,7 @@ struct hex { int iso; - int x, y, z; + long x, y, z; }; /* y *must* be positive down as the xy /iso conversion assumes this */ @@ -77,7 +77,7 @@ static void hex_iso(struct hex *h) { h->iso = 1; } -static void hexbin2(double width, double x, double y, int *i, int *j) { +static void hexbin2(double width, double x, double y, long *i, long *j) { double z, rx, ry, rz; double abs_dx, abs_dy, abs_dz; long ix, iy, iz, s; @@ -666,7 +666,7 @@ static int isea_dddi_ap3odd(struct isea_dgg *g, int quad, struct isea_pt *pt, struct isea_pt v; double hexwidth; double sidelength; /* in hexes */ - int d, i; + long d, i; long maxcoord; struct hex h; @@ -823,10 +823,10 @@ static int isea_ptdi(struct isea_dgg *g, int tri, struct isea_pt *pt, /* q2di to seqnum */ -static int isea_disn(struct isea_dgg *g, int quad, struct isea_pt *di) { - int sidelength; - int sn, height; - int hexes; +static long isea_disn(struct isea_dgg *g, int quad, struct isea_pt *di) { + long sidelength; + long sn, height; + long hexes; if (quad == 0) { g->serial = 1; @@ -840,8 +840,8 @@ static int isea_disn(struct isea_dgg *g, int quad, struct isea_pt *di) { } if (g->aperture == 3 && g->resolution % 2 == 1) { height = lround(floor((pow(g->aperture, (g->resolution - 1) / 2.0)))); - sn = ((int) di->x) * height; - sn += ((int) di->y) / height; + sn = ((long)di->x) * height; + sn += ((long)di->y) / height; sn += (quad - 1) * hexes; sn += 2; } else { diff --git a/src/PJ_pipeline.c b/src/PJ_pipeline.c index d623423b..618d4688 100644 --- a/src/PJ_pipeline.c +++ b/src/PJ_pipeline.c @@ -400,7 +400,8 @@ PJ *OPERATION(pipeline,0) { set_ellipsoid(P); /* Now loop over all steps, building a new set of arguments for each init */ - for (i_current_step = i_first_step, i = 0; i < nsteps; i++) { + i_current_step = i_first_step; + for (i = 0; i < nsteps; i++) { int j; int current_argc = 0; int err; diff --git a/src/PJ_poly.c b/src/PJ_poly.c index 03fa84a4..b5f78fdf 100644 --- a/src/PJ_poly.c +++ b/src/PJ_poly.c @@ -71,7 +71,8 @@ static LP e_inverse (XY xy, PJ *P) { /* Ellipsoidal, inverse */ int i; r = xy.y * xy.y + xy.x * xy.x; - for (lp.phi = xy.y, i = I_ITER; i ; --i) { + lp.phi = xy.y; + for (i = I_ITER; i ; --i) { sp = sin(lp.phi); s2ph = sp * ( cp = cos(lp.phi)); if (fabs(cp) < ITOL) { diff --git a/src/PJ_unitconvert.c b/src/PJ_unitconvert.c index a3051ad7..25bdc2e7 100644 --- a/src/PJ_unitconvert.c +++ b/src/PJ_unitconvert.c @@ -94,20 +94,20 @@ struct pj_opaque_unitconvert { /***********************************************************************/ -static int is_leap_year(int year) { +static int is_leap_year(long year) { /***********************************************************************/ return ((year % 4 == 0 && year % 100 != 0) || year % 400 ==0); } /***********************************************************************/ -static int days_in_year(int year) { +static int days_in_year(long year) { /***********************************************************************/ return is_leap_year(year) ? 366 : 365; } /***********************************************************************/ -static unsigned int days_in_month(unsigned int year, unsigned int month) { +static unsigned int days_in_month(unsigned long year, unsigned long month) { /***********************************************************************/ const unsigned int month_table[] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; unsigned int days; @@ -123,7 +123,7 @@ static unsigned int days_in_month(unsigned int year, unsigned int month) { /***********************************************************************/ -static int daynumber_in_year(unsigned int year, unsigned int month, unsigned int day) { +static int daynumber_in_year(unsigned long year, unsigned long month, unsigned long day) { /***********************************************************************/ unsigned int daynumber=0, i; @@ -167,7 +167,7 @@ static double decimalyear_to_mjd(double decimalyear) { year = lround(floor(decimalyear)); fractional_year = decimalyear - year; mjd = (year - 1859)*365 + 14 + 31; - mjd += fractional_year*days_in_year(year); + mjd += (double)fractional_year*(double)days_in_year(year); /* take care of leap days */ year--; diff --git a/src/dmstor.c b/src/dmstor.c index d3496cd9..ab8e33f4 100644 --- a/src/dmstor.c +++ b/src/dmstor.c @@ -34,7 +34,10 @@ dmstor_ctx(projCtx ctx, const char *is, char **rs) { *rs = (char *)is; /* copy sting into work space */ while (isspace(sign = *is)) ++is; - for (n = MAX_WORK, s = work, p = (char *)is; isgraph(*p) && --n ; ) + n = MAX_WORK; + s = work; + p = (char *)is; + while (isgraph(*p) && --n) *s++ = *p++; *s = '\0'; /* it is possible that a really odd input (like lots of leading @@ -42,7 +45,8 @@ dmstor_ctx(projCtx ctx, const char *is, char **rs) { sign = *(s = work); if (sign == '+' || sign == '-') s++; else sign = '+'; - for (v = 0., nl = 0 ; nl < 3 ; nl = n + 1 ) { + v = 0.; + for (nl = 0 ; nl < 3 ; nl = n + 1 ) { if (!(isdigit(*s) || *s == '.')) break; if ((tv = proj_strtod(s, &s)) == HUGE_VAL) return tv; diff --git a/src/gen_cheb.c b/src/gen_cheb.c index 351d9604..ab16b409 100644 --- a/src/gen_cheb.c +++ b/src/gen_cheb.c @@ -16,8 +16,10 @@ 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]; + long NU = 15, NV = 15; + int errin = 0, pwr; + long res = -1; + char *arg, fmt[32]; projUV low, upp, resid; Tseries *F; double (*input)(const char *, char **); @@ -54,10 +56,10 @@ void gen_cheb(int inverse, projUV (*proj)(projUV), char *s, PJ *P, emess(16,"approx. argument range error"); if (low.u > upp.u) low.u -= M_TWOPI; - if (NU < 2 || NV < 2) - emess(16,"approx. work dimensions (%d %d) too small",NU,NV); + if (NU < 2 || NV < 2 || NU > INT_MAX || NV > INT_MAX) + emess(16,"approx. work dimensions (%ld %ld) too small or large",NU,NV); if (!(F = mk_cheby(low, upp, pow(10., (double)res)*.5, &resid, proj, - NU, NV, pwr))) + (int)NU, (int)NV, pwr))) emess(16,"generation of approx failed\nreason: %s\n", pj_strerrno(errno)); (void)printf("%c,%.12g,%.12g,%.12g,%.12g,%.12g\n",inverse?'I':'F', @@ -67,7 +69,7 @@ void gen_cheb(int inverse, projUV (*proj)(projUV), char *s, PJ *P, if (pwr) strcpy(fmt, "%.15g"); else if (res <= 0) - (void)sprintf(fmt,"%%.%df",-res+1); + (void)sprintf(fmt,"%%.%ldf",-res+1); else (void)strcpy(fmt,"%.0f"); p_series(F, stdout, fmt); diff --git a/src/geodesic.c b/src/geodesic.c index 3fcfd1c9..220dcd7f 100644 --- a/src/geodesic.c +++ b/src/geodesic.c @@ -932,8 +932,9 @@ static real geod_geninverse_int(const struct geod_geodesic* g, unsigned numit = 0; /* Bracketing range */ real salp1a = tiny, calp1a = 1, salp1b = tiny, calp1b = -1; - boolx tripn, tripb; - for (tripn = FALSE, tripb = FALSE; numit < maxit2; ++numit) { + boolx tripn = FALSE; + boolx tripb = FALSE; + for (; numit < maxit2; ++numit) { /* the WGS84 test set: mean = 1.47, sd = 1.25, max = 16 * WGS84 and random input: mean = 2.85, sd = 0.60 */ real dv = 0, diff --git a/src/geodesic.h b/src/geodesic.h index f9d612f3..0e18af5a 100644 --- a/src/geodesic.h +++ b/src/geodesic.h @@ -633,7 +633,7 @@ extern "C" { /** * Specify position of point 3 in terms of distance. * - * @param[inout] l a pointer to the geod_geodesicline object. + * @param[in,out] l a pointer to the geod_geodesicline object. * @param[in] s13 the distance from point 1 to point 3 (meters); it * can be negative. * @@ -645,7 +645,7 @@ extern "C" { /** * Specify position of point 3 in terms of either distance or arc length. * - * @param[inout] l a pointer to the geod_geodesicline object. + * @param[in,out] l a pointer to the geod_geodesicline object. * @param[in] flags either GEOD_NOFLAGS or GEOD_ARCMODE to determining the * meaning of the \e s13_a13. * @param[in] s13_a13 if \e flags = GEOD_NOFLAGS, this is the distance @@ -386,8 +386,11 @@ static int process_file (const char *fname) { T.op_ko = T.total_ko = 0; T.op_skip = T.total_skip = 0; - if (T.skip) - return proj_destroy (T.P), T.P = 0, 0; + if (T.skip) { + proj_destroy (T.P); + T.P = 0; + return 0; + } f = fopen (fname, "rt"); if (0==f) { @@ -404,8 +407,11 @@ static int process_file (const char *fname) { T.curr_file = fname; while (get_inp(F)) { - if (SKIP==dispatch (F->tag, F->args)) - return proj_destroy (T.P), T.P = 0, 0; + if (SKIP==dispatch (F->tag, F->args)) { + proj_destroy (T.P); + T.P = 0; + return 0; + } } fclose (f); @@ -639,7 +645,8 @@ static PJ_COORD torad_coord (PJ *P, PJ_DIRECTION dir, PJ_COORD a) { paralist *l = pj_param_exists (P->params, "axis"); if (l && dir==PJ_INV) axis = l->param + strlen ("axis="); - for (i = 0, n = strlen (axis); i < n; i++) + n = strlen (axis); + for (i = 0; i < n; i++) if (strchr ("news", axis[i])) a.v[i] = proj_torad (a.v[i]); return a; @@ -652,7 +659,8 @@ static PJ_COORD todeg_coord (PJ *P, PJ_DIRECTION dir, PJ_COORD a) { paralist *l = pj_param_exists (P->params, "axis"); if (l && dir==PJ_FWD) axis = l->param + strlen ("axis="); - for (i = 0, n = strlen (axis); i < n; i++) + n = strlen (axis); + for (i = 0; i < n; i++) if (strchr ("news", axis[i])) a.v[i] = proj_todeg (a.v[i]); return a; @@ -669,7 +677,8 @@ Attempt to interpret args as a PJ_COORD. const char *endp, *prev = args; PJ_COORD a = proj_coord (0,0,0,0); - for (i = 0, T.dimensions_given = 0; i < 4; i++, T.dimensions_given++) { + T.dimensions_given = 0; + for (i = 0; i < 4; i++) { double d = proj_strtod (prev, (char **) &endp); /* Break out if there were no more numerals */ @@ -678,6 +687,7 @@ Attempt to interpret args as a PJ_COORD. a.v[i] = d; prev = endp; + T.dimensions_given++; } return a; diff --git a/src/mk_cheby.c b/src/mk_cheby.c index 3dbc3096..a2f90bef 100644 --- a/src/mk_cheby.c +++ b/src/mk_cheby.c @@ -6,13 +6,16 @@ eval(projUV **w, int nu, int nv, double res, projUV *resid) { projUV *s; resid->u = resid->v = 0.; - for (i = 0; i < nu; ++i) - for (s = w[i], j = 0; j < nv; ++j, ++s) { + for (i = 0; i < nu; ++i) { + s = w[i]; + for (j = 0; j < nv; ++j) { if ((ab = fabs(s->u)) < res) resid->u += ab; if ((ab = fabs(s->v)) < res) resid->v += ab; + ++s; } + } } static Tseries * /* create power series structure */ makeT(int nru, int nrv) { @@ -70,7 +73,8 @@ mk_cheby(projUV a, projUV b, double res, projUV *resid, projUV (*func)(projUV), nru = nrv = 0; for (j = 0; j < nu; ++j) { ncu[j] = ncv[j] = 0; /* clear column maxes */ - for (s = w[j], i = 0; i < nv; ++i, ++s) { + s = w[j]; + for (i = 0; i < nv; ++i) { if ((ab = fabs(s->u)) < cutres) /* < resolution ? */ s->u = 0.; /* clear coefficient */ else @@ -79,6 +83,7 @@ mk_cheby(projUV a, projUV b, double res, projUV *resid, projUV (*func)(projUV), s->v = 0.; else ncv[j] = i + 1; + ++s; } if (ncu[j]) nru = j + 1; /* update row max */ if (ncv[j]) nrv = j + 1; @@ -90,11 +95,13 @@ mk_cheby(projUV a, projUV b, double res, projUV *resid, projUV (*func)(projUV), nru = nrv = 0; for (j = 0; j < nu; ++j) { ncu[j] = ncv[j] = 0; /* clear column maxes */ - for (s = w[j], i = 0; i < nv; ++i, ++s) { + s = w[j]; + for (i = 0; i < nv; ++i) { if (s->u != 0.0) ncu[j] = i + 1; /* update column max */ if (s->v != 0.0) ncv[j] = i + 1; + ++s; } if (ncu[j]) nru = j + 1; /* update row max */ if (ncv[j]) nrv = j + 1; diff --git a/src/nad2bin.c b/src/nad2bin.c index dfc4e2dd..eb8672a5 100644 --- a/src/nad2bin.c +++ b/src/nad2bin.c @@ -119,7 +119,8 @@ int main(int argc, char **argv) { ct.del.lam *= DEG_TO_RAD; ct.del.phi *= DEG_TO_RAD; /* load table */ - for (p = ct.cvs, i = 0; i < ct.lim.phi; ++i) { + p = ct.cvs; + for (i = 0; i < ct.lim.phi; ++i) { /* cppcheck-suppress invalidscanf */ if ( EOF == scanf("%d:%ld %ld", &ichk, &laml, &phil) ) { perror("scanf on row"); diff --git a/src/optargpm.h b/src/optargpm.h index 8a9dd0c7..48cb260b 100644 --- a/src/optargpm.h +++ b/src/optargpm.h @@ -524,29 +524,37 @@ OPTARGS *opt_parse (int argc, char **argv, const char *flags, const char *keys, if (equals) *equals = 0; c = opt_ordinal (o, crepr); - if (0==c) - return fprintf (stderr, "Invalid option \"%s\"\n", crepr), (OPTARGS *) 0; + if (0==c) { + fprintf (stderr, "Invalid option \"%s\"\n", crepr); + return (OPTARGS *) 0; + } /* inline (gnu) --foo=bar style arg */ if (equals) { *equals = '='; - if (opt_is_flag (o, c)) - return fprintf (stderr, "Option \"%s\" takes no arguments\n", crepr), (OPTARGS *) 0; + if (opt_is_flag (o, c)) { + fprintf (stderr, "Option \"%s\" takes no arguments\n", crepr); + return (OPTARGS *) 0; + } o->optarg[c] = equals + 1; break; } /* "outline" --foo bar style arg */ if (!opt_is_flag (o, c)) { - if ((argc==i + 1) || ('+'==argv[i+1][0]) || ('-'==argv[i+1][0])) - return fprintf (stderr, "Missing argument for option \"%s\"\n", crepr), (OPTARGS *) 0; + if ((argc==i + 1) || ('+'==argv[i+1][0]) || ('-'==argv[i+1][0])) { + fprintf (stderr, "Missing argument for option \"%s\"\n", crepr); + return (OPTARGS *) 0; + } o->optarg[c] = argv[i + 1]; i++; /* eat the arg */ break; } - if (!opt_is_flag (o, c)) - return fprintf (stderr, "Expected flag style long option here, but got \"%s\"\n", crepr), (OPTARGS *) 0; + if (!opt_is_flag (o, c)) { + fprintf (stderr, "Expected flag style long option here, but got \"%s\"\n", crepr); + return (OPTARGS *) 0; + } /* Flag style option, i.e. taking no arguments */ opt_raise_flag (o, c); @@ -554,8 +562,10 @@ OPTARGS *opt_parse (int argc, char **argv, const char *flags, const char *keys, } /* classic short options */ - if (0==o->optarg[c]) - return fprintf (stderr, "Invalid option \"%s\"\n", crepr), (OPTARGS *) 0; + if (0==o->optarg[c]) { + fprintf (stderr, "Invalid option \"%s\"\n", crepr); + return (OPTARGS *) 0; + } /* Flag style option, i.e. taking no arguments */ if (opt_is_flag (o, c)) { @@ -568,7 +578,10 @@ OPTARGS *opt_parse (int argc, char **argv, const char *flags, const char *keys, /* argument separate (i.e. "-i 10") */ if (j + 1==arg_group_size) { if ((argc==i + 1) || ('+'==argv[i+1][0]) || ('-'==argv[i+1][0])) - return fprintf (stderr, "Bad or missing arg for option \"%s\"\n", crepr), (OPTARGS *) 0; + { + fprintf (stderr, "Bad or missing arg for option \"%s\"\n", crepr); + return (OPTARGS *) 0; + } o->optarg[(int) c] = argv[i + 1]; i++; break; @@ -584,7 +597,8 @@ OPTARGS *opt_parse (int argc, char **argv, const char *flags, const char *keys, o->pargv = argv + i; /* Is free format in use, instead of plus-style? */ - for (free_format = 0, j = 1; j < argc; j++) { + free_format = 0; + for (j = 1; j < argc; j++) { if (0==strcmp ("--", argv[j])) { free_format = j; break; diff --git a/src/pj_internal.c b/src/pj_internal.c index 58ea9b48..7eb917be 100644 --- a/src/pj_internal.c +++ b/src/pj_internal.c @@ -209,7 +209,9 @@ consuming their surrounding whitespace. n = strlen (c); /* First collapse repeated whitespace (including +/;) */ - for (i = j = 0, ws = 0; j < n; j++) { + i = 0; + ws = 0; + for (j = 0; j < n; j++) { /* Eliminate prefix '+', only if preceded by whitespace */ /* (i.e. keep it in 1.23e+08) */ @@ -233,7 +235,8 @@ consuming their surrounding whitespace. n = strlen(c); /* Then make ',' and '=' greedy */ - for (i = j = 0; j < n; j++) { + i = 0; + for (j = 0; j < n; j++) { if (i==0) { c[i++] = c[j]; continue; @@ -311,7 +314,8 @@ It is the duty of the caller to free this array. if (0==argv) return 0; argv[0] = args; - for (i = 0, j = 1; ; i++) { + j = 1; + for (i = 0; ; i++) { if (0==args[i]) { argv[j++] = args + (i + 1); } diff --git a/src/pj_strtod.c b/src/pj_strtod.c index 45159d11..f604a013 100644 --- a/src/pj_strtod.c +++ b/src/pj_strtod.c @@ -164,7 +164,6 @@ static char* replace_point_by_locale_point(const char* pszNumber, char point, * @param endptr If is not NULL, a pointer to the character after the last * character used in the conversion is stored in the location referenced * by endptr. - * @param point Decimal delimiter. * * @return Converted value. */ diff --git a/src/pj_transform.c b/src/pj_transform.c index 5863b39e..93094f01 100644 --- a/src/pj_transform.c +++ b/src/pj_transform.c @@ -835,7 +835,7 @@ int pj_datum_transform( PJ *src, PJ *dst, /* -------------------------------------------------------------------- */ if( z == NULL ) { - int bytes = sizeof(double) * point_count * point_offset; + size_t bytes = sizeof(double) * point_count * point_offset; z = (double *) pj_malloc(bytes); memset( z, 0, bytes ); z_is_temp = TRUE; diff --git a/src/proj_etmerc.c b/src/proj_etmerc.c index 457edcb8..4d7187e6 100644 --- a/src/proj_etmerc.c +++ b/src/proj_etmerc.c @@ -71,8 +71,13 @@ static double gatg(double *p1, int len_p1, double B) { double h = 0, h1, h2 = 0, cos_2B; cos_2B = 2*cos(2*B); - for (p = p1 + len_p1, h1 = *--p; p - p1; h2 = h1, h1 = h) + p = p1 + len_p1; + h1 = *--p; + while (p - p1) { h = -h2 + cos_2B*h1 + *--p; + h2 = h1; + h1 = h; + } return (B + h*sin(2*B)); } @@ -98,7 +103,9 @@ static double clenS(double *a, int size, double arg_r, double arg_i, double *R, i = -2*sin_arg_r*sinh_arg_i; /* summation loop */ - for (hi1 = hr1 = hi = 0, hr = *--p; a - p;) { + hi1 = hr1 = hi = 0; + hr = *--p; + for (; a - p;) { hr2 = hr1; hi2 = hi1; hr1 = hr; @@ -124,7 +131,9 @@ static double clens(double *a, int size, double arg_r) { r = 2*cos_arg_r; /* summation loop */ - for (hr1 = 0, hr = *--p; a - p;) { + hr1 = 0; + hr = *--p; + for (; a - p;) { hr2 = hr1; hr1 = hr; hr = -hr2 + r*hr1 + *--p; diff --git a/src/proj_strtod.c b/src/proj_strtod.c index ad197d2a..a3bc7d40 100644 --- a/src/proj_strtod.c +++ b/src/proj_strtod.c @@ -134,9 +134,13 @@ double proj_strtod(const char *str, char **endptr) { /* Then handle optional prefixed sign and skip prefix zeros */ switch (*p) { case '-': - sign = -1, p++; break; + sign = -1; + p++; + break; case '+': - sign = 1, p++; break; + sign = 1; + p++; + break; default: if (isdigit(*p) || '_'==*p || '.'==*p) break; diff --git a/src/projects.h b/src/projects.h index d6d6e23e..5b923813 100644 --- a/src/projects.h +++ b/src/projects.h @@ -684,7 +684,7 @@ typedef struct _pj_gi { const char *format; /* format of this grid, ie "ctable", "ntv1", "ntv2" or "missing". */ - int grid_offset; /* offset in file, for delayed loading */ + long grid_offset; /* offset in file, for delayed loading */ int must_swap; /* only for NTv2 */ struct CTABLE *ct; |
