Blame SOURCES/0005-Get-rid-of-the-arrows-in-our-debug-messages.patch

d5c737
From da19b396ed674a7c9fddca1e3b480a18e642e280 Mon Sep 17 00:00:00 2001
d5c737
From: Peter Jones <pjones@redhat.com>
d5c737
Date: Thu, 21 Feb 2019 15:26:23 -0500
d5c737
Subject: [PATCH 05/63] Get rid of the arrows in our debug messages.
d5c737
d5c737
They're not *that* useful, and the code is clever and problematic.
d5c737
d5c737
Resolves github issue #124
d5c737
d5c737
Signed-off-by: Peter Jones <pjones@redhat.com>
d5c737
---
d5c737
 src/linux-acpi-root.c |  7 -------
d5c737
 src/linux-emmc.c      |  9 ---------
d5c737
 src/linux-md.c        |  8 --------
d5c737
 src/linux-nvme.c      |  9 ---------
d5c737
 src/linux-pci-root.c  |  7 -------
d5c737
 src/linux-pci.c       |  8 --------
d5c737
 src/linux-sata.c      | 11 -----------
d5c737
 src/linux-scsi.c      | 24 ------------------------
d5c737
 src/linux-soc-root.c  |  7 -------
d5c737
 src/linux-virtblk.c   |  8 --------
d5c737
 src/util.h            |  1 -
d5c737
 11 files changed, 99 deletions(-)
d5c737
d5c737
diff --git a/src/linux-acpi-root.c b/src/linux-acpi-root.c
d5c737
index 06e69eebe78..30728ded671 100644
d5c737
--- a/src/linux-acpi-root.c
d5c737
+++ b/src/linux-acpi-root.c
d5c737
@@ -51,13 +51,6 @@ parse_acpi_root(struct device *dev, const char *current, const char *root UNUSED
d5c737
         char *colon;
d5c737
 
d5c737
         const char *devpart = current;
d5c737
-        char *spaces;
d5c737
-
d5c737
-        pos = strlen(current);
d5c737
-        spaces = alloca(pos+1);
d5c737
-        memset(spaces, ' ', pos+1);
d5c737
-        spaces[pos] = '\0';
d5c737
-        pos = 0;
d5c737
 
d5c737
         debug("entry");
d5c737
 
d5c737
diff --git a/src/linux-emmc.c b/src/linux-emmc.c
d5c737
index 87e92477554..b290ed0a2bd 100644
d5c737
--- a/src/linux-emmc.c
d5c737
+++ b/src/linux-emmc.c
d5c737
@@ -50,13 +50,6 @@ parse_emmc(struct device *dev, const char *current, const char *root UNUSED)
d5c737
         int rc;
d5c737
         int32_t tosser0, tosser1, tosser2, tosser3, slot_id, partition;
d5c737
         int pos0 = 0, pos1 = 0;
d5c737
-        char *spaces;
d5c737
-
d5c737
-        pos0 = strlen(current);
d5c737
-        spaces = alloca(pos0+1);
d5c737
-        memset(spaces, ' ', pos0+1);
d5c737
-        spaces[pos0] = '\0';
d5c737
-        pos0 = 0;
d5c737
 
d5c737
         debug("entry");
d5c737
 
d5c737
@@ -65,8 +58,6 @@ parse_emmc(struct device *dev, const char *current, const char *root UNUSED)
d5c737
                     &tosser0, &tosser1, &tosser2, &slot_id,
d5c737
                     &pos0, &tosser3, &partition, &pos1);
d5c737
         debug("current:\"%s\" rc:%d pos0:%d pos1:%d\n", current, rc, pos0, pos1);
d5c737
-        arrow(LOG_DEBUG, spaces, 9, pos0, rc, 4);
d5c737
-        arrow(LOG_DEBUG, spaces, 9, pos1, rc, 6);
d5c737
         /*
d5c737
          * If it isn't of that form, it's not one of our emmc devices.
d5c737
          */
d5c737
diff --git a/src/linux-md.c b/src/linux-md.c
d5c737
index 0a5c1cdb435..cb584c96c4b 100644
d5c737
--- a/src/linux-md.c
d5c737
+++ b/src/linux-md.c
d5c737
@@ -44,13 +44,6 @@ parse_md(struct device *dev, const char *current, const char *root UNUSED)
d5c737
         int rc;
d5c737
         int32_t md, tosser0, part;
d5c737
         int pos0 = 0, pos1 = 0;
