Fix unprintable model and serial numbers.

Some systems support model and serial numbers for their fans and psus but they might not be programmed correctly.
This fix uses the printable string datatype to make sure the result can be marshalled by other tools.
This commit is contained in:
Jeffrey Townsend
2019-08-30 16:55:59 +00:00
parent 812217a676
commit 7bb76e6579
2 changed files with 4 additions and 5 deletions

View File

@@ -310,10 +310,10 @@ onlp_fan_show(onlp_oid_t oid, aim_pvs_t* pvs, uint32_t flags)
else {
iof_iprintf(&iof, "Status: Running");
if(fi.model[0]) {
iof_iprintf(&iof, "Model: %s", fi.model);
iof_iprintf(&iof, "Model: %{pstr}", fi.model, '?');
}
if(fi.serial[0]) {
iof_iprintf(&iof, "SN: %s", fi.serial);
iof_iprintf(&iof, "SN: %{pstr}", fi.serial, '?');
}
if(fi.caps & ONLP_FAN_CAPS_GET_RPM) {
iof_iprintf(&iof, "RPM: %d", fi.rpm);
@@ -336,4 +336,3 @@ onlp_fan_show(onlp_oid_t oid, aim_pvs_t* pvs, uint32_t flags)
}
iof_pop(&iof);
}

View File

@@ -196,8 +196,8 @@ onlp_psu_show(onlp_oid_t id, aim_pvs_t* pvs, uint32_t flags)
}
else {
iof_iprintf(&iof, "Status: Running");
if(pi.model[0]) iof_iprintf(&iof, "Model: %s", pi.model);
if(pi.serial[0]) iof_iprintf(&iof, "SN: %s", pi.serial);
if(pi.model[0]) iof_iprintf(&iof, "Model: %{pstr}", pi.model, '?');
if(pi.serial[0]) iof_iprintf(&iof, "SN: %{pstr}", pi.serial, '?');
if(pi.caps & ONLP_PSU_CAPS_AC) {
iof_iprintf(&iof, "Type: AC");
}