From db2ee653fe355c8fd3c07a2d895db69c3161196b Mon Sep 17 00:00:00 2001 From: Joaquim Date: Thu, 5 Sep 2024 20:09:48 +0100 Subject: [PATCH] Initialize variables reported in the Lint Checker report (#8578) --- src/gmt_io.c | 16 ++++++++-------- src/gmt_map.c | 4 ++-- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/gmt_io.c b/src/gmt_io.c index 92077590d53..a7538f59ca4 100644 --- a/src/gmt_io.c +++ b/src/gmt_io.c @@ -1372,21 +1372,21 @@ GMT_LOCAL int gmtio_h_read (struct GMT_CTRL *GMT, FILE *fp, uint64_t n, double * } /*! . */ -GMT_LOCAL int gmtio_h_read_swab (struct GMT_CTRL *GMT, FILE *fp, uint64_t n, double *d) { +GMT_LOCAL int gmtio_h_read_swab(struct GMT_CTRL *GMT, FILE *fp, uint64_t n, double *d) { /* read byteswapped int16_t */ uint64_t i; - uint16_t u; + uint16_t u = 0; size_t k; int16_t *s = (int16_t *)&u; for (i = 0; i < n; ++i) { - if ((k = gmt_M_fread (&u, sizeof (uint16_t), 1U, fp)) != 1) { + if ((k = gmt_M_fread (&u, sizeof(uint16_t), 1U, fp)) != 1) { GMT->current.io.status = GMT_IO_EOF; - return (GMT_DATA_READ_ERROR); + return GMT_DATA_READ_ERROR; } u = bswap16 (u); - d[i] = (double) *s; + d[i] = (double)*s; } - return (GMT_OK); + return GMT_OK; } /*! . */ @@ -3446,7 +3446,7 @@ GMT_LOCAL void gmtio_check_abstime_format_is_suitable (struct GMT_CTRL *GMT, cha char copy[GMT_LEN32] = {""}, s1[GMT_LEN16] = {""}, *c = NULL; int n, d0, d1, d2; unsigned int k, n_delim_template[3] = {0, 0, 0}, n_delim_token[3] = {0, 0, 0}; - unsigned int token_delim, template_delim, delim; + unsigned int token_delim = 0, template_delim, delim; if (strncmp (GMT->current.setting.format_date_in, "yyyy-mm-dd", 10U)) return; /* No longer set to default so we trust user */ @@ -3502,7 +3502,7 @@ GMT_LOCAL unsigned int gmtio_examine_current_record (struct GMT_CTRL *GMT, char unsigned int ret_val = GMT_READ_DATA, pos = 0, col = 0, k, *type = NULL; unsigned int n_numeric_cols = (GMT->parent->n_numerical_columns == GMT_NOTSET) ? UINT_MAX : GMT->parent->n_numerical_columns; int got; - enum gmt_col_enum phys_col_type; + enum gmt_col_enum phys_col_type = GMT_IS_UNKNOWN; bool found_text = false; char token[GMT_BUFSIZ], message[GMT_BUFSIZ] = {""}; double value; diff --git a/src/gmt_map.c b/src/gmt_map.c index 9f39912f227..42dfeb71b32 100644 --- a/src/gmt_map.c +++ b/src/gmt_map.c @@ -3398,8 +3398,8 @@ void gmt_translate_point (struct GMT_CTRL *GMT, double A[3], double B[3], double GMT_LOCAL void gmtmap_translate_point_geodesic (struct GMT_CTRL *GMT, double lon1, double lat1, double azimuth, double distance_m, double *lon2, double *lat2, double *back_azimuth) { /* Use Vincenty (1975) solution to the direct geodesic problem. Unstable for near antipodal points */ double a = GMT->current.proj.EQ_RAD, f = GMT->current.setting.ref_ellipsoid[GMT->current.setting.proj_ellipsoid].flattening, f1 = 1.0 - f; - double b = a * f1, s = distance_m, alpha1 = azimuth * D2R, s_alpha1, c_alpha1, tan_U1, c_U1, s_U1, sigma1, s_alpha, cosSqAlpha, cos2SigmaM, tmp; - double uSq, A, B, sigma, sigmaP, deltaSigma, sinSigma, cosSigma, lambda, C, L; + double b = a * f1, s = distance_m, alpha1 = azimuth * D2R, s_alpha1, c_alpha1, tan_U1, c_U1, s_U1, sigma1, s_alpha, cosSqAlpha, cos2SigmaM = 0.0, tmp; + double uSq, A, B, sigma, sigmaP, deltaSigma, sinSigma = 0.0, cosSigma = 0.0, lambda, C, L; sincos (alpha1, &s_alpha1, &c_alpha1); tan_U1 = f1 * tand (lat1);