From ba83342994caae71623e53c05bfda2be2c761248 Mon Sep 17 00:00:00 2001 From: Shubham Vasudeo Desai Date: Wed, 17 Jul 2024 11:43:47 -0400 Subject: [PATCH] raster: Fix uninitialized variable issue for c files in raster --- raster/r.coin/print_coin.c | 2 +- raster/r.mapcalc/map3.c | 2 +- raster/r.object.geometry/main.c | 2 +- raster/r.out.mpeg/main.c | 2 +- raster/r.sim/simlib/random.c | 4 ++-- raster/r.spreadpath/path_finder.c | 2 +- raster/r.statistics/o_kurt.c | 2 +- raster/r.statistics/o_sdev.c | 2 +- raster/r.statistics/o_skew.c | 2 +- 9 files changed, 10 insertions(+), 10 deletions(-) diff --git a/raster/r.coin/print_coin.c b/raster/r.coin/print_coin.c index f2a291fa326..a74ab75044b 100644 --- a/raster/r.coin/print_coin.c +++ b/raster/r.coin/print_coin.c @@ -32,7 +32,7 @@ int print_coin(int Conformat, int out_cols, int tofile) double colarea_no_0, rowarea_no_0; double area; - int addflag; + int addflag = 0; char topformat[133], midformat[133], namformat[133]; char fillformat[133]; const char *mapone; diff --git a/raster/r.mapcalc/map3.c b/raster/r.mapcalc/map3.c index 374f6a76109..c9683148275 100644 --- a/raster/r.mapcalc/map3.c +++ b/raster/r.mapcalc/map3.c @@ -265,7 +265,7 @@ static void translate_from_cats(map *m, CELL *cell, DCELL *xcell, int ncols) { struct Categories *pcats; BTREE *btree; - int i, idx; + int i = 0, idx = 0; CELL cat, key; double vbuf[1 << SHIFT]; double *values; diff --git a/raster/r.object.geometry/main.c b/raster/r.object.geometry/main.c index 062a7aa1a83..f808c4b88e1 100644 --- a/raster/r.object.geometry/main.c +++ b/raster/r.object.geometry/main.c @@ -56,7 +56,7 @@ int main(int argc, char *argv[]) } *obj_geos; double unit_area; int n_objects; - int planimetric, compute_areas; + int planimetric = 0, compute_areas = 0; struct Cell_head cellhd; G_gisinit(argv[0]); diff --git a/raster/r.out.mpeg/main.c b/raster/r.out.mpeg/main.c index a83004544b1..0ac3b631b80 100644 --- a/raster/r.out.mpeg/main.c +++ b/raster/r.out.mpeg/main.c @@ -235,7 +235,7 @@ static int load_files(void) register int i, rowoff, row, col, vxoff, vyoff, offset; int cnt, fd, size, tsiz, coff; int vnum; - int y_rows, y_cols; + int y_rows = 0, y_cols = 0; char *pr, *pg, *pb; unsigned char *tr, *tg, *tb, *tset; char *mpfilename, *name; diff --git a/raster/r.sim/simlib/random.c b/raster/r.sim/simlib/random.c index 4fff384f795..8646a93bf9f 100644 --- a/raster/r.sim/simlib/random.c +++ b/raster/r.sim/simlib/random.c @@ -25,7 +25,7 @@ double gasdev(void) double ret_val; /* Local variables */ - double r = 0., vv1, vv2, fac; + double r = 0.0, vv1 = 0.0, vv2 = 0.0, fac = 0.0; if (iset == 0) { while (r >= 1. || r == 0.) { @@ -47,7 +47,7 @@ double gasdev(void) void gasdev_for_paralel(double *x, double *y) { - double r = 0., vv1, vv2, fac; + double r = 0.0, vv1 = 0.0, vv2 = 0.0, fac = 0.0; while (r >= 1. || r == 0.) { vv1 = simwe_rand() * 2. - 1.; diff --git a/raster/r.spreadpath/path_finder.c b/raster/r.spreadpath/path_finder.c index 8b5cfe87a39..9cf98048d47 100644 --- a/raster/r.spreadpath/path_finder.c +++ b/raster/r.spreadpath/path_finder.c @@ -10,7 +10,7 @@ void path_finder(int row, int col, int backrow, int backcol) { - int data, new_backrow, new_backcol; + int data = 0, new_backrow = 0, new_backcol = 0; extern char *value; extern int nrows, ncols; extern SEGMENT in_row_seg, in_col_seg, out_seg; diff --git a/raster/r.statistics/o_kurt.c b/raster/r.statistics/o_kurt.c index b6383811dd4..0155ffa0893 100644 --- a/raster/r.statistics/o_kurt.c +++ b/raster/r.statistics/o_kurt.c @@ -17,7 +17,7 @@ int o_kurt(const char *basemap, const char *covermap, const char *outputmap, { struct Popen stats_child, reclass_child; FILE *stats, *reclass; - int first, i, count; + int first, i, count = 0; size_t mem; long basecat, covercat, catb, catc; double value, var, x; diff --git a/raster/r.statistics/o_sdev.c b/raster/r.statistics/o_sdev.c index 4a39cd76559..b49c134508f 100644 --- a/raster/r.statistics/o_sdev.c +++ b/raster/r.statistics/o_sdev.c @@ -17,7 +17,7 @@ int o_sdev(const char *basemap, const char *covermap, const char *outputmap, { struct Popen stats_child, reclass_child; FILE *stats, *reclass; - int first, i, count; + int first, i, count = 0; size_t mem; long basecat, covercat, catb, catc; double value, sdev, x; diff --git a/raster/r.statistics/o_skew.c b/raster/r.statistics/o_skew.c index e08c97e5951..09cca655d46 100644 --- a/raster/r.statistics/o_skew.c +++ b/raster/r.statistics/o_skew.c @@ -17,7 +17,7 @@ int o_skew(const char *basemap, const char *covermap, const char *outputmap, { struct Popen stats_child, reclass_child; FILE *stats, *reclass; - int first, i, count; + int first, i, count = 0; size_t mem; long basecat, covercat, catb, catc; double value, var, x;