d5c737
-        char *spaces;
d5c737
-
d5c737
-        pos0 = strlen(current);
d5c737
-        spaces = alloca(pos0+1);
d5c737
-        memset(spaces, ' ', pos0+1);
d5c737
-        spaces[pos0] = '\0';
d5c737
-        pos0 = 0;
d5c737
 
d5c737
         debug("entry");
d5c737
 
d5c737
@@ -58,7 +51,6 @@ parse_md(struct device *dev, const char *current, const char *root UNUSED)
d5c737
         rc = sscanf(current, "md%d/%nmd%dp%d%n",
d5c737
                     &md, &pos0, &tosser0, &part, &pos1);
d5c737
         debug("current:\"%s\" rc:%d pos0:%d pos1:%d\n", current, rc, pos0, pos1);
d5c737
-        arrow(LOG_DEBUG, spaces, 9, pos0, rc, 3);
d5c737
         /*
d5c737
          * If it isn't of that form, it's not one of our partitioned md devices.
d5c737
          */
d5c737
diff --git a/src/linux-nvme.c b/src/linux-nvme.c
d5c737
index d68d11a3409..1d8fc654f76 100644
d5c737
--- a/src/linux-nvme.c
d5c737
+++ b/src/linux-nvme.c
d5c737
@@ -54,13 +54,6 @@ parse_nvme(struct device *dev, const char *current, const char *root UNUSED)
d5c737
         int32_t tosser0, tosser1, tosser2, ctrl_id, ns_id, partition;
d5c737
         uint8_t *filebuf = NULL;
d5c737
         int pos0 = 0, pos1 = 0;
d5c737
-        char *spaces;
d5c737
-
d5c737
-        pos0 = strlen(current);
d5c737
-        spaces = alloca(pos0+1);
d5c737
-        memset(spaces, ' ', pos0+1);
d5c737
-        spaces[pos0] = '\0';
d5c737
-        pos0 = 0;
d5c737
 
d5c737
         debug("entry");
d5c737
 
d5c737
@@ -69,8 +62,6 @@ parse_nvme(struct device *dev, const char *current, const char *root UNUSED)
d5c737
                     &tosser0, &ctrl_id, &ns_id, &pos0,
d5c737
                     &tosser1, &tosser2, &partition, &pos1);
d5c737
         debug("current:\"%s\" rc:%d pos0:%d pos1:%d\n", current, rc, pos0, pos1);
d5c737
-        arrow(LOG_DEBUG, spaces, 9, pos0, rc, 3);
d5c737
-        arrow(LOG_DEBUG, spaces, 9, pos1, rc, 6);
d5c737
         /*
d5c737
          * If it isn't of that form, it's not one of our nvme devices.
d5c737
          */
d5c737
diff --git a/src/linux-pci-root.c b/src/linux-pci-root.c
d5c737
index 5d1df06119d..0605acfc7cb 100644
d5c737
--- a/src/linux-pci-root.c
d5c737
+++ b/src/linux-pci-root.c
d5c737
@@ -48,13 +48,6 @@ parse_pci_root(struct device *dev, const char *current, const char *root UNUSED)
d5c737
         uint16_t root_domain;
d5c737
         uint8_t root_bus;
d5c737
         const char *devpart = current;
d5c737
-        char *spaces;
d5c737
-
d5c737
-        pos = strlen(current);
d5c737
-        spaces = alloca(pos+1);
d5c737
-        memset(spaces, ' ', pos+1);
d5c737
-        spaces[pos] = '\0';
d5c737
-        pos = 0;
d5c737
 
d5c737
         debug("entry");
d5c737
 
d5c737
diff --git a/src/linux-pci.c b/src/linux-pci.c
d5c737
index f63f5914d9f..64aaefb461c 100644
d5c737
--- a/src/linux-pci.c
d5c737
+++ b/src/linux-pci.c
d5c737
@@ -48,13 +48,6 @@ parse_pci(struct device *dev, const char *current, const char *root)
d5c737
         int rc;
d5c737
         int pos;
d5c737
         const char *devpart = current;
d5c737
-        char *spaces;
d5c737
-
d5c737
-        pos = strlen(current);
d5c737
-        spaces = alloca(pos+1);
d5c737
-        memset(spaces, ' ', pos+1);
d5c737
-        spaces[pos] = '\0';
d5c737
-        pos = 0;
d5c737
 
d5c737
         debug("entry");
d5c737
 
