From fe53bbe0be6a3fca00b60a04c7343c2c5ba8eaea Mon Sep 17 00:00:00 2001 From: Alexander Moibenko Date: Tue, 10 Aug 2021 16:09:57 -0500 Subject: [PATCH] Clear physical location if it contatins garbage. --- mtx-1.3.12/mtx.c | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/mtx-1.3.12/mtx.c b/mtx-1.3.12/mtx.c index b784224..a4f4d96 100644 --- a/mtx-1.3.12/mtx.c +++ b/mtx-1.3.12/mtx.c @@ -35,7 +35,7 @@ */ char *argv0; - +#include #include "mtx.h" /* various defines for bit order etc. */ #include "mtxl.h" @@ -565,6 +565,24 @@ static void Status(void) (ElementStatus->StorageElementFull[StorageElementNumber] ? "Full " : "Empty")); } else { + /* some libraries return garbage in physical location */ + /* see if entry has non-printable character */ + int sl = strlen(ElementStatus->StorageElementPhysicalLocation[StorageElementNumber]); + int sind = 0; + + if (sl > 1) { + for (sind = 0; sind < sl; sind++) + { + if ( !isprint(ElementStatus->StorageElementPhysicalLocation[StorageElementNumber][sind])) { + ElementStatus->StorageElementPhysicalLocation[StorageElementNumber][0] = 0; + break; + } + } + } + else { + ElementStatus->StorageElementPhysicalLocation[StorageElementNumber][0] = 0; + } + printf( " Storage Element %d Phys Loc %s %s:%s ", ElementStatus->StorageElementAddress[StorageElementNumber], ElementStatus->StorageElementPhysicalLocation[StorageElementNumber], (ElementStatus->StorageElementIsImportExport[StorageElementNumber]) ? " IMPORT/EXPORT" : "",