]> mj.ucw.cz Git - pciutils.git/blobdiff - ls-tree.c
cxl: Rename variable to match other code
[pciutils.git] / ls-tree.c
index fede581156e4d288759f3809bf467f2b3af37d89..cc65ac472097b36d93100e7ba6821ebf873fecfd 100644 (file)
--- a/ls-tree.c
+++ b/ls-tree.c
@@ -107,7 +107,7 @@ grow_tree(void)
     {
       struct pci_dev *dd = d->dev;
       word class = dd->device_class;
-      byte ht = get_conf_byte(d, PCI_HEADER_TYPE) & 0x7f;
+      byte ht = d->no_config_access ? -1 : (get_conf_byte(d, PCI_HEADER_TYPE) & 0x7f);
       if ((class >> 8) == PCI_BASE_CLASS_BRIDGE &&
          (ht == PCI_HEADER_TYPE_BRIDGE || ht == PCI_HEADER_TYPE_CARDBUS))
        {
@@ -239,7 +239,11 @@ tree_printf(char *line, char *p, char *fmt, ...)
       p += space;
     }
   else if (res >= space)
-    p += space;
+    {
+      /* Ancient C libraries do not truncate the output properly. */
+      *(p+space-1) = 0;
+      p += space;
+    }
   else
     p += res;
 
@@ -258,7 +262,9 @@ show_tree_dev(struct device *d, char *line, char *p)
   for (b=&host_bridge; b; b=b->chain)
     if (b->br_dev == d)
       {
-       if (b->secondary == b->subordinate)
+       if (b->secondary == 0)
+         p = tree_printf(line, p, "-");
+       else if (b->secondary == b->subordinate)
          p = tree_printf(line, p, "-[%02x]-", b->secondary);
        else
          p = tree_printf(line, p, "-[%02x-%02x]-", b->secondary, b->subordinate);