Skip to content

Commit c14f9f4

Browse files
authored
r.describe: initialize some variables (OSGeo#5039)
1 parent d50cd86 commit c14f9f4

File tree

4 files changed

+13
-11
lines changed

4 files changed

+13
-11
lines changed

raster/r.describe/describe.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* PURPOSE: Prints terse list of category values found in a raster
88
* map layer.
99
*
10-
* COPYRIGHT: (C) 2006 by the GRASS Development Team
10+
* COPYRIGHT: (C) 2006-2025 by the GRASS Development Team
1111
*
1212
* This program is free software under the GNU General Public
1313
* License (>=v2). Read the file COPYING that comes with GRASS
@@ -36,7 +36,7 @@ int describe(const char *name, int compact, char *no_data_str, int range,
3636
RASTER_MAP_TYPE map_type;
3737
struct Quant q;
3838
struct FPRange r;
39-
DCELL dmin, dmax;
39+
DCELL dmin = 0.0, dmax = 0.0;
4040
void (*get_row)(int, CELL *, int);
4141

4242
if (windowed) {

raster/r.describe/dumplist.c

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* PURPOSE: Prints terse list of category values found in a raster
88
* map layer.
99
*
10-
* COPYRIGHT: (C) 2006 by the GRASS Development Team
10+
* COPYRIGHT: (C) 2006-2025 by the GRASS Development Team
1111
*
1212
* This program is free software under the GNU General Public
1313
* License (>=v2). Read the file COPYING that comes with GRASS
@@ -29,7 +29,8 @@ static void output_pretty_json(JSON_Value *);
2929
static int show(CELL, CELL, int *, DCELL, DCELL, RASTER_MAP_TYPE, int,
3030
enum OutputFormat, JSON_Array *);
3131

32-
void initialize_json_object(JSON_Value **root_value, JSON_Object **root_object)
32+
static void initialize_json_object(JSON_Value **root_value,
33+
JSON_Object **root_object)
3334
{
3435
*root_value = json_value_init_object();
3536
if (*root_value == NULL) {
@@ -38,7 +39,8 @@ void initialize_json_object(JSON_Value **root_value, JSON_Object **root_object)
3839
*root_object = json_object(*root_value);
3940
}
4041

41-
void initialize_json_array(JSON_Value **root_value, JSON_Array **root_array)
42+
static void initialize_json_array(JSON_Value **root_value,
43+
JSON_Array **root_array)
4244
{
4345
*root_value = json_value_init_array();
4446
if (*root_value == NULL) {
@@ -47,7 +49,7 @@ void initialize_json_array(JSON_Value **root_value, JSON_Array **root_array)
4749
*root_array = json_array(*root_value);
4850
}
4951

50-
void append_category_ranges(JSON_Array *range_array, long min, long max)
52+
static void append_category_ranges(JSON_Array *range_array, long min, long max)
5153
{
5254
JSON_Object *cat_object;
5355
JSON_Value *cat_value;
@@ -59,7 +61,7 @@ void append_category_ranges(JSON_Array *range_array, long min, long max)
5961
json_array_append_value(range_array, cat_value);
6062
}
6163

62-
void output_pretty_json(JSON_Value *root_value)
64+
static void output_pretty_json(JSON_Value *root_value)
6365
{
6466
char *serialized_string = json_serialize_to_string_pretty(root_value);
6567
if (!serialized_string) {
@@ -162,7 +164,7 @@ int compact_list(struct Cell_stats *statf, DCELL dmin, DCELL dmax,
162164
long count; /* not used, but required by cell stats call */
163165
JSON_Value *root_value, *range_value;
164166
JSON_Object *root_object;
165-
JSON_Array *range_array;
167+
JSON_Array *range_array = NULL;
166168

167169
if (format == JSON) {
168170
initialize_json_object(&root_value, &root_object);
@@ -221,7 +223,7 @@ static int show(CELL low, CELL high, int *len, DCELL dmin, DCELL dmax,
221223
RASTER_MAP_TYPE map_type, int nsteps, enum OutputFormat format,
222224
JSON_Array *root_array)
223225
{
224-
char text[100];
226+
char text[100] = {0};
225227
char xlen;
226228
JSON_Object *cat_object;
227229
JSON_Value *cat_value;

raster/r.describe/local_proto.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* PURPOSE: Prints terse list of category values found in a raster
88
* map layer.
99
*
10-
* COPYRIGHT: (C) 2006 by the GRASS Development Team
10+
* COPYRIGHT: (C) 2006-2025 by the GRASS Development Team
1111
*
1212
* This program is free software under the GNU General Public
1313
* License (>=v2). Read the file COPYING that comes with GRASS

raster/r.describe/main.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* PURPOSE: Prints terse list of category values found in a raster
88
* map layer.
99
*
10-
* COPYRIGHT: (C) 2006 by the GRASS Development Team
10+
* COPYRIGHT: (C) 2006-2025 by the GRASS Development Team
1111
*
1212
* This program is free software under the GNU General Public
1313
* License (>=v2). Read the file COPYING that comes with GRASS

0 commit comments

Comments
 (0)