efivar/SOURCES/0005-Get-rid-of-the-arrows-in-our-debug-messages.patch
2021-12-09 11:57:18 +00:00

373 lines
14 KiB
Diff

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