Blame SOURCES/0020-Make-the-debug-code-less-intrusive.patch

821f82
From 154d0794827ffe9fd6adbbdf1cd3d04dba18e24d Mon Sep 17 00:00:00 2001
821f82
From: Peter Jones <pjones@redhat.com>
821f82
Date: Thu, 21 Jun 2018 13:32:28 -0400
821f82
Subject: [PATCH 20/24] Make the debug() code less intrusive
821f82
821f82
Signed-off-by: Peter Jones <pjones@redhat.com>
821f82
---
821f82
 src/creator.c         | 17 +++++++-------
821f82
 src/dp-acpi.c         | 18 +++++++--------
821f82
 src/linux-acpi-root.c | 26 ++++++++++-----------
821f82
 src/linux-acpi.c      | 12 +++++-----
821f82
 src/linux-ata.c       |  6 ++---
821f82
 src/linux-i2o.c       |  2 +-
821f82
 src/linux-nvme.c      | 12 +++++-----
821f82
 src/linux-pci-root.c  | 12 +++++-----
821f82
 src/linux-pci.c       | 22 +++++++++---------
821f82
 src/linux-pmem.c      |  6 ++---
821f82
 src/linux-sas.c       |  4 ++--
821f82
 src/linux-sata.c      | 30 ++++++++++++------------
821f82
 src/linux-scsi.c      | 48 +++++++++++++++++++--------------------
821f82
 src/linux-soc-root.c  |  4 ++--
821f82
 src/linux-virtblk.c   |  8 +++----
821f82
 src/linux.c           | 53 ++++++++++++++++++++-----------------------
821f82
 src/loadopt.c         | 13 +++++------
821f82
 src/util.h            | 14 ++++++++----
821f82
 18 files changed, 154 insertions(+), 153 deletions(-)