d5c737
@@ -75,7 +68,6 @@ parse_pci(struct device *dev, const char *current, const char *root)
d5c737
                 rc = sscanf(devpart, "%hx:%hhx:%hhx.%hhx/%n",
d5c737
                             &domain, &bus, &device, &function, &pos;;
d5c737
                 debug("current:\"%s\" rc:%d pos:%d", devpart, rc, pos);
d5c737
-                arrow(LOG_DEBUG, spaces, 9, pos, rc, 3);
d5c737
                 if (rc != 4)
d5c737
                         break;
d5c737
                 devpart += pos;
d5c737
diff --git a/src/linux-sata.c b/src/linux-sata.c
d5c737
index 85265022f89..356411724bb 100644
d5c737
--- a/src/linux-sata.c
d5c737
+++ b/src/linux-sata.c
d5c737
@@ -148,13 +148,6 @@ parse_sata(struct device *dev, const char *devlink, const char *root UNUSED)
d5c737
         uint64_t scsi_lun, tosser3;
d5c737
         int pos = 0;
d5c737
         int rc;
d5c737
-        char *spaces;
d5c737
-
d5c737
-        pos = strlen(current);
d5c737
-        spaces = alloca(pos+1);
d5c737
-        memset(spaces, ' ', pos+1);
d5c737
-        spaces[pos] = '\0';
d5c737
-        pos = 0;
d5c737
 
d5c737
         debug("entry");
d5c737
         if (is_pata(dev)) {
d5c737
@@ -169,7 +162,6 @@ parse_sata(struct device *dev, const char *devlink, const char *root UNUSED)
d5c737
         debug("searching for ata1/");
d5c737
         rc = sscanf(current, "ata%"PRIu32"/%n", &print_id, &pos;;
d5c737
         debug("current:\"%s\" rc:%d pos:%d\n", current, rc, pos);
d5c737
-        arrow(LOG_DEBUG, spaces, 9, pos, rc, 1);
d5c737
         /*
d5c737
          * If we don't find this one, it isn't an ata device, so return 0 not
d5c737
          * error.  Later errors mean it is an ata device, but we can't parse
d5c737
@@ -183,7 +175,6 @@ parse_sata(struct device *dev, const char *devlink, const char *root UNUSED)
d5c737
         debug("searching for host0/");
d5c737
         rc = sscanf(current, "host%"PRIu32"/%n", &scsi_bus, &pos;;
d5c737
         debug("current:\"%s\" rc:%d pos:%d\n", current, rc, pos);
d5c737
-        arrow(LOG_DEBUG, spaces, 9, pos, rc, 1);
d5c737
         if (rc != 1)
d5c737
                 return -1;
d5c737
         current += pos;
d5c737
@@ -193,7 +184,6 @@ parse_sata(struct device *dev, const char *devlink, const char *root UNUSED)
d5c737
         rc = sscanf(current, "target%"PRIu32":%"PRIu32":%"PRIu64"/%n",
d5c737
                     &scsi_device, &scsi_target, &scsi_lun, &pos;;
d5c737
         debug("current:\"%s\" rc:%d pos:%d\n", current, rc, pos);
d5c737
-        arrow(LOG_DEBUG, spaces, 9, pos, rc, 3);
d5c737
         if (rc != 3)
d5c737
                 return -1;
d5c737
         current += pos;
d5c737
@@ -203,7 +193,6 @@ parse_sata(struct device *dev, const char *devlink, const char *root UNUSED)
d5c737
         rc = sscanf(current, "%"PRIu32":%"PRIu32":%"PRIu32":%"PRIu64"/%n",
d5c737
                     &tosser0, &tosser1, &tosser2, &tosser3, &pos;;
d5c737
         debug("current:\"%s\" rc:%d pos:%d\n", current, rc, pos);
d5c737
-        arrow(LOG_DEBUG, spaces, 9, pos, rc, 4);
d5c737
         if (rc != 4)
d5c737
                 return -1;
d5c737
         current += pos;
d5c737
diff --git a/src/linux-scsi.c b/src/linux-scsi.c
d5c737
index a5e81cf9cb6..04892f02b4e 100644
d5c737
--- a/src/linux-scsi.c
d5c737
+++ b/src/linux-scsi.c
d5c737
@@ -45,13 +45,6 @@ parse_scsi_link(const char *current, uint32_t *scsi_host,
d5c737
         int rc;
d5c737
         int sz = 0;
d5c737
         int pos0 = 0, pos1 = 0;
d5c737
-        char *spaces;
d5c737
-
d5c737
-        sz = strlen(current);
d5c737
-        spaces = alloca(sz+1);
d5c737
-        memset(spaces, ' ', sz+1);
d5c737
-        spaces[sz] = '\0';
d5c737
-        sz = 0;
d5c737
 
d5c737
         debug("entry");
d5c737
         /*
d5c737
@@ -108,7 +101,6 @@ parse_scsi_link(const char *current, uint32_t *scsi_host,
d5c737
         debug("searching for host4/");
d5c737
         rc = sscanf(current, "host%d/%n", scsi_host, &pos0);
d5c737
         debug("current:\"%s\" rc:%d pos0:%d\n", current+sz, rc, pos0);
d5c737
-        arrow(LOG_DEBUG, spaces, 9, pos0, rc, 1);
d5c737
         if (rc != 1)
d5c737
                 return -1;
d5c737
         sz += pos0;
d5c737
@@ -126,8 +118,6 @@ parse_scsi_link(const char *current, uint32_t *scsi_host,
d5c737
         rc = sscanf(current+sz, "port-%d:%d%n:%d%n", &tosser0,
d5c737
                     &tosser1, &pos0, &tosser2, &pos1);
d5c737
         debug("current:\"%s\" rc:%d pos0:%d pos1:%d\n", current+sz, rc, pos0, pos1);
d5c737
-        arrow(LOG_DEBUG, spaces, 9, pos0, rc, 2);
d5c737
-        arrow(LOG_DEBUG, spaces, 9, pos1, rc, 3);
d5c737
         if (rc == 2 || rc == 3) {
d5c737
                 sz += pos0;
d5c737
                 pos0 = 0;
d5c737
@@ -153,7 +143,6 @@ parse_scsi_link(const char *current, uint32_t *scsi_host,
d5c737
                 debug("searching for expander-4:0/");
d5c737
                 rc = sscanf(current+sz, "expander-%d:%d/%n", &tosser0, &tosser1, &pos0);
d5c737
                 debug("current:\"%s\" rc:%d pos0:%d\n", current+sz, rc, pos0);
d5c737
-                arrow(LOG_DEBUG, spaces, 9, pos0, rc, 2);
d5c737
                 if (rc == 2) {
d5c737
                         if (!remote_target_id) {
d5c737
                                 efi_error("Device is PHY is a remote target, but remote_target_id is NULL");
d5c737
@@ -169,7 +158,6 @@ parse_scsi_link(const char *current, uint32_t *scsi_host,
d5c737
                         debug("searching for port-2:0:2/");
d5c737
                         rc = sscanf(current+sz, "port-%d:%d:%d/%n", &tosser0, &tosser1, &tosser2, &pos0);
d5c737
                         debug("current:\"%s\" rc:%d pos0:%d\n", current+sz, rc, pos0);
d5c737
-                        arrow(LOG_DEBUG, spaces, 9, pos0, rc, 3);
d5c737
                         if (rc != 3) {
d5c737
                                 efi_error("Couldn't parse port expander port string");
d5c737
                                 return -1;
d5c737
@@ -192,8 +180,6 @@ parse_scsi_link(const char *current, uint32_t *scsi_host,
d5c737
 
d5c737
                 pos1 = 0;
d5c737
                 rc = sscanf(current + sz + pos0, ":%d%n", &tosser2, &pos1);
d5c737
-                arrow(LOG_DEBUG, spaces, 9, pos0, rc + 2, 2);
d5c737
-                arrow(LOG_DEBUG, spaces, 9, pos0 + pos1, rc + 2, 3);
d5c737
                 if (rc != 0 && rc != 1)
d5c737
                         return -1;
d5c737
                 if (remote_port_id && rc == 1)
d5c737
@@ -217,7 +203,6 @@ parse_scsi_link(const char *current, uint32_t *scsi_host,
d5c737
         rc = sscanf(current + sz, "target%d:%d:%"PRIu64"/%n", &tosser0, &tosser1,
d5c737
                     &tosser3, &pos0);
d5c737
         debug("current:\"%s\" rc:%d pos0:%d\n", current+sz, rc, pos0);
d5c737
-        arrow(LOG_DEBUG, spaces, 9, pos0, rc, 3);
d5c737
         if (rc != 3)
d5c737
                 return -1;
d5c737
         sz += pos0;
d5c737
@@ -230,7 +215,6 @@ parse_scsi_link(const char *current, uint32_t *scsi_host,
d5c737
         rc = sscanf(current + sz, "%d:%d:%d:%"PRIu64"/%n",
d5c737
                     scsi_bus, scsi_device, scsi_target, scsi_lun, &pos0);
d5c737
         debug("current:\"%s\" rc:%d pos0:%d\n", current+sz, rc, pos0);
d5c737
-        arrow(LOG_DEBUG, spaces, 9, pos0, rc, 4);
d5c737
         if (rc != 4)
d5c737
                 return -1;
d5c737
         sz += pos0;
d5c737
@@ -247,13 +231,6 @@ parse_scsi(struct device *dev, const char *current, const char *root UNUSED)
d5c737
         ssize_t sz;
d5c737
         int pos;
d5c737
         int rc;
d5c737
-        char *spaces;
d5c737
-
d5c737
-        pos = strlen(current);
d5c737
-        spaces = alloca(pos+1);
d5c737
-        memset(spaces, ' ', pos+1);
d5c737
-        spaces[pos] = '\0';
d5c737
-        pos = 0;
d5c737
 
d5c737
         debug("entry");
d5c737
 
d5c737
@@ -265,7 +242,6 @@ parse_scsi(struct device *dev, const char *current, const char *root UNUSED)
d5c737
                     &dev->scsi_info.scsi_lun,
d5c737
                     &pos;;
d5c737
         debug("current:\"%s\" rc:%d pos:%d\n", dev->device, rc, pos);
d5c737
-        arrow(LOG_DEBUG, spaces, 9, pos, rc, 3);
d5c737
         if (rc != 4)
d5c737
                 return 0;
d5c737
 
d5c737
diff --git a/src/linux-soc-root.c b/src/linux-soc-root.c
d5c737
index 394f496a453..373cd59521a 100644
d5c737
--- a/src/linux-soc-root.c
d5c737
+++ b/src/linux-soc-root.c
d5c737
@@ -43,13 +43,6 @@ parse_soc_root(struct device *dev UNUSED, const char *current, const char *root
d5c737
         int rc;
d5c737
         int pos;
d5c737
         const char *devpart = current;
d5c737
-        char *spaces;
d5c737
-
d5c737
-        pos = strlen(current);
d5c737
-        spaces = alloca(pos+1);
d5c737
-        memset(spaces, ' ', pos+1);
d5c737
-        spaces[pos] = '\0';
d5c737
-        pos = 0;
d5c737
 
d5c737
         debug("entry");
d5c737
 
d5c737
diff --git a/src/linux-virtblk.c b/src/linux-virtblk.c
d5c737
index c54a813a947..2e9889def2f 100644
d5c737
--- a/src/linux-virtblk.c
d5c737
+++ b/src/linux-virtblk.c
d5c737
@@ -50,20 +50,12 @@ parse_virtblk(struct device *dev, const char *current, const char *root UNUSED)
d5c737
         uint32_t tosser;
d5c737
         int pos;
d5c737
         int rc;
d5c737
-        char *spaces;
d5c737
-
d5c737
-        pos = strlen(current);
d5c737
-        spaces = alloca(pos+1);
d5c737
-        memset(spaces, ' ', pos+1);
d5c737
-        spaces[pos] = '\0';
d5c737
-        pos = 0;
d5c737
 
d5c737
         debug("entry");
d5c737
 
d5c737
         debug("searching for virtio0/");
d5c737
         rc = sscanf(current, "virtio%x/%n", &tosser, &pos;;
d5c737
         debug("current:\"%s\" rc:%d pos:%d\n", current, rc, pos);
d5c737
-        arrow(LOG_DEBUG, spaces, 9, pos, rc, 1);
d5c737
         /*
d5c737
          * If we couldn't find virtioX/ then it isn't a virtio device.
d5c737
          */
d5c737
diff --git a/src/util.h b/src/util.h
d5c737
index ba8fee35ae9..6d3c10e946e 100644
d5c737
--- a/src/util.h
d5c737
+++ b/src/util.h
d5c737
@@ -388,7 +388,6 @@ swizzle_guid_to_uuid(efi_guid_t *guid)
d5c737
 #undef log
d5c737
 #endif
d5c737
 #define log(level, fmt, args...) log_(__FILE__, __LINE__, __func__, level, fmt, ## args)
d5c737
-#define arrow(l,b,o,p,n,m) ({if(n==m){char c_=b[p+1]; b[o]='^'; b[p+o]='^';b[p+o+1]='\0';log(l,"%s",b);b[o]=' ';b[p+o]=' ';b[p+o+1]=c_;}})
d5c737
 #define debug(fmt, args...) log(LOG_DEBUG, fmt, ## args)
d5c737
 
d5c737
 #endif /* EFIVAR_UTIL_H */
d5c737
-- 
d5c737
2.26.2
d5c737