diff options
| author | Elliott Sales de Andrade <quantum.analyst@gmail.com> | 2015-05-31 02:02:18 -0400 |
|---|---|---|
| committer | Elliott Sales de Andrade <quantum.analyst@gmail.com> | 2015-06-20 18:44:49 -0400 |
| commit | e048c9f807df1d804c20089ca3c66bdb22296a66 (patch) | |
| tree | 67bee70cc5090edd2ab9e8e0fca94592f6a59637 /src | |
| parent | 0c1ec3aa94732738690756b5a122a75f47706ff2 (diff) | |
| download | PROJ-e048c9f807df1d804c20089ca3c66bdb22296a66.tar.gz PROJ-e048c9f807df1d804c20089ca3c66bdb22296a66.zip | |
Fix possibly-uninitialized variable warnings.
Some of these should be false positives, but I re-wrote them anyway
because they were unclear.
Diffstat (limited to 'src')
| -rw-r--r-- | src/PJ_cea.c | 9 | ||||
| -rw-r--r-- | src/PJ_qsc.c | 72 | ||||
| -rw-r--r-- | src/geod_set.c | 10 | ||||
| -rw-r--r-- | src/pj_ell_set.c | 7 | ||||
| -rw-r--r-- | src/pj_init.c | 10 |
5 files changed, 58 insertions, 50 deletions
diff --git a/src/PJ_cea.c b/src/PJ_cea.c index f5b78838..aa544db6 100644 --- a/src/PJ_cea.c +++ b/src/PJ_cea.c @@ -42,9 +42,12 @@ FREEUP; ENTRY1(cea, apa) double t; - if (pj_param(P->ctx, P->params, "tlat_ts").i && - (P->k0 = cos(t = pj_param(P->ctx, P->params, "rlat_ts").f)) < 0.) - E_ERROR(-24); + if (pj_param(P->ctx, P->params, "tlat_ts").i) { + P->k0 = cos(t = pj_param(P->ctx, P->params, "rlat_ts").f); + if (P->k0 < 0.) { + E_ERROR(-24); + } + } if (P->es) { t = sin(t); P->k0 /= sqrt(1. - P->es * t * t); diff --git a/src/PJ_qsc.c b/src/PJ_qsc.c index cb91e86a..12cb9d63 100644 --- a/src/PJ_qsc.c +++ b/src/PJ_qsc.c @@ -105,9 +105,6 @@ qsc_shift_lon_origin(double lon, double offset) { /* Forward projection, ellipsoid */ FORWARD(e_forward); double lat, lon; - double sinlat, coslat; - double sinlon, coslon; - double q, r, s; double theta, phi; double t, mu; /* nu; */ int area; @@ -127,35 +124,7 @@ FORWARD(e_forward); * directly from phi, lam. For the other faces, we must use * unit sphere cartesian coordinates as an intermediate step. */ lon = lp.lam; - if (P->face != FACE_TOP && P->face != FACE_BOTTOM) { - if (P->face == FACE_RIGHT) { - lon = qsc_shift_lon_origin(lon, +HALFPI); - } else if (P->face == FACE_BACK) { - lon = qsc_shift_lon_origin(lon, +PI); - } else if (P->face == FACE_LEFT) { - lon = qsc_shift_lon_origin(lon, -HALFPI); - } - sinlat = sin(lat); - coslat = cos(lat); - sinlon = sin(lon); - coslon = cos(lon); - q = coslat * coslon; - r = coslat * sinlon; - s = sinlat; - } - if (P->face == FACE_FRONT) { - phi = acos(q); - theta = qsc_fwd_equat_face_theta(phi, s, r, &area); - } else if (P->face == FACE_RIGHT) { - phi = acos(r); - theta = qsc_fwd_equat_face_theta(phi, s, -q, &area); - } else if (P->face == FACE_BACK) { - phi = acos(-q); - theta = qsc_fwd_equat_face_theta(phi, s, -r, &area); - } else if (P->face == FACE_LEFT) { - phi = acos(-r); - theta = qsc_fwd_equat_face_theta(phi, s, q, &area); - } else if (P->face == FACE_TOP) { + if (P->face == FACE_TOP) { phi = HALFPI - lat; if (lon >= FORTPI && lon <= HALFPI + FORTPI) { area = AREA_0; @@ -170,7 +139,7 @@ FORWARD(e_forward); area = AREA_3; theta = lon; } - } else /* P->face == FACE_BOTTOM */ { + } else if (P->face == FACE_BOTTOM) { phi = HALFPI + lat; if (lon >= FORTPI && lon <= HALFPI + FORTPI) { area = AREA_0; @@ -185,6 +154,43 @@ FORWARD(e_forward); area = AREA_3; theta = (lon > 0.0 ? -lon + PI : -lon - PI); } + } else { + double q, r, s; + double sinlat, coslat; + double sinlon, coslon; + + if (P->face == FACE_RIGHT) { + lon = qsc_shift_lon_origin(lon, +HALFPI); + } else if (P->face == FACE_BACK) { + lon = qsc_shift_lon_origin(lon, +PI); + } else if (P->face == FACE_LEFT) { + lon = qsc_shift_lon_origin(lon, -HALFPI); + } + sinlat = sin(lat); + coslat = cos(lat); + sinlon = sin(lon); + coslon = cos(lon); + q = coslat * coslon; + r = coslat * sinlon; + s = sinlat; + + if (P->face == FACE_FRONT) { + phi = acos(q); + theta = qsc_fwd_equat_face_theta(phi, s, r, &area); + } else if (P->face == FACE_RIGHT) { + phi = acos(r); + theta = qsc_fwd_equat_face_theta(phi, s, -q, &area); + } else if (P->face == FACE_BACK) { + phi = acos(-q); + theta = qsc_fwd_equat_face_theta(phi, s, -r, &area); + } else if (P->face == FACE_LEFT) { + phi = acos(-r); + theta = qsc_fwd_equat_face_theta(phi, s, q, &area); + } else { + /* Impossible */ + phi = theta = 0.0; + area = AREA_0; + } } /* Compute mu and nu for the area of definition. diff --git a/src/geod_set.c b/src/geod_set.c index eaadce52..e687c512 100644 --- a/src/geod_set.c +++ b/src/geod_set.c @@ -15,11 +15,11 @@ geod_set(int argc, char **argv) { /* put arguments into internal linked list */ if (argc <= 0) emess(1, "no arguments in initialization list"); - for (i = 0; i < argc; ++i) - if (i) - curr = curr->next = pj_mkparam(argv[i]); - else - start = curr = pj_mkparam(argv[i]); + start = curr = pj_mkparam(argv[0]); + for (i = 1; i < argc; ++i) { + curr->next = pj_mkparam(argv[i]); + curr = curr->next; + } /* set elliptical parameters */ if (pj_ell_set(pj_get_default_ctx(),start, &geod_a, &es)) emess(1,"ellipse setup failure"); /* set units */ diff --git a/src/pj_ell_set.c b/src/pj_ell_set.c index 857bd78c..af825bed 100644 --- a/src/pj_ell_set.c +++ b/src/pj_ell_set.c @@ -11,7 +11,7 @@ pj_ell_set(projCtx ctx, paralist *pl, double *a, double *es) { int i; double b=0.0, e; char *name; - paralist *start = 0, *curr; + paralist *start = 0; /* clear any previous error */ pj_ctx_set_errno(ctx,0); @@ -28,11 +28,10 @@ pj_ell_set(projCtx ctx, paralist *pl, double *a, double *es) { char *s; for (start = pl; start && start->next ; start = start->next) ; - curr = start; for (i = 0; (s = pj_ellps[i].id) && strcmp(name, s) ; ++i) ; if (!s) { pj_ctx_set_errno( ctx, -9); return 1; } - curr = curr->next = pj_mkparam(pj_ellps[i].major); - curr = curr->next = pj_mkparam(pj_ellps[i].ell); + start->next = pj_mkparam(pj_ellps[i].major); + start->next->next = pj_mkparam(pj_ellps[i].ell); } *a = pj_param(ctx,pl, "da").f; if (pj_param(ctx,pl, "tes").i) /* eccentricity squared */ diff --git a/src/pj_init.c b/src/pj_init.c index 88f4a28c..b45a5054 100644 --- a/src/pj_init.c +++ b/src/pj_init.c @@ -409,11 +409,11 @@ pj_init_ctx(projCtx ctx, int argc, char **argv) { /* put arguments into internal linked list */ if (argc <= 0) { pj_ctx_set_errno( ctx, -1 ); goto bum_call; } - for (i = 0; i < argc; ++i) - if (i) - curr = curr->next = pj_mkparam(argv[i]); - else - start = curr = pj_mkparam(argv[i]); + start = curr = pj_mkparam(argv[0]); + for (i = 1; i < argc; ++i) { + curr->next = pj_mkparam(argv[i]); + curr = curr->next; + } if (ctx->last_errno) goto bum_call; /* check if +init present */ |
