From 8c95b155acbb590bea134a94f0410e496bc3e646 Mon Sep 17 00:00:00 2001 From: jan Date: Fri, 5 Mar 2021 20:06:39 +0000 Subject: [PATCH] Avoid print for NULL pointer The subclass arrays have to be empty. OK deraadt@ --- usr.sbin/pcidump/pcidump.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/usr.sbin/pcidump/pcidump.c b/usr.sbin/pcidump/pcidump.c index 97c9ad1f2c3..bc98460cda6 100644 --- a/usr.sbin/pcidump/pcidump.c +++ b/usr.sbin/pcidump/pcidump.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pcidump.c,v 1.62 2021/03/05 12:57:20 jan Exp $ */ +/* $OpenBSD: pcidump.c,v 1.63 2021/03/05 20:06:39 jan Exp $ */ /* * Copyright (c) 2006, 2007 David Gwynne @@ -1296,8 +1296,8 @@ static const struct pci_subclass pci_subclass_dasp[] = { { PCI_SUBCLASS_DASP_MISC, "Miscellaneous" }, }; -static const struct pci_subclass pci_subclass_accelerator[] = {0}; -static const struct pci_subclass pci_subclass_instrumentation[] = {0}; +static const struct pci_subclass pci_subclass_accelerator[] = {}; +static const struct pci_subclass pci_subclass_instrumentation[] = {}; #define CLASS(_c, _n, _s) { \ .class = _c, \ @@ -1389,7 +1389,6 @@ pci_class_name(pci_class_t class) return (pc->name); } - static const char * pci_subclass_name(pci_class_t class, pci_subclass_t subclass) { @@ -1401,7 +1400,7 @@ pci_subclass_name(pci_class_t class, pci_subclass_t subclass) return ("(unknown)"); ps = pci_subclass(pc, subclass); - if (ps == NULL) + if (ps == NULL || ps->name == NULL) return ("(unknown)"); return (ps->name); -- 2.20.1