Ensure FRU text is printable ASCII
Currently, libcper currently fails to compile on my machine (GCC 13):
../cper-utils.c: In function ‘add_untrusted_string’:
../cper-utils.c:467:23: error: comparison is always false due to
limited range of data type [-Werror=type-limits]
467 | if (c < 0) {
| ^
The reason seems to be that char signedness is implementation-defined,
we have to explicitly use unsigned char or signed char to get a portable
char type. In our case, char is unsigned char, hence the warning.
Apparently we are trying to validate ASCII strings from the records.
Those strings seem to be used for display purpose only, so I think
replacing it with a more precise printable ASCII test, which also does
not care about char signedness, is appropriate here.
This changes the JSON fruText property to appear only with printable
ASCII FRU content. As a result, all of the examples have been changed
where applicable. Some sections use FRU content with a predefined format
(pcie, cxlprotocol) so fruText has been completely removed from those
JSON objects like in the case of non-printable ASCII FRU content.
Tested: oompile successfully
Change-Id: I98c7c10a674c8817e0b2cbe82c26f6590d8d716a
Signed-off-by: Khang D Nguyen <khangng@os.amperecomputing.com>
diff --git a/examples/arm.json b/examples/arm.json
index 13a945c..8d275c7 100644
--- a/examples/arm.json
+++ b/examples/arm.json
@@ -38,7 +38,7 @@
"resourceNotAccessible": true
},
"fruID": "9f68aa9b-b3f4-3bc8-e10e-045a48a46ee9",
- "fruText": "\u0016I]si\u001dt\u00169'f:\u0003\u0004wJ\u001f;\r",
+ "fruText": "I]sit9'f:wJ;",
"revision": {
"major": 46,
"minor": 70