mirror of
git://sourceware.org/git/lvm2.git
synced 2024-12-21 13:34:40 +03:00
cov: ensure settings is set
This commit is contained in:
parent
f7912635a0
commit
a66380ea3e
@ -93,23 +93,26 @@ static uint32_t _raidmaxrecoveryrate(const struct logical_volume *lv)
|
||||
|
||||
static const char *_raidintegritymode(const struct logical_volume *lv)
|
||||
{
|
||||
struct integrity_settings *settings;
|
||||
struct integrity_settings *settings = NULL;
|
||||
|
||||
if (lv_raid_has_integrity((struct logical_volume *)lv))
|
||||
lv_get_raid_integrity_settings((struct logical_volume *)lv, &settings);
|
||||
else if (lv_is_integrity(lv))
|
||||
settings = &first_seg(lv)->integrity_settings;
|
||||
|
||||
if (settings->mode[0] == 'B')
|
||||
return "bitmap";
|
||||
if (settings->mode[0] == 'J')
|
||||
return "journal";
|
||||
if (settings) {
|
||||
switch (settings->mode[0]) {
|
||||
case 'B': return "bitmap";
|
||||
case 'J': return "journal";
|
||||
}
|
||||
}
|
||||
|
||||
return "unknown";
|
||||
}
|
||||
|
||||
static uint32_t _raidintegrityblocksize(const struct logical_volume *lv)
|
||||
{
|
||||
struct integrity_settings *settings;
|
||||
struct integrity_settings *settings = NULL;
|
||||
|
||||
if (lv_raid_has_integrity((struct logical_volume *)lv))
|
||||
lv_get_raid_integrity_settings((struct logical_volume *)lv, &settings);
|
||||
@ -118,7 +121,7 @@ static uint32_t _raidintegrityblocksize(const struct logical_volume *lv)
|
||||
else
|
||||
return 0;
|
||||
|
||||
return settings->block_size;
|
||||
return (settings) ? settings->block_size : 0;
|
||||
}
|
||||
|
||||
static uint64_t _integritymismatches(const struct logical_volume *lv)
|
||||
|
@ -3278,7 +3278,7 @@ static int _raidintegritymode_disp(struct dm_report *rh __attribute__((unused)),
|
||||
void *private __attribute__((unused)))
|
||||
{
|
||||
struct logical_volume *lv = (struct logical_volume *) data;
|
||||
struct integrity_settings *settings;
|
||||
struct integrity_settings *settings = NULL;
|
||||
const char *mode = NULL;
|
||||
char *repstr;
|
||||
|
||||
@ -3289,7 +3289,7 @@ static int _raidintegritymode_disp(struct dm_report *rh __attribute__((unused)),
|
||||
else
|
||||
goto out;
|
||||
|
||||
if (settings->mode[0]) {
|
||||
if (settings && settings->mode[0]) {
|
||||
if (settings->mode[0] == 'B')
|
||||
mode = "bitmap";
|
||||
else if (settings->mode[0] == 'J')
|
||||
@ -3314,13 +3314,14 @@ static int _raidintegrityblocksize_disp(struct dm_report *rh __attribute__((unus
|
||||
void *private __attribute__((unused)))
|
||||
{
|
||||
struct logical_volume *lv = (struct logical_volume *) data;
|
||||
struct integrity_settings *settings;
|
||||
struct integrity_settings *settings = NULL;
|
||||
|
||||
if (lv_raid_has_integrity(lv))
|
||||
lv_get_raid_integrity_settings(lv, &settings);
|
||||
else if (lv_is_integrity(lv))
|
||||
settings = &first_seg(lv)->integrity_settings;
|
||||
else
|
||||
|
||||
if (!settings)
|
||||
return dm_report_field_int32(rh, field, &GET_TYPE_RESERVED_VALUE(num_undef_32));
|
||||
|
||||
return dm_report_field_uint32(rh, field, &settings->block_size);
|
||||
|
Loading…
Reference in New Issue
Block a user