Remove validation bits
Discard invalid properties from json decode. JSON output should only
contain valid properties. This saves time in preventing post
processing of output for valid fields.
Ensure round trip validity with validation bits removed and required
properties populated.
Fix bugs in json decode.
Overhaul unit tests to use valijson. Add tests with static examples
to validate against schema. Use and nlohmann for better schema
validation over intrinsic libcper validation.
Example json output before:
{
"ValidationBits": {
"LevelValid": false,
"CorrectedValid": true
},
"Level": 1,
"Corrected": true
}
After:
{
"Corrected": true
}
Change-Id: I188bdc2827a57d938c22a431238fadfcdc939ab8
Signed-off-by: Aushim Nagarkatti <anagarkatti@nvidia.com>
diff --git a/cper-parse.c b/cper-parse.c
index 9bfdb40..128b768 100644
--- a/cper-parse.c
+++ b/cper-parse.c
@@ -68,6 +68,7 @@
cper_section_descriptor_to_ir(§ion_descriptor));
//Read the section itself.
+
json_object_array_add(sections_ir,
cper_section_to_ir(cper_file, base_pos,
§ion_descriptor));
@@ -121,11 +122,6 @@
header->ErrorSeverity)));
json_object_object_add(header_ir, "severity", error_severity);
- //The validation bits for each section.
- json_object *validation_bits = bitfield_to_ir(
- header->ValidationBits, 3, CPER_HEADER_VALID_BITFIELD_NAMES);
- json_object_object_add(header_ir, "validationBits", validation_bits);
-
//Total length of the record (including headers) in bytes.
json_object_object_add(header_ir, "recordLength",
json_object_new_uint64(header->RecordLength));
@@ -256,13 +252,6 @@
json_object_object_add(section_descriptor_ir, "revision",
revision_to_ir(section_descriptor->Revision));
- //Validation bits.
- json_object *validation_bits =
- bitfield_to_ir(section_descriptor->SecValidMask, 2,
- CPER_SECTION_DESCRIPTOR_VALID_BITFIELD_NAMES);
- json_object_object_add(section_descriptor_ir, "validationBits",
- validation_bits);
-
//Flag bits.
json_object *flags =
bitfield_to_ir(section_descriptor->SectionFlags, 8,