mirror of
git://sourceware.org/git/lvm2.git
synced 2024-12-21 13:34:40 +03:00
libdm: fix uninitialized variable warnings on older gcc
Older versions of gcc aren't able to track the assignments of local variables as well as the latest versions leading to spurious warnings like: libdm-stats.c:2183: warning: "len" may be used uninitialized in this function libdm-stats.c:2177: warning: "minwidth" may be used uninitialized in this function Both of these variables are in fact assigned in all possible paths through the function and later compilers do not produce these warnings. There's no reason to not initialize these variables though and it makes the function slightly easier to follow. Also fix one use of 'unsigned' for a nr_bins value.
This commit is contained in:
parent
cebbb0feaf
commit
cdca2782d2
@ -419,7 +419,7 @@ static int _stats_parse_histogram_spec(struct dm_stats *dms,
|
||||
struct dm_pool *mem = dms->hist_mem;
|
||||
struct dm_histogram_bin cur;
|
||||
struct dm_histogram hist;
|
||||
unsigned nr_bins = 1;
|
||||
int nr_bins = 1;
|
||||
const char *c, *v;
|
||||
char *p;
|
||||
|
||||
@ -2180,7 +2180,7 @@ const char *dm_histogram_to_string(const struct dm_histogram *dmh, int bin,
|
||||
struct dm_pool *mem = dmh->dms->hist_mem;
|
||||
char buf[64], bounds_buf[64];
|
||||
const char *sep = "";
|
||||
ssize_t len;
|
||||
ssize_t len = 0;
|
||||
|
||||
bounds = flags & DM_HISTOGRAM_BOUNDS_MASK;
|
||||
values = flags & DM_HISTOGRAM_VALUES;
|
||||
@ -2191,6 +2191,8 @@ const char *dm_histogram_to_string(const struct dm_histogram *dmh, int bin,
|
||||
} else
|
||||
start = last = bin;
|
||||
|
||||
minwidth = width;
|
||||
|
||||
if (width < 0 || !values)
|
||||
width = minwidth = 0; /* no padding */
|
||||
else if (flags & DM_HISTOGRAM_PERCENT)
|
||||
|
Loading…
Reference in New Issue
Block a user