summaryrefslogtreecommitdiff
path: root/lib/report
diff options
context:
space:
mode:
authorPeter Rajnoha <prajnoha@redhat.com>2022-08-15 11:40:52 +0200
committerPeter Rajnoha <prajnoha@redhat.com>2022-08-16 13:42:50 +0200
commit81839cc4ebf566ea9f3e6d819c7338b98cdec374 (patch)
tree9ca7a0e6d75de73b623df635a61227703bafd6d5 /lib/report
parentce58e9d5b37c3e408f2b41c8095980490a87f2a4 (diff)
downloadlvm2-81839cc4ebf566ea9f3e6d819c7338b98cdec374.tar.gz
report: report numeric values (not string synonyms) for NUM and BIN fields with json_std format
Internally, NUM and BIN fields are marked as DM_REPORT_FIELD_TYPE_NUM_NUMBER through libdevmapper API. The new 'json_std' format mandates that the report string representing such a value must be a number, not an arbitrary string. This is because numeric values in 'json_std' format do not have double quotes around them. This practically means, we can't use string synonyms ("named reserved values") for such values and the report string must always represent a proper number. With 'json' and 'basic' formats, this is not an issue because 'basic' format doesn't have any structure or typing at all and 'json' format puts all values in quotes, including numeric ones.
Diffstat (limited to 'lib/report')
-rw-r--r--lib/report/report.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/lib/report/report.c b/lib/report/report.c
index c06b22674..8a5122ff9 100644
--- a/lib/report/report.c
+++ b/lib/report/report.c
@@ -1256,7 +1256,7 @@ static int _binary_disp(struct dm_report *rh, struct dm_pool *mem __attribute__(
{
const struct cmd_context *cmd = (const struct cmd_context *) private;
- if (cmd->report_binary_values_as_numeric)
+ if (cmd->report_strict_type_mode || cmd->report_binary_values_as_numeric)
/* "0"/"1" */
return _field_set_value(field, bin_value ? _str_one : _str_zero, bin_value ? &_one64 : &_zero64);
@@ -1269,7 +1269,7 @@ static int _binary_undef_disp(struct dm_report *rh, struct dm_pool *mem __attrib
{
const struct cmd_context *cmd = (const struct cmd_context *) private;
- if (cmd->report_binary_values_as_numeric)
+ if (cmd->report_strict_type_mode || cmd->report_binary_values_as_numeric)
return _field_set_value(field, GET_FIRST_RESERVED_NAME(num_undef_64), &GET_TYPE_RESERVED_VALUE(num_undef_64));
return _field_set_value(field, _str_unknown, &GET_TYPE_RESERVED_VALUE(num_undef_64));
@@ -3041,10 +3041,11 @@ static int _vgmdacopies_disp(struct dm_report *rh, struct dm_pool *mem,
struct dm_report_field *field,
const void *data, void *private)
{
+ struct cmd_context *cmd = (struct cmd_context *) private;
const struct volume_group *vg = (const struct volume_group *) data;
uint32_t count = vg_mda_copies(vg);
- if (count == VGMETADATACOPIES_UNMANAGED)
+ if (count == VGMETADATACOPIES_UNMANAGED && !cmd->report_strict_type_mode)
return _field_set_value(field, GET_FIRST_RESERVED_NAME(vg_mda_copies_unmanaged),
GET_FIELD_RESERVED_VALUE(vg_mda_copies_unmanaged));