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

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