Skip to content

Commit

Permalink
Fix -Wuninitialized compiler warnings (#2164)
Browse files Browse the repository at this point in the history
  • Loading branch information
nilason authored Nov 9, 2022
1 parent 5184a91 commit cd43296
Show file tree
Hide file tree
Showing 12 changed files with 18 additions and 20 deletions.
6 changes: 2 additions & 4 deletions imagery/i.gensig/means.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

int compute_means(struct files *files, struct Signature *S)
{
int n, n_nulls;
int n;
int b;
int nrows, ncols, row, col;
CELL *class;
Expand All @@ -32,10 +32,8 @@ int compute_means(struct files *files, struct Signature *S)
Rast_get_d_row(files->band_fd[b], cell =
files->band_cell[b], row);
for (col = 0; col < ncols; col++) {
if (Rast_is_d_null_value(&cell[col])) {
n_nulls++;
if (Rast_is_d_null_value(&cell[col]))
continue;
}
n = class[col];
if (n < 0)
continue;
Expand Down
3 changes: 2 additions & 1 deletion lib/raster3d/test/test_put_get_value_large_file.c
Original file line number Diff line number Diff line change
Expand Up @@ -444,7 +444,8 @@ int test_large_file_sparse_random(int depths, int rows, int cols,
for (x = 0; x < region.cols; x++) {
/* Check the counter as cell value */
Rast3d_get_value(map, x, y, z, &value, DCELL_TYPE);
if (fabs(value - random_value_vector[i]) > EPSILON) {
random_value = random_value_vector[i];
if (fabs(value - random_value) > EPSILON) {
G_message
("At: z %i y %i x %i -- value %.14lf != %.14lf\n", z,
y, x, value, random_value);
Expand Down
2 changes: 1 addition & 1 deletion lib/rst/interp_float/ressegm2d.c
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ int IL_resample_interp_segments_2d(struct interp_params *params, struct BM *bitm
double xmax, xmin, ymax, ymin;
int totsegm; /* total number of segments */
int total_points = 0;
struct triple triple; /* contains garbage */
struct triple triple = { 0.0, 0.0, 0.0, 0.0 }; /* contains garbage */


xmin = params->x_orig;
Expand Down
2 changes: 1 addition & 1 deletion lib/rst/interp_float/segmen2d_parallel.c
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ int IL_interp_segments_2d_parallel(struct interp_params *params, struct tree_inf
double dnorm, int threads)
{
int some_thread_failed = 0;
int tid;
int tid = 0;
int i = 0;
int j = 0;
int i_cnt;
Expand Down
2 changes: 1 addition & 1 deletion lib/vector/Vlib/ascii.c
Original file line number Diff line number Diff line change
Expand Up @@ -542,7 +542,7 @@ int Vect_write_ascii(FILE * ascii,
if (columns) {
for (i = 0; columns[i]; i++) {
if (db_select_value
(driver, Fi->table, Fi->key, cat, columns[i], &value) < 0)
(driver, Fi->table, Fi->key, 0, columns[i], &value) < 0)
G_fatal_error(_("Unable to select record from table <%s> (key %s, column %s)"),
Fi->table, Fi->key, columns[i]);
if (columns[i])
Expand Down
2 changes: 1 addition & 1 deletion lib/vector/Vlib/net_build.c
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ Vect_net_ttb_build_graph(struct Map_info *Map,
struct bound_box box;
struct boxlist *List;

dglInt32_t dgl_cost = cost;
dglInt32_t dgl_cost;

/*TODO attributes of turntable should be stored in one place */
const char *tcols[] = { "cat", "ln_from", "ln_to", "cost", "isec", NULL
Expand Down
2 changes: 1 addition & 1 deletion lib/vector/neta/path.c
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ int NetA_find_path(dglGraph_s * graph, int from, int to, int *edges,
prev[from] = NULL;
while (begin != end) {
dglInt32_t vertex = queue[begin++];
dglInt32_t *edge, *node;
dglInt32_t *edge = NULL, *node;

if (vertex == to)
break;
Expand Down
3 changes: 1 addition & 2 deletions raster/r.statistics/o_sum.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ int o_sum(const char *basemap, const char *covermap, const char *outputmap,
{
long catb, basecat, covercat;
double x, area, sum1;
int stat;
struct Popen stats_child, reclass_child;
FILE *stats, *reclass;

Expand Down Expand Up @@ -44,7 +43,7 @@ int o_sum(const char *basemap, const char *covermap, const char *outputmap,
G_popen_close(&stats_child);
G_popen_close(&reclass_child);

return stat;
return 0;
}

static void sum_out(FILE * fp, long cat, double sum1)
Expand Down
7 changes: 3 additions & 4 deletions raster/r.stream.extract/streams.c
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ static int continue_stream(CELL stream_id, int r_max, int c_max,
/* debug */
if (n_stream_nodes != *stream_no)
G_warning(_("Stream_no %d and n_stream_nodes %" PRI_OFF_T
" out of sync"), *stream_no, n_stream_nodes);
" out of sync"), *stream_no, n_stream_nodes);

stream_node[*stream_no].n_alloc += 2;
new_size = stream_node[*stream_no].n_alloc * sizeof(int);
Expand Down Expand Up @@ -151,7 +151,7 @@ int do_accum(double d8cut)
int asp_c[9] = { 0, 1, 0, -1, -1, -1, 0, 1, 1 };
int nextdr[8] = { 1, -1, 0, 0, -1, 1, 1, -1 };
int nextdc[8] = { 0, 0, -1, 1, 1, -1, 1, -1 };
GW_LARGE_INT workedon, killer;
GW_LARGE_INT killer;
char *flag_nbr;
POINT astarpoint;
WAT_ALT wa;
Expand Down Expand Up @@ -331,7 +331,6 @@ int do_accum(double d8cut)
}
else if (ct_dir == np_side) {
/* check for consistency with A * path */
workedon++;
}
}
}
Expand Down Expand Up @@ -660,7 +659,7 @@ int extract_streams(double threshold, double mont_exp, int internal_acc)
/* debug */
if (n_stream_nodes != stream_no)
G_warning(_("Stream_no %d and n_stream_nodes %" PRI_OFF_T
" out of sync"), stream_no, n_stream_nodes);
" out of sync"), stream_no, n_stream_nodes);
}

/*********************/
Expand Down
2 changes: 1 addition & 1 deletion vector/v.lrs/v.lrs.label/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@ int main(int argc, char **argv)
/* For each line select all existeng reference segments, sort them along the line
* and fcreate stationing. */

G_debug(2, "find_line(): lfield = %d lcat = %d", lfield, lcat);
G_debug(2, "find_line(): lfield = %d", lfield);

arseg = 1000;
rseg = (RSEGMENT *) G_malloc(arseg * sizeof(RSEGMENT));
Expand Down
4 changes: 2 additions & 2 deletions vector/v.net.salesman/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -500,8 +500,8 @@ int main(int argc, char **argv)

/* tmpcost must always be > 0 */

G_debug(2, "? %d - %d cost = %f x %f", node1, node2, tmpcost,
cost);
G_debug(2, "? %d - %d cost = %f x %f", cities[cycle[j]],
cities[cycle[j + 1]], tmpcost, cost);
/* always true for j = 0 */
if (tmpcost < cost) {
city1 = j;
Expand Down
3 changes: 2 additions & 1 deletion vector/v.split/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -237,9 +237,10 @@ int main(int argc, char *argv[])
if (nosplit)
Vect_reset_line(Points3);

double x = 0.0, y = 0.0, z = 0.0;

for (i = 0; i < n; i++) {
int ret;
double x, y, z;

if (i == n - 1) {
to = l; /* to be sure that it goes to end */
Expand Down

0 comments on commit cd43296

Please sign in to comment.