821f82
821f82
diff --git a/src/creator.c b/src/creator.c
821f82
index 55b411ee3da..ef782e2b647 100644
821f82
--- a/src/creator.c
821f82
+++ b/src/creator.c
821f82
@@ -178,7 +178,7 @@ efi_va_generate_file_device_path_from_esp(uint8_t *buf, ssize_t size,
821f82
 	int fd = -1;
821f82
 	int saved_errno;
821f82
 
821f82
-	debug(DEBUG, "partition:%d", partition);
821f82
+	debug("partition:%d", partition);
821f82
 
821f82
 	if (buf && size)
821f82
 		memset(buf, '\0', size);
821f82
@@ -198,7 +198,7 @@ efi_va_generate_file_device_path_from_esp(uint8_t *buf, ssize_t size,
821f82
 	if (partition < 0) {
821f82
 		int disk_fd;
821f82
 
821f82
-		debug(DEBUG, "partition: %d", partition);
821f82
+		debug("partition: %d", partition);
821f82
 		disk_fd = open_disk(dev,
821f82
 				    (options & EFIBOOT_OPTIONS_WRITE_SIGNATURE)
821f82
 				     ? O_RDWR : O_RDONLY);
821f82
@@ -211,7 +211,7 @@ efi_va_generate_file_device_path_from_esp(uint8_t *buf, ssize_t size,
821f82
 			partition = 1;
821f82
 		else
821f82
 			partition = 0;
821f82
-		debug(DEBUG, "is_partitioned(): partition -> %d", partition);
821f82
+		debug("is_partitioned(): partition -> %d", partition);
821f82
 
821f82
 		close(disk_fd);
821f82
 	}
821f82
@@ -226,13 +226,13 @@ efi_va_generate_file_device_path_from_esp(uint8_t *buf, ssize_t size,
821f82
 	}
821f82
 
821f82
 	if (options & EFIBOOT_ABBREV_NONE)
821f82
-		debug(DEBUG, "EFIBOOT_ABBREV_NONE");
821f82
+		debug("EFIBOOT_ABBREV_NONE");
821f82
 	if (options & EFIBOOT_ABBREV_HD)
821f82
-		debug(DEBUG, "EFIBOOT_ABBREV_HD");
821f82
+		debug("EFIBOOT_ABBREV_HD");
821f82
 	if (options & EFIBOOT_ABBREV_FILE)
821f82
-		debug(DEBUG, "EFIBOOT_ABBREV_FILE");
821f82
+		debug("EFIBOOT_ABBREV_FILE");
821f82
 	if (options & EFIBOOT_ABBREV_EDD10)
821f82
-		debug(DEBUG, "EFIBOOT_ABBREV_EDD10");
821f82
+		debug("EFIBOOT_ABBREV_EDD10");
821f82
 
821f82
 	if (options & EFIBOOT_ABBREV_EDD10) {
821f82
 		va_list aq;
821f82
@@ -245,6 +245,7 @@ efi_va_generate_file_device_path_from_esp(uint8_t *buf, ssize_t size,
821f82
 
821f82
         if (!(options & (EFIBOOT_ABBREV_FILE|EFIBOOT_ABBREV_HD)) &&
821f82
             (dev->flags & DEV_ABBREV_ONLY)) {
821f82
+                efi_error_clear();
821f82
                 errno = EINVAL;
821f82
                 efi_error("Device must use File() or HD() device path");
821f82
                 goto err;
821f82
@@ -323,7 +324,7 @@ err:
821f82
 	if (fd >= 0)
821f82
 		close(fd);
821f82
 	errno = saved_errno;
821f82
-	debug(DEBUG, "= %zd", ret);
821f82
+	debug("= %zd", ret);
821f82
 	return ret;
821f82
 }
821f82
 
821f82
diff --git a/src/dp-acpi.c b/src/dp-acpi.c
821f82
index a49ef38488c..6f3e94443e5 100644
821f82
--- a/src/dp-acpi.c
821f82
+++ b/src/dp-acpi.c
821f82
@@ -51,9 +51,9 @@ _format_acpi_hid_ex(char *buf, size_t size, const char *dp_type UNUSED,
821f82
 {
821f82
 	ssize_t off = 0;
821f82
 
821f82
-	debug(DEBUG, "hid:0x%08x hidstr:\"%s\"", dp->acpi_hid_ex.hid, hidstr);
821f82
-	debug(DEBUG, "cid:0x%08x cidstr:\"%s\"", dp->acpi_hid_ex.cid, cidstr);
821f82
-	debug(DEBUG, "uid:0x%08x uidstr:\"%s\"", dp->acpi_hid_ex.uid, uidstr);
821f82
+	debug("hid:0x%08x hidstr:\"%s\"", dp->acpi_hid_ex.hid, hidstr);
821f82
+	debug("cid:0x%08x cidstr:\"%s\"", dp->acpi_hid_ex.cid, cidstr);
821f82
+	debug("uid:0x%08x uidstr:\"%s\"", dp->acpi_hid_ex.uid, uidstr);
821f82
 
821f82
 	if (!hidstr && !cidstr && (uidstr || dp->acpi_hid_ex.uid)) {
821f82
 		format(buf, size, off, "AcpiExp",
821f82
@@ -109,12 +109,12 @@ _format_acpi_dn(char *buf, size_t size, const_efidp dp)
821f82
 	// size_t cidlen = 0;
821f82
 
821f82
 	if (dp->subtype == EFIDP_ACPI_ADR) {
821f82
-		debug(DEBUG, "formatting ACPI _ADR");
821f82
+		debug("formatting ACPI _ADR");
821f82
 		format_acpi_adr(buf, size, off, dp);
821f82
 		return off;
821f82
 	} else if (dp->subtype != EFIDP_ACPI_HID_EX &&
821f82
 		   dp->subtype != EFIDP_ACPI_HID) {
821f82
-		debug(DEBUG, "DP subtype %d, formatting as ACPI Path", dp->subtype);
821f82
+		debug("DP subtype %d, formatting as ACPI Path", dp->subtype);
821f82
 		format(buf, size, off, "AcpiPath", "AcpiPath(%d,", dp->subtype);
821f82
 		format_hex(buf, size, off, "AcpiPath", (uint8_t *)dp+4,
821f82
 			   (efidp_node_size(dp)-4) / 2);
821f82
@@ -124,7 +124,7 @@ _format_acpi_dn(char *buf, size_t size, const_efidp dp)
821f82
 		ssize_t limit = efidp_node_size(dp)
821f82
 				- offsetof(efidp_acpi_hid_ex, hidstr);
821f82
 
821f82
-		debug(DEBUG, "formatting ACPI HID EX");
821f82
+		debug("formatting ACPI HID EX");
821f82
 		hidstr = dp->acpi_hid_ex.hidstr;
821f82
 		hidlen = strnlen(hidstr, limit);
821f82
 		limit -= hidlen + 1;
821f82
@@ -230,20 +230,20 @@ _format_acpi_dn(char *buf, size_t size, const_efidp dp)
821f82
 			break;
821f82
 					    }
821f82
 		default:
821f82
-			debug(DEBUG, "Decoding non-well-known HID");
821f82
+			debug("Decoding non-well-known HID");
821f82
 			switch (dp->subtype) {
821f82
 			case EFIDP_ACPI_HID_EX:
821f82
 				format_acpi_hid_ex(buf, size, off, dp,
821f82
 						   hidstr, cidstr, uidstr);
821f82
 				break;
821f82
 			case EFIDP_ACPI_HID:
821f82
-				debug(DEBUG, "Decoding ACPI HID");
821f82
+				debug("Decoding ACPI HID");
821f82
 				format(buf, size, off, "Acpi",
821f82
 				       "Acpi(0x%08x,0x%"PRIx32")",
821f82
 				       dp->acpi_hid.hid, dp->acpi_hid.uid);
821f82
 				break;
821f82
 			default:
821f82
-				debug(DEBUG, "ACPI subtype %d???",
821f82
+				debug("ACPI subtype %d???",
821f82
 				      dp->subtype);
821f82
 				errno = EINVAL;
821f82
 				return -1;
821f82
diff --git a/src/linux-acpi-root.c b/src/linux-acpi-root.c
821f82
index e55af5fa385..06e69eebe78 100644
821f82
--- a/src/linux-acpi-root.c
821f82
+++ b/src/linux-acpi-root.c
821f82
@@ -59,7 +59,7 @@ parse_acpi_root(struct device *dev, const char *current, const char *root UNUSED
821f82
         spaces[pos] = '\0';
821f82
         pos = 0;
821f82
 
821f82
-        debug(DEBUG, "entry");
821f82
+        debug("entry");
821f82
 
821f82
         /*
821f82
          * find the ACPI root dunno0 and dunno1; they basically look like:
821f82
@@ -69,7 +69,7 @@ parse_acpi_root(struct device *dev, const char *current, const char *root UNUSED
821f82
          * side in sscanf.
821f82
          */
821f82
         rc = sscanf(devpart, "../../devices/platform/%n", &pos;;
821f82
-        debug(DEBUG, "devpart:\"%s\" rc:%d pos:%d", devpart, rc, pos);
821f82
+        debug("devpart:\"%s\" rc:%d pos:%d", devpart, rc, pos);
821f82
         if (rc != 0 || pos < 1)
821f82
                 return 0;
821f82
         devpart += pos;
821f82
@@ -100,15 +100,15 @@ parse_acpi_root(struct device *dev, const char *current, const char *root UNUSED
821f82
                 return -1;
821f82
         }
821f82
         dev->acpi_root.acpi_hid_str[pos] = 0;
821f82
-        debug(DEBUG, "acpi_hid_str:\"%s\"", dev->acpi_root.acpi_hid_str);
821f82
+        debug("acpi_hid_str:\"%s\"", dev->acpi_root.acpi_hid_str);
821f82
 
821f82
         pos -= 4;
821f82
-        debug(DEBUG, "devpart:\"%s\" rc:%d pos:%d", devpart, rc, pos);
821f82
+        debug("devpart:\"%s\" rc:%d pos:%d", devpart, rc, pos);
821f82
         acpi_header = strndupa(devpart, pos);
821f82
         if (!acpi_header)
821f82
                 return 0;
821f82
         acpi_header[pos] = 0;
821f82
-        debug(DEBUG, "devpart:\"%s\" acpi_header:\"%s\"", devpart, acpi_header);
821f82
+        debug("devpart:\"%s\" acpi_header:\"%s\"", devpart, acpi_header);
821f82
         devpart += pos;
821f82
 
821f82
         /*
821f82
@@ -119,26 +119,26 @@ parse_acpi_root(struct device *dev, const char *current, const char *root UNUSED
821f82
                 efi_error("Could not parse ACPI path \"%s\"", devpart);
821f82
                 return 0;
821f82
         }
821f82
-        debug(DEBUG, "devpart:\"%s\" parsed:%04hx:%02hhx pos:%d rc:%d",
821f82
+        debug("devpart:\"%s\" parsed:%04hx:%02hhx pos:%d rc:%d",
821f82
               devpart, pad0, pad1, pos, rc);
821f82
 
821f82
         devpart += pos;
821f82
 
821f82
         rc = parse_acpi_hid_uid(dev, "devices/platform/%s%04hX:%02hhX",
821f82
                                 acpi_header, pad0, pad1);
821f82
-        debug(DEBUG, "rc:%d acpi_header:%s pad0:%04hX pad1:%02hhX",
821f82
+        debug("rc:%d acpi_header:%s pad0:%04hX pad1:%02hhX",
821f82
               rc, acpi_header, pad0, pad1);
821f82
         if (rc < 0 && errno == ENOENT) {
821f82
                 rc = parse_acpi_hid_uid(dev, "devices/platform/%s%04hx:%02hhx",
821f82
                                 acpi_header, pad0, pad1);
821f82
-                debug(DEBUG, "rc:%d acpi_header:%s pad0:%04hx pad1:%02hhx",
821f82
+                debug("rc:%d acpi_header:%s pad0:%04hx pad1:%02hhx",
821f82
                       rc, acpi_header, pad0, pad1);
821f82
         }
821f82
         if (rc < 0) {
821f82
                 efi_error("Could not parse hid/uid");
821f82
                 return rc;
821f82
         }
821f82
-        debug(DEBUG, "Parsed HID:0x%08x UID:0x%"PRIx64" uidstr:\"%s\" path:\"%s\"",
821f82
+        debug("Parsed HID:0x%08x UID:0x%"PRIx64" uidstr:\"%s\" path:\"%s\"",
821f82
               dev->acpi_root.acpi_hid, dev->acpi_root.acpi_uid,
821f82
               dev->acpi_root.acpi_uid_str,
821f82
               dev->acpi_root.acpi_cid_str);
821f82
@@ -152,10 +152,10 @@ dp_create_acpi_root(struct device *dev,
821f82
 {
821f82
         ssize_t sz = 0, new = 0;
821f82
 
821f82
-        debug(DEBUG, "entry buf:%p size:%zd off:%zd", buf, size, off);
821f82
+        debug("entry buf:%p size:%zd off:%zd", buf, size, off);
821f82
 
821f82
         if (dev->acpi_root.acpi_uid_str || dev->acpi_root.acpi_cid_str) {
821f82
-                debug(DEBUG, "creating acpi_hid_ex dp hid:0x%08x uid:0x%"PRIx64" uidstr:\"%s\" cidstr:\"%s\"",
821f82
+                debug("creating acpi_hid_ex dp hid:0x%08x uid:0x%"PRIx64" uidstr:\"%s\" cidstr:\"%s\"",
821f82
                       dev->acpi_root.acpi_hid, dev->acpi_root.acpi_uid,
821f82
                       dev->acpi_root.acpi_uid_str, dev->acpi_root.acpi_cid_str);
821f82
                 new = efidp_make_acpi_hid_ex(buf + off, size ? size - off : 0,
821f82
@@ -170,7 +170,7 @@ dp_create_acpi_root(struct device *dev,
821f82
                         return new;
821f82
                 }
821f82
         } else {
821f82
-                debug(DEBUG, "creating acpi_hid dp hid:0x%08x uid:0x%0"PRIx64,
821f82
+                debug("creating acpi_hid dp hid:0x%08x uid:0x%0"PRIx64,
821f82
                       dev->acpi_root.acpi_hid,
821f82
                       dev->acpi_root.acpi_uid);
821f82
                 new = efidp_make_acpi_hid(buf + off, size ? size - off : 0,
821f82
@@ -183,7 +183,7 @@ dp_create_acpi_root(struct device *dev,
821f82
         }
821f82
         sz += new;
821f82
 
821f82
-        debug(DEBUG, "returning %zd", sz);
821f82
+        debug("returning %zd", sz);
821f82
         return sz;
821f82
 }
821f82
 
821f82
diff --git a/src/linux-acpi.c b/src/linux-acpi.c
821f82
index cb93a113ee2..3eac526525f 100644
821f82
--- a/src/linux-acpi.c
821f82
+++ b/src/linux-acpi.c
821f82
@@ -39,12 +39,12 @@ parse_acpi_hid_uid(struct device *dev, const char *fmt, ...)
821f82
         uint32_t acpi_hid = 0;
821f82
         uint64_t acpi_uid_int = 0;
821f82
 
821f82
-        debug(DEBUG, "entry");
821f82
+        debug("entry");
821f82
 
821f82
         va_start(ap, fmt);
821f82
         rc = vasprintfa(&path, fmt, ap);
821f82
         va_end(ap);
821f82
-        debug(DEBUG, "path:%s rc:%d", path, rc);
821f82
+        debug("path:%s rc:%d", path, rc);
821f82
         if (rc < 0 || path == NULL)
821f82
                 return -1;
821f82
 
821f82
@@ -54,7 +54,7 @@ parse_acpi_hid_uid(struct device *dev, const char *fmt, ...)
821f82
                 if (l > 1) {
821f82
                         fbuf[l-1] = 0;
821f82
                         dev->acpi_root.acpi_cid_str = strdup(fbuf);
821f82
-                        debug(DEBUG, "Setting ACPI root path to \"%s\"", fbuf);
821f82
+                        debug("Setting ACPI root path to \"%s\"", fbuf);
821f82
                 }
821f82
         }
821f82
 
821f82
@@ -73,7 +73,7 @@ hid_err:
821f82
         rc -= 4;
821f82
 
821f82
         rc = sscanf((char *)fbuf + rc, "%04hx", &tmp16);
821f82
-        debug(DEBUG, "rc:%d hid:0x%08x\n", rc, tmp16);
821f82
+        debug("rc:%d hid:0x%08x\n", rc, tmp16);
821f82
         if (rc != 1)
821f82
                 goto hid_err;
821f82
 
821f82
@@ -88,7 +88,7 @@ hid_err:
821f82
         if (acpi_hid == EFIDP_ACPI_PCIE_ROOT_HID)
821f82
                 acpi_hid = EFIDP_ACPI_PCI_ROOT_HID;
821f82
         dev->acpi_root.acpi_hid = acpi_hid;
821f82
-        debug(DEBUG, "acpi root HID:0x%08x", acpi_hid);
821f82
+        debug("acpi root HID:0x%08x", acpi_hid);
821f82
 
821f82
         errno = 0;
821f82
         fbuf = NULL;
821f82
@@ -111,7 +111,7 @@ hid_err:
821f82
                         }
821f82
                 }
821f82
         }
821f82
-        debug(DEBUG, "acpi root UID:0x%"PRIx64" uidstr:\"%s\"",
821f82
+        debug("acpi root UID:0x%"PRIx64" uidstr:\"%s\"",
821f82
               dev->acpi_root.acpi_uid, dev->acpi_root.acpi_uid_str);
821f82
 
821f82
         errno = 0;
821f82
diff --git a/src/linux-ata.c b/src/linux-ata.c
821f82
index dab02f3d224..32cb99361e5 100644
821f82
--- a/src/linux-ata.c
821f82
+++ b/src/linux-ata.c
821f82
@@ -64,7 +64,7 @@ parse_ata(struct device *dev, const char *current, const char *root UNUSED)
821f82
         uint64_t scsi_lun;
821f82
         int pos;
821f82
 
821f82
-        debug(DEBUG, "entry");
821f82
+        debug("entry");
821f82
         /* IDE disks can have up to 64 partitions, or 6 bits worth,
821f82
          * and have one bit for the disk number.
821f82
          * This leaves an extra bit at the top.
821f82
@@ -95,7 +95,7 @@ parse_ata(struct device *dev, const char *current, const char *root UNUSED)
821f82
                 dev->interface_type = ata;
821f82
                 set_part(dev, dev->minor & 0x3F);
821f82
         } else {
821f82
-                debug(DEBUG, "If this is ATA, it isn't using a traditional IDE inode.");
821f82
+                debug("If this is ATA, it isn't using a traditional IDE inode.");
821f82
         }
821f82
 
821f82
         if (is_pata(dev)) {
821f82
@@ -136,7 +136,7 @@ dp_create_ata(struct device *dev,
821f82
 {
821f82
         ssize_t sz;
821f82
 
821f82
-        debug(DEBUG, "entry");
821f82
+        debug("entry");
821f82
 
821f82
         sz = efidp_make_atapi(buf + off, size ? size - off : 0,
821f82
                               dev->ata_info.scsi_device,
821f82
diff --git a/src/linux-i2o.c b/src/linux-i2o.c
821f82
index 4fe79e5719f..3ce25b957bf 100644
821f82
--- a/src/linux-i2o.c
821f82
+++ b/src/linux-i2o.c
821f82
@@ -35,7 +35,7 @@
821f82
 static ssize_t
821f82
 parse_i2o(struct device *dev, const char *current UNUSED, const char *root UNUSED)
821f82
 {
821f82
-        debug(DEBUG, "entry");
821f82
+        debug("entry");
821f82
         /* I2O disks can have up to 16 partitions, or 4 bits worth. */
821f82
         if (dev->major >= 80 && dev->major <= 87) {
821f82
                 dev->interface_type = i2o;
821f82
diff --git a/src/linux-nvme.c b/src/linux-nvme.c
821f82
index 00f53d5a9a7..ce931b7e237 100644
821f82
--- a/src/linux-nvme.c
821f82
+++ b/src/linux-nvme.c
821f82
@@ -62,15 +62,15 @@ parse_nvme(struct device *dev, const char *current, const char *root UNUSED)
821f82
         spaces[pos0] = '\0';
821f82
         pos0 = 0;
821f82
 
821f82
-        debug(DEBUG, "entry");
821f82
+        debug("entry");
821f82
 
821f82
-        debug(DEBUG, "searching for nvme/nvme0/nvme0n1 or nvme/nvme0/nvme0n1/nvme0n1p1");
821f82
+        debug("searching for nvme/nvme0/nvme0n1 or nvme/nvme0/nvme0n1/nvme0n1p1");
821f82
         rc = sscanf(current, "nvme/nvme%d/nvme%dn%d%n/nvme%dn%dp%d%n",
821f82
                     &tosser0, &ctrl_id, &ns_id, &pos0,
821f82
                     &tosser1, &tosser2, &partition, &pos1);
821f82
-        debug(DEBUG, "current:\"%s\" rc:%d pos0:%d pos1:%d\n", current, rc, pos0, pos1);
821f82
-        arrow(DEBUG, spaces, 9, pos0, rc, 3);
821f82
-        arrow(DEBUG, spaces, 9, pos1, rc, 6);
821f82
+        debug("current:\"%s\" rc:%d pos0:%d pos1:%d\n", current, rc, pos0, pos1);
821f82
+        arrow(LOG_DEBUG, spaces, 9, pos0, rc, 3);
821f82
+        arrow(LOG_DEBUG, spaces, 9, pos1, rc, 6);
821f82
         /*
821f82
          * If it isn't of that form, it's not one of our nvme devices.
821f82
          */
821f82
@@ -130,7 +130,7 @@ dp_create_nvme(struct device *dev,
821f82
 {
821f82
         ssize_t sz;
821f82
 
821f82
-        debug(DEBUG, "entry");
821f82
+        debug("entry");
821f82
 
821f82
         sz = efidp_make_nvme(buf + off, size ? size - off : 0,
821f82
                              dev->nvme_info.ns_id,
821f82
diff --git a/src/linux-pci-root.c b/src/linux-pci-root.c
821f82
index 8f556a066f3..269e30e2c31 100644
821f82
--- a/src/linux-pci-root.c
821f82
+++ b/src/linux-pci-root.c
821f82
@@ -56,7 +56,7 @@ parse_pci_root(struct device *dev, const char *current, const char *root UNUSED)
821f82
         spaces[pos] = '\0';
821f82
         pos = 0;
821f82
 
821f82
-        debug(DEBUG, "entry");
821f82
+        debug("entry");
821f82
 
821f82
         /*
821f82
          * find the pci root domain and port; they basically look like:
821f82
@@ -87,11 +87,11 @@ static ssize_t
821f82
 dp_create_pci_root(struct device *dev UNUSED,
821f82
                    uint8_t *buf, ssize_t size, ssize_t off)
821f82
 {
821f82
-        debug(DEBUG, "entry buf:%p size:%zd off:%zd", buf, size, off);
821f82
-        debug(DEBUG, "returning 0");
821f82
+        debug("entry buf:%p size:%zd off:%zd", buf, size, off);
821f82
+        debug("returning 0");
821f82
 #if 0
821f82
         if (dev->acpi_root.acpi_uid_str) {
821f82
-                debug(DEBUG, "creating acpi_hid_ex dp hid:0x%08x uid:\"%s\"",
821f82
+                debug("creating acpi_hid_ex dp hid:0x%08x uid:\"%s\"",
821f82
                       dev->acpi_root.acpi_hid,
821f82
                       dev->acpi_root.acpi_uid_str);
821f82
                 new = efidp_make_acpi_hid_ex(buf + off, size ? size - off : 0,
821f82
@@ -104,7 +104,7 @@ dp_create_pci_root(struct device *dev UNUSED,
821f82
                         return new;
821f82
                 }
821f82
         } else {
821f82
-                debug(DEBUG, "creating acpi_hid dp hid:0x%08x uid:0x%0"PRIx64,
821f82
+                debug("creating acpi_hid dp hid:0x%08x uid:0x%0"PRIx64,
821f82
                       dev->acpi_root.acpi_hid,
821f82
                       dev->acpi_root.acpi_uid);
821f82
                 new = efidp_make_acpi_hid(buf + off, size ? size - off : 0,
821f82
@@ -118,7 +118,7 @@ dp_create_pci_root(struct device *dev UNUSED,
821f82
         off += new;
821f82
         sz += new;
821f82
 
821f82
-        debug(DEBUG, "returning %zd", sz);
821f82
+        debug("returning %zd", sz);
821f82
         return sz;
821f82
 #else
821f82
         return 0;
821f82
diff --git a/src/linux-pci.c b/src/linux-pci.c
821f82
index 0f59d3e840d..e7c864b2d33 100644
821f82
--- a/src/linux-pci.c
821f82
+++ b/src/linux-pci.c
821f82
@@ -56,7 +56,7 @@ parse_pci(struct device *dev, const char *current, const char *root)
821f82
         spaces[pos] = '\0';
821f82
         pos = 0;
821f82
 
821f82
-        debug(DEBUG, "entry");
821f82
+        debug("entry");
821f82
 
821f82
         /* find the pci domain/bus/device/function:
821f82
          * 0000:00:01.0/0000:01:00.0/
821f82
@@ -69,16 +69,16 @@ parse_pci(struct device *dev, const char *current, const char *root)
821f82
                 unsigned int i = dev->n_pci_devs;
821f82
 
821f82
                 pos = 0;
821f82
-                debug(DEBUG, "searching for 0000:00:00.0/");
821f82
+                debug("searching for 0000:00:00.0/");
821f82
                 rc = sscanf(devpart, "%hx:%hhx:%hhx.%hhx/%n",
821f82
                             &domain, &bus, &device, &function, &pos;;
821f82
-                debug(DEBUG, "current:\"%s\" rc:%d pos:%d", devpart, rc, pos);
821f82
-                arrow(DEBUG, spaces, 9, pos, rc, 3);
821f82
+                debug("current:\"%s\" rc:%d pos:%d", devpart, rc, pos);
821f82
+                arrow(LOG_DEBUG, spaces, 9, pos, rc, 3);
821f82
                 if (rc != 4)
821f82
                         break;
821f82
                 devpart += pos;
821f82
 
821f82
-                debug(DEBUG, "found pci domain %04hx:%02hhx:%02hhx.%02hhx",
821f82
+                debug("found pci domain %04hx:%02hhx:%02hhx.%02hhx",
821f82
                       domain, bus, device, function);
821f82
                 pci_dev = realloc(dev->pci_dev,
821f82
                                   sizeof(*pci_dev) * (i + 1));
821f82
@@ -108,11 +108,11 @@ parse_pci(struct device *dev, const char *current, const char *root)
821f82
                 }
821f82
                 free(tmp);
821f82
                 dev->pci_dev[i].driverlink = strdup(linkbuf);
821f82
-                debug(DEBUG, "driver:%s\n", linkbuf);
821f82
+                debug("driver:%s\n", linkbuf);
821f82
                 dev->n_pci_devs += 1;
821f82
         }
821f82
 
821f82
-        debug(DEBUG, "next:\"%s\"", devpart);
821f82
+        debug("next:\"%s\"", devpart);
821f82
         return devpart - current;
821f82
 }
821f82
 
821f82
@@ -122,11 +122,11 @@ dp_create_pci(struct device *dev,
821f82
 {
821f82
         ssize_t sz = 0, new = 0;
821f82
 
821f82
-        debug(DEBUG, "entry buf:%p size:%zd off:%zd", buf, size, off);
821f82
+        debug("entry buf:%p size:%zd off:%zd", buf, size, off);
821f82
 
821f82
-        debug(DEBUG, "creating PCI device path nodes");
821f82
+        debug("creating PCI device path nodes");
821f82
         for (unsigned int i = 0; i < dev->n_pci_devs; i++) {
821f82
-                debug(DEBUG, "creating PCI device path node %u", i);
821f82
+                debug("creating PCI device path node %u", i);
821f82
                 new = efidp_make_pci(buf + off, size ? size - off : 0,
821f82
                                     dev->pci_dev[i].pci_device,
821f82
                                     dev->pci_dev[i].pci_function);
821f82
@@ -138,7 +138,7 @@ dp_create_pci(struct device *dev,
821f82
                 off += new;
821f82
         }
821f82
 
821f82
-        debug(DEBUG, "returning %zd", sz);
821f82
+        debug("returning %zd", sz);
821f82
         return sz;
821f82
 }
821f82
 
821f82
diff --git a/src/linux-pmem.c b/src/linux-pmem.c
821f82
index 9a075716f7f..4d981fc8ad3 100644
821f82
--- a/src/linux-pmem.c
821f82
+++ b/src/linux-pmem.c
821f82
@@ -78,7 +78,7 @@ parse_pmem(struct device *dev, const char *current, const char *root UNUSED)
821f82
         int ndbus, region, btt_region_id, btt_id, rc, pos;
821f82
         char *namespace = NULL;
821f82
 
821f82
-        debug(DEBUG, "entry");
821f82
+        debug("entry");
821f82
 
821f82
         if (!strcmp(dev->driver, "nd_pmem")) {
821f82
                 ;
821f82
@@ -121,7 +121,7 @@ parse_pmem(struct device *dev, const char *current, const char *root UNUSED)
821f82
                 return -1;
821f82
 
821f82
         filebuf = NULL;
821f82
-        debug(DEBUG, "nvdimm namespace is \"%s\"", namespace);
821f82
+        debug("nvdimm namespace is \"%s\"", namespace);
821f82
         rc = read_sysfs_file(&filebuf, "bus/nd/devices/%s/uuid", namespace);
821f82
         free(namespace);
821f82
         if (rc < 0 || filebuf == NULL)
821f82
@@ -165,7 +165,7 @@ dp_create_pmem(struct device *dev,
821f82
 {
821f82
         ssize_t sz, sz1;
821f82
 
821f82
-        debug(DEBUG, "entry");
821f82
+        debug("entry");
821f82
 
821f82
         sz = efidp_make_nvdimm(buf + off, size ? size - off : 0,
821f82
                                &dev->nvdimm_info.namespace_label);
821f82
diff --git a/src/linux-sas.c b/src/linux-sas.c
821f82
index 5f44f2c1f7b..4d77d39a24d 100644
821f82
--- a/src/linux-sas.c
821f82
+++ b/src/linux-sas.c
821f82
@@ -55,7 +55,7 @@ parse_sas(struct device *dev, const char *current, const char *root UNUSED)
821f82
         uint8_t *filebuf = NULL;
821f82
         uint64_t sas_address;
821f82
 
821f82
-        debug(DEBUG, "entry");
821f82
+        debug("entry");
821f82
 
821f82
         pos = parse_scsi_link(current, &scsi_host,
821f82
                               &scsi_bus, &scsi_device,
821f82
@@ -111,7 +111,7 @@ dp_create_sas(struct device *dev,
821f82
 {
821f82
         ssize_t sz;
821f82
 
821f82
-        debug(DEBUG, "entry");
821f82
+        debug("entry");
821f82
 
821f82
         sz = efidp_make_sas(buf + off, size ? size - off : 0,
821f82
                             dev->sas_info.sas_address);
821f82
diff --git a/src/linux-sata.c b/src/linux-sata.c
821f82
index d9a62efdbe6..85265022f89 100644
821f82
--- a/src/linux-sata.c
821f82
+++ b/src/linux-sata.c
821f82
@@ -156,9 +156,9 @@ parse_sata(struct device *dev, const char *devlink, const char *root UNUSED)
821f82
         spaces[pos] = '\0';
821f82
         pos = 0;
821f82
 
821f82
-        debug(DEBUG, "entry");
821f82
+        debug("entry");
821f82
         if (is_pata(dev)) {
821f82
-                debug(DEBUG, "This is a PATA device; skipping.");
821f82
+                debug("This is a PATA device; skipping.");
821f82
                 return 0;
821f82
         }
821f82
 
821f82
@@ -166,10 +166,10 @@ parse_sata(struct device *dev, const char *devlink, const char *root UNUSED)
821f82
          * ata1/host0/target0:0:0/0:0:0:0
821f82
          *    ^dev  ^host   x y z
821f82
          */
821f82
-        debug(DEBUG, "searching for ata1/");
821f82
+        debug("searching for ata1/");
821f82
         rc = sscanf(current, "ata%"PRIu32"/%n", &print_id, &pos;;
821f82
-        debug(DEBUG, "current:\"%s\" rc:%d pos:%d\n", current, rc, pos);
821f82
-        arrow(DEBUG, spaces, 9, pos, rc, 1);
821f82
+        debug("current:\"%s\" rc:%d pos:%d\n", current, rc, pos);
821f82
+        arrow(LOG_DEBUG, spaces, 9, pos, rc, 1);
821f82
         /*
821f82
          * If we don't find this one, it isn't an ata device, so return 0 not
821f82
          * error.  Later errors mean it is an ata device, but we can't parse
821f82
@@ -180,30 +180,30 @@ parse_sata(struct device *dev, const char *devlink, const char *root UNUSED)
821f82
         current += pos;
821f82
         pos = 0;
821f82
 
821f82
-        debug(DEBUG, "searching for host0/");
821f82
+        debug("searching for host0/");
821f82
         rc = sscanf(current, "host%"PRIu32"/%n", &scsi_bus, &pos;;
821f82
-        debug(DEBUG, "current:\"%s\" rc:%d pos:%d\n", current, rc, pos);
821f82
-        arrow(DEBUG, spaces, 9, pos, rc, 1);
821f82
+        debug("current:\"%s\" rc:%d pos:%d\n", current, rc, pos);
821f82
+        arrow(LOG_DEBUG, spaces, 9, pos, rc, 1);
821f82
         if (rc != 1)
821f82
                 return -1;
821f82
         current += pos;
821f82
         pos = 0;
821f82
 
821f82
-        debug(DEBUG, "searching for target0:0:0:0/");
821f82
+        debug("searching for target0:0:0:0/");
821f82
         rc = sscanf(current, "target%"PRIu32":%"PRIu32":%"PRIu64"/%n",
821f82
                     &scsi_device, &scsi_target, &scsi_lun, &pos;;
821f82
-        debug(DEBUG, "current:\"%s\" rc:%d pos:%d\n", current, rc, pos);
821f82
-        arrow(DEBUG, spaces, 9, pos, rc, 3);
821f82
+        debug("current:\"%s\" rc:%d pos:%d\n", current, rc, pos);
821f82
+        arrow(LOG_DEBUG, spaces, 9, pos, rc, 3);
821f82
         if (rc != 3)
821f82
                 return -1;
821f82
         current += pos;
821f82
         pos = 0;
821f82
 
821f82
-        debug(DEBUG, "searching for 0:0:0:0/");
821f82
+        debug("searching for 0:0:0:0/");
821f82
         rc = sscanf(current, "%"PRIu32":%"PRIu32":%"PRIu32":%"PRIu64"/%n",
821f82
                     &tosser0, &tosser1, &tosser2, &tosser3, &pos;;
821f82
-        debug(DEBUG, "current:\"%s\" rc:%d pos:%d\n", current, rc, pos);
821f82
-        arrow(DEBUG, spaces, 9, pos, rc, 4);
821f82
+        debug("current:\"%s\" rc:%d pos:%d\n", current, rc, pos);
821f82
+        arrow(LOG_DEBUG, spaces, 9, pos, rc, 4);
821f82
         if (rc != 4)
821f82
                 return -1;
821f82
         current += pos;
821f82
@@ -229,7 +229,7 @@ dp_create_sata(struct device *dev,
821f82
 {
821f82
         ssize_t sz = -1;
821f82
 
821f82
-        debug(DEBUG, "entry buf:%p size:%zd off:%zd", buf, size, off);
821f82
+        debug("entry buf:%p size:%zd off:%zd", buf, size, off);
821f82
 
821f82
         if (dev->interface_type == ata || dev->interface_type == atapi) {
821f82
                 sz = efidp_make_atapi(buf + off, size ? size - off : 0,
821f82
diff --git a/src/linux-scsi.c b/src/linux-scsi.c
821f82
index 153a4ff87ad..80c2fb7d82e 100644
821f82
--- a/src/linux-scsi.c
821f82
+++ b/src/linux-scsi.c
821f82
@@ -51,7 +51,7 @@ parse_scsi_link(const char *current, uint32_t *scsi_host,
821f82
         spaces[sz] = '\0';
821f82
         sz = 0;
821f82
 
821f82
-        debug(DEBUG, "entry");
821f82
+        debug("entry");
821f82
         /*
821f82
          * This structure is completely ridiculous.
821f82
          *
821f82
@@ -82,21 +82,21 @@ parse_scsi_link(const char *current, uint32_t *scsi_host,
821f82
          *    host4/port-4:0
821f82
          * or host4/port-4:0:0
821f82
          */
821f82
-        debug(DEBUG, "searching for host4/");
821f82
+        debug("searching for host4/");
821f82
         rc = sscanf(current, "host%d/%n", scsi_host, &pos0);
821f82
-        debug(DEBUG, "current:\"%s\" rc:%d pos0:%d\n", current+sz, rc, pos0);
821f82
-        arrow(DEBUG, spaces, 9, pos0, rc, 1);
821f82
+        debug("current:\"%s\" rc:%d pos0:%d\n", current+sz, rc, pos0);
821f82
+        arrow(LOG_DEBUG, spaces, 9, pos0, rc, 1);
821f82
         if (rc != 1)
821f82
                 return -1;
821f82
         sz += pos0;
821f82
         pos0 = 0;
821f82
 
821f82
-        debug(DEBUG, "searching for port-4:0 or port-4:0:0");
821f82
+        debug("searching for port-4:0 or port-4:0:0");
821f82
         rc = sscanf(current, "port-%d:%d%n:%d%n", &tosser0,
821f82
                     &tosser1, &pos0, &tosser2, &pos1);
821f82
-        debug(DEBUG, "current:\"%s\" rc:%d pos0:%d pos1:%d\n", current+sz, rc, pos0, pos1);
821f82
-        arrow(DEBUG, spaces, 9, pos0, rc, 2);
821f82
-        arrow(DEBUG, spaces, 9, pos1, rc, 3);
821f82
+        debug("current:\"%s\" rc:%d pos0:%d pos1:%d\n", current+sz, rc, pos0, pos1);
821f82
+        arrow(LOG_DEBUG, spaces, 9, pos0, rc, 2);
821f82
+        arrow(LOG_DEBUG, spaces, 9, pos1, rc, 3);
821f82
         if (rc == 2 || rc == 3) {
821f82
                 sz += pos0;
821f82
                 pos0 = 0;
821f82
@@ -107,18 +107,18 @@ parse_scsi_link(const char *current, uint32_t *scsi_host,
821f82
                  * awesomely these are the exact same fields that go into port-blah,
821f82
                  * but we don't care for now about any of them anyway.
821f82
                  */
821f82
-                debug(DEBUG, "searching for /end_device-4:0/ or /end_device-4:0:0/");
821f82
+                debug("searching for /end_device-4:0/ or /end_device-4:0:0/");
821f82
                 rc = sscanf(current + sz, "/end_device-%d:%d%n", &tosser0, &tosser1, &pos0);
821f82
-                debug(DEBUG, "current:\"%s\" rc:%d pos0:%d\n", current+sz, rc, pos0);
821f82
-                arrow(DEBUG, spaces, 9, pos0, rc, 2);
821f82
+                debug("current:\"%s\" rc:%d pos0:%d\n", current+sz, rc, pos0);
821f82
+                arrow(LOG_DEBUG, spaces, 9, pos0, rc, 2);
821f82
                 if (rc != 2)
821f82
                         return -1;
821f82
                 sz += pos0;
821f82
                 pos0 = 0;
821f82
 
821f82
                 rc = sscanf(current + sz, ":%d%n", &tosser0, &pos0);
821f82
-                debug(DEBUG, "current:\"%s\" rc:%d pos0:%d\n", current+sz, rc, pos0);
821f82
-                arrow(DEBUG, spaces, 9, pos0, rc, 2);
821f82
+                debug("current:\"%s\" rc:%d pos0:%d\n", current+sz, rc, pos0);
821f82
+                arrow(LOG_DEBUG, spaces, 9, pos0, rc, 2);
821f82
                 if (rc != 0 && rc != 1)
821f82
                         return -1;
821f82
                 sz += pos0;
821f82
@@ -134,11 +134,11 @@ parse_scsi_link(const char *current, uint32_t *scsi_host,
821f82
          * /target4:0:0/
821f82
          */
821f82
         uint64_t tosser3;
821f82
-        debug(DEBUG, "searching for target4:0:0/");
821f82
+        debug("searching for target4:0:0/");
821f82
         rc = sscanf(current + sz, "target%d:%d:%"PRIu64"/%n", &tosser0, &tosser1,
821f82
                     &tosser3, &pos0);
821f82
-        debug(DEBUG, "current:\"%s\" rc:%d pos0:%d\n", current+sz, rc, pos0);
821f82
-        arrow(DEBUG, spaces, 9, pos0, rc, 3);
821f82
+        debug("current:\"%s\" rc:%d pos0:%d\n", current+sz, rc, pos0);
821f82
+        arrow(LOG_DEBUG, spaces, 9, pos0, rc, 3);
821f82
         if (rc != 3)
821f82
                 return -1;
821f82
         sz += pos0;
821f82
@@ -147,11 +147,11 @@ parse_scsi_link(const char *current, uint32_t *scsi_host,
821f82
         /* now:
821f82
          * %d:%d:%d:%llu/
821f82
          */
821f82
-        debug(DEBUG, "searching for 4:0:0:0/");
821f82
+        debug("searching for 4:0:0:0/");
821f82
         rc = sscanf(current + sz, "%d:%d:%d:%"PRIu64"/%n",
821f82
                     scsi_bus, scsi_device, scsi_target, scsi_lun, &pos0);
821f82
-        debug(DEBUG, "current:\"%s\" rc:%d pos0:%d\n", current+sz, rc, pos0);
821f82
-        arrow(DEBUG, spaces, 9, pos0, rc, 4);
821f82
+        debug("current:\"%s\" rc:%d pos0:%d\n", current+sz, rc, pos0);
821f82
+        arrow(LOG_DEBUG, spaces, 9, pos0, rc, 4);
821f82
         if (rc != 4)
821f82
                 return -1;
821f82
         sz += pos0;
821f82
@@ -175,17 +175,17 @@ parse_scsi(struct device *dev, const char *current, const char *root UNUSED)
821f82
         spaces[pos] = '\0';
821f82
         pos = 0;
821f82
 
821f82
-        debug(DEBUG, "entry");
821f82
+        debug("entry");
821f82
 
821f82
-        debug(DEBUG, "searching for ../../../0:0:0:0");
821f82
+        debug("searching for ../../../0:0:0:0");
821f82
         rc = sscanf(dev->device, "../../../%d:%d:%d:%"PRIu64"%n",
821f82
                     &dev->scsi_info.scsi_bus,
821f82
                     &dev->scsi_info.scsi_device,
821f82
                     &dev->scsi_info.scsi_target,
821f82
                     &dev->scsi_info.scsi_lun,
821f82
                     &pos;;
821f82
-        debug(DEBUG, "current:\"%s\" rc:%d pos:%d\n", dev->device, rc, pos);
821f82
-        arrow(DEBUG, spaces, 9, pos, rc, 3);
821f82
+        debug("current:\"%s\" rc:%d pos:%d\n", dev->device, rc, pos);
821f82
+        arrow(LOG_DEBUG, spaces, 9, pos, rc, 3);
821f82
         if (rc != 4)
821f82
                 return 0;
821f82
 
821f82
@@ -225,7 +225,7 @@ dp_create_scsi(struct device *dev,
821f82
 {
821f82
         ssize_t sz = 0;
821f82
 
821f82
-        debug(DEBUG, "entry");
821f82
+        debug("entry");
821f82
 
821f82
         sz = efidp_make_scsi(buf + off, size ? size - off : 0,
821f82
                              dev->scsi_info.scsi_target,
821f82
diff --git a/src/linux-soc-root.c b/src/linux-soc-root.c
821f82
index 57dd9b04f2c..394f496a453 100644
821f82
--- a/src/linux-soc-root.c
821f82
+++ b/src/linux-soc-root.c
821f82
@@ -51,13 +51,13 @@ parse_soc_root(struct device *dev UNUSED, const char *current, const char *root
821f82
         spaces[pos] = '\0';
821f82
         pos = 0;
821f82
 
821f82
-        debug(DEBUG, "entry");
821f82
+        debug("entry");
821f82
 
821f82
         rc = sscanf(devpart, "../../devices/platform/soc/%*[^/]/%n", &pos;;
821f82
         if (rc != 0)
821f82
                 return 0;
821f82
         devpart += pos;
821f82
-        debug(DEBUG, "new position is \"%s\"", devpart);
821f82
+        debug("new position is \"%s\"", devpart);
821f82
 
821f82
         return devpart - current;
821f82
 }
821f82
diff --git a/src/linux-virtblk.c b/src/linux-virtblk.c
821f82
index 9ee7994aeb3..c54a813a947 100644
821f82
--- a/src/linux-virtblk.c
821f82
+++ b/src/linux-virtblk.c
821f82
@@ -58,12 +58,12 @@ parse_virtblk(struct device *dev, const char *current, const char *root UNUSED)
821f82
         spaces[pos] = '\0';
821f82
         pos = 0;
821f82
 
821f82
-        debug(DEBUG, "entry");
821f82
+        debug("entry");
821f82
 
821f82
-        debug(DEBUG, "searching for virtio0/");
821f82
+        debug("searching for virtio0/");
821f82
         rc = sscanf(current, "virtio%x/%n", &tosser, &pos;;
821f82
-        debug(DEBUG, "current:\"%s\" rc:%d pos:%d\n", current, rc, pos);
821f82
-        arrow(DEBUG, spaces, 9, pos, rc, 1);
821f82
+        debug("current:\"%s\" rc:%d pos:%d\n", current, rc, pos);
821f82
+        arrow(LOG_DEBUG, spaces, 9, pos, rc, 1);
821f82
         /*
821f82
          * If we couldn't find virtioX/ then it isn't a virtio device.
821f82
          */
821f82
diff --git a/src/linux.c b/src/linux.c
821f82
index 8fe21f19f78..f919dee5b67 100644
821f82
--- a/src/linux.c
821f82
+++ b/src/linux.c
821f82
@@ -178,12 +178,12 @@ set_disk_and_part_name(struct device *dev)
821f82
         char *proximate = pathseg(dev->link, -4);
821f82
 
821f82
         errno = 0;
821f82
-        debug(DEBUG, "dev->disk_name:%p dev->part_name:%p", dev->disk_name, dev->part_name);
821f82
-        debug(DEBUG, "dev->part:%d", dev->part);
821f82
-        debug(DEBUG, "ultimate:\"%s\"", ultimate ? : "");
821f82
-        debug(DEBUG, "penultimate:\"%s\"", penultimate ? : "");
821f82
-        debug(DEBUG, "approximate:\"%s\"", approximate ? : "");
821f82
-        debug(DEBUG, "proximate:\"%s\"", proximate ? : "");
821f82
+        debug("dev->disk_name:%p dev->part_name:%p", dev->disk_name, dev->part_name);
821f82
+        debug("dev->part:%d", dev->part);
821f82
+        debug("ultimate:\"%s\"", ultimate ? : "");
821f82
+        debug("penultimate:\"%s\"", penultimate ? : "");
821f82
+        debug("approximate:\"%s\"", approximate ? : "");
821f82
+        debug("proximate:\"%s\"", proximate ? : "");
821f82
 
821f82
         if (ultimate && penultimate &&
821f82
             ((proximate && !strcmp(proximate, "nvme")) ||
821f82
@@ -197,14 +197,14 @@ set_disk_and_part_name(struct device *dev)
821f82
                  */
821f82
                 set_disk_name(dev, "%s", penultimate);
821f82
                 set_part_name(dev, "%s", ultimate);
821f82
-                debug(DEBUG, "disk:%s part:%s", penultimate, ultimate);
821f82
+                debug("disk:%s part:%s", penultimate, ultimate);
821f82
         } else if (ultimate && approximate && !strcmp(approximate, "nvme")) {
821f82
                 /*
821f82
                  * 259:0 -> ../../devices/pci0000:00/0000:00:1d.0/0000:05:00.0/nvme/nvme0/nvme0n1
821f82
                  */
821f82
                 set_disk_name(dev, "%s", ultimate);
821f82
                 set_part_name(dev, "%sp%d", ultimate, dev->part);
821f82
-                debug(DEBUG, "disk:%s part:%sp%d", ultimate, ultimate, dev->part);
821f82
+                debug("disk:%s part:%sp%d", ultimate, ultimate, dev->part);
821f82
         } else if (ultimate && penultimate && !strcmp(penultimate, "block")) {
821f82
                 /*
821f82
                  * 253:0 -> ../../devices/virtual/block/dm-0 (... I guess)
821f82
@@ -217,13 +217,13 @@ set_disk_and_part_name(struct device *dev)
821f82
                  */
821f82
                 set_disk_name(dev, "%s", ultimate);
821f82
                 set_part_name(dev, "%s%d", ultimate, dev->part);
821f82
-                debug(DEBUG, "disk:%s part:%s%d", ultimate, ultimate, dev->part);
821f82
+                debug("disk:%s part:%s%d", ultimate, ultimate, dev->part);
821f82
         } else if (ultimate && approximate && !strcmp(approximate, "mtd")) {
821f82
                 /*
821f82
                  * 31:0 -> ../../devices/platform/1e000000.palmbus/1e000b00.spi/spi_master/spi32766/spi32766.0/mtd/mtd0/mtdblock0
821f82
                  */
821f82
                 set_disk_name(dev, "%s", ultimate);
821f82
-                debug(DEBUG, "disk:%s", ultimate);
821f82
+                debug("disk:%s", ultimate);
821f82
         }
821f82
 
821f82
         return 0;
821f82
@@ -321,7 +321,7 @@ struct device HIDDEN
821f82
         }
821f82
 
821f82
         dev->part = partition;
821f82
-        debug(DEBUG, "partition:%d dev->part:%d", partition, dev->part);
821f82
+        debug("partition:%d dev->part:%d", partition, dev->part);
821f82
         dev->probes = calloc(nmemb, sizeof(struct dev_probe *));
821f82
         if (!dev->probes) {
821f82
                 efi_error("could not allocate %zd bytes",
821f82
@@ -362,7 +362,7 @@ struct device HIDDEN
821f82
                 efi_error("strdup(\"%s\") failed", linkbuf);
821f82
                 goto err;
821f82
         }
821f82
-        debug(DEBUG, "dev->link: %s", dev->link);
821f82
+        debug("dev->link: %s", dev->link);
821f82
 
821f82
         if (dev->part == -1) {
821f82
                 rc = read_sysfs_file(&tmpbuf, "dev/block/%s/partition", dev->link);
821f82
@@ -380,8 +380,8 @@ struct device HIDDEN
821f82
                 efi_error("could not set disk and partition names");
821f82
                 goto err;
821f82
         }
821f82
-        debug(DEBUG, "dev->disk_name: %s", dev->disk_name);
821f82
-        debug(DEBUG, "dev->part_name: %s", dev->part_name);
821f82
+        debug("dev->disk_name: %s", dev->disk_name);
821f82
+        debug("dev->part_name: %s", dev->part_name);
821f82
 
821f82
         rc = sysfs_readlink(&tmpbuf, "block/%s/device", dev->disk_name);
821f82
         if (rc < 0 || !tmpbuf) {
821f82
@@ -431,25 +431,25 @@ struct device HIDDEN
821f82
         bool needs_root = true;
821f82
         int last_successful_probe = -1;
821f82
 
821f82
-        debug(DEBUG, "searching for device nodes in %s", dev->link);
821f82
+        debug("searching for device nodes in %s", dev->link);
821f82
         for (i = 0; dev_probes[i] && dev_probes[i]->parse; i++) {
821f82
                 struct dev_probe *probe = dev_probes[i];
821f82
                 ssize_t pos;
821f82
 
821f82
                 if (!needs_root &&
821f82
                     (probe->flags & DEV_PROVIDES_ROOT)) {
821f82
-                        debug(DEBUG, "not testing %s because flags is 0x%x",
821f82
+                        debug("not testing %s because flags is 0x%x",
821f82
                               probe->name, probe->flags);
821f82
                         continue;
821f82
                 }
821f82
 
821f82
-                debug(DEBUG, "trying %s", probe->name);
821f82
+                debug("trying %s", probe->name);
821f82
                 pos = probe->parse(dev, current, dev->link);
821f82
                 if (pos < 0) {
821f82
                         efi_error("parsing %s failed", probe->name);
821f82
                         goto err;
821f82
                 } else if (pos > 0) {
821f82
-                        debug(DEBUG, "%s matched %s", probe->name, current);
821f82
+                        debug("%s matched %s", probe->name, current);
821f82
                         dev->flags |= probe->flags;
821f82
 
821f82
                         if (probe->flags & DEV_PROVIDES_HD ||
821f82
@@ -459,7 +459,7 @@ struct device HIDDEN
821f82
 
821f82
                         dev->probes[n++] = dev_probes[i];
821f82
                         current += pos;
821f82
-                        debug(DEBUG, "current:%s", current);
821f82
+                        debug("current:%s", current);
821f82
                         last_successful_probe = i;
821f82
 
821f82
                         if (!*current || !strncmp(current, "block/", 6))
821f82
@@ -468,7 +468,7 @@ struct device HIDDEN
821f82
                         continue;
821f82
                 }
821f82
 
821f82
-                debug(DEBUG, "dev_probes[i+1]: %p dev->interface_type: %d\n",
821f82
+                debug("dev_probes[i+1]: %p dev->interface_type: %d\n",
821f82
                       dev_probes[i+1], dev->interface_type);
821f82
                 if (dev_probes[i+1] == NULL && dev->interface_type == unknown) {
821f82
                         int new_pos = 0;
821f82
@@ -479,12 +479,9 @@ struct device HIDDEN
821f82
                                      current);
821f82
                                 goto err;
821f82
                         }
821f82
-                        debug(DEBUG,
821f82
-                              "Cannot parse device link segment \"%s\"",
821f82
-                              current);
821f82
-                        debug(DEBUG, "Skipping to \"%s\"", current + new_pos);
821f82
-                        debug(DEBUG,
821f82
-                              "This means we can only write abbreviated paths");
821f82
+                        debug("Cannot parse device link segment \"%s\"", current);
821f82
+                        debug("Skipping to \"%s\"", current + pos);
821f82
+                        debug("This means we can only create abbreviated paths");
821f82
                         if (rc < 0)
821f82
                                 goto err;
821f82
                         if (new_pos == 0)
821f82
@@ -512,7 +509,7 @@ make_blockdev_path(uint8_t *buf, ssize_t size, struct device *dev)
821f82
 {
821f82
         ssize_t off = 0;
821f82
 
821f82
-        debug(DEBUG, "entry buf:%p size:%zd", buf, size);
821f82
+        debug("entry buf:%p size:%zd", buf, size);
821f82
 
821f82
         for (unsigned int i = 0; dev->probes[i] &&
821f82
                                  dev->probes[i]->parse; i++) {
821f82
@@ -531,7 +528,7 @@ make_blockdev_path(uint8_t *buf, ssize_t size, struct device *dev)
821f82
                 off += sz;
821f82
         }
821f82
 
821f82
-        debug(DEBUG, "= %zd", off);
821f82
+        debug("= %zd", off);
821f82
 
821f82
         return off;
821f82
 }
821f82
diff --git a/src/loadopt.c b/src/loadopt.c
821f82
index 23911f6e742..85fb646d107 100644
821f82
--- a/src/loadopt.c
821f82
+++ b/src/loadopt.c
821f82
@@ -46,7 +46,7 @@ efi_loadopt_create(uint8_t *buf, ssize_t size, uint32_t attributes,
821f82
 		     + sizeof (uint16_t) + desc_len
821f82
 		     + dp_size + optional_data_size;
821f82
 
821f82
-	debug(DEBUG, "entry buf:%p size:%zd dp:%p dp_size:%zd",
821f82
+	debug("entry buf:%p size:%zd dp:%p dp_size:%zd",
821f82
 	      buf, size, dp, dp_size);
821f82
 
821f82
 	if (size == 0)
821f82
@@ -57,31 +57,30 @@ efi_loadopt_create(uint8_t *buf, ssize_t size, uint32_t attributes,
821f82
 		return -1;
821f82
 	}
821f82
 
821f82
-	debug(DEBUG, "testing buf");
821f82
+	debug("testing buf");
821f82
 	if (!buf) {
821f82
 invalid:
821f82
 		errno = EINVAL;
821f82
 		return -1;
821f82
 	}
821f82
 
821f82
-	debug(DEBUG, "testing optional data presence");
821f82
+	debug("testing optional data presence");
821f82
 	if (!optional_data && optional_data_size != 0)
821f82
 		goto invalid;
821f82
 
821f82
-	debug(DEBUG, "testing dp presence");
821f82
+	debug("testing dp presence");
821f82
 	if ((!dp && dp_size == 0) || dp_size < 0)
821f82
 		goto invalid;
821f82
 
821f82
 	if (dp) {
821f82
-		debug(DEBUG, "testing dp validity");
821f82
+		debug("testing dp validity");
821f82
 		if (!efidp_is_valid(dp, dp_size)) {
821f82
 			if (efi_get_verbose() >= 1)
821f82
 				hexdump((void *)dp, dp_size);
821f82
 			goto invalid;
821f82
 		}
821f82
 
821f82
-		debug(DEBUG,
821f82
-		      "testing dp size: dp_size:%zd efidp_size(dp):%zd",
821f82
+		debug("testing dp size: dp_size:%zd efidp_size(dp):%zd",
821f82
 		      dp_size, efidp_size(dp));
821f82
 		if (efidp_size(dp) != dp_size) {
821f82
 			if (efi_get_verbose() >= 1)
821f82
diff --git a/src/util.h b/src/util.h
821f82
index 441ced84fcf..f63a8907611 100644
821f82
--- a/src/util.h
821f82
+++ b/src/util.h
821f82
@@ -360,7 +360,7 @@ swizzle_guid_to_uuid(efi_guid_t *guid)
821f82
         u16[1] = __builtin_bswap16(u16[1]);
821f82
 }
821f82
 
821f82
-#define debug_(file, line, func, level, fmt, args...)                   \
821f82
+#define log_(file, line, func, level, fmt, args...)                     \
821f82
         ({                                                              \
821f82
                 if (efi_get_verbose() >= level) {                       \
821f82
                         FILE *logfile_ = efi_get_logfile();             \
821f82
@@ -373,9 +373,13 @@ swizzle_guid_to_uuid(efi_guid_t *guid)
821f82
                 }                                                       \
821f82
         })
821f82
 
821f82
-#define debug(level, fmt, args...) debug_(__FILE__, __LINE__, __func__, level, fmt, ## args)
821f82
-#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';debug(l,"%s",b);b[o]=' ';b[p+o]=' ';b[p+o+1]=c_;}})
821f82
-
821f82
-#define DEBUG 1
821f82
+#define LOG_VERBOSE 0
821f82
+#define LOG_DEBUG 1
821f82
+#ifdef log
821f82
+#undef log
821f82
+#endif
821f82
+#define log(level, fmt, args...) log_(__FILE__, __LINE__, __func__, level, fmt, ## args)
821f82
+#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_;}})
821f82
+#define debug(fmt, args...) log(LOG_DEBUG, fmt, ## args)
821f82
 
821f82
 #endif /* EFIVAR_UTIL_H */
821f82
-- 
821f82
2.17.1
821f82