[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <YReBCtWxvmDx7Uqg@infradead.org>
Date: Sat, 14 Aug 2021 09:38:34 +0100
From: Christoph Hellwig <hch@...radead.org>
To: Uwe Kleine-K??nig <u.kleine-koenig@...gutronix.de>
Cc: Christoph Hellwig <hch@...radead.org>,
Benjamin Herrenschmidt <benh@...nel.crashing.org>,
linux-pci@...r.kernel.org, Alexander Duyck <alexanderduyck@...com>,
oss-drivers@...igine.com, Paul Mackerras <paulus@...ba.org>,
Herbert Xu <herbert@...dor.apana.org.au>,
Michael Ellerman <mpe@...erman.id.au>,
Rafa?? Mi??ecki <zajec5@...il.com>,
Jesse Brandeburg <jesse.brandeburg@...el.com>,
Bjorn Helgaas <helgaas@...nel.org>,
Ido Schimmel <idosch@...dia.com>,
Jakub Kicinski <kuba@...nel.org>,
Yisen Zhuang <yisen.zhuang@...wei.com>,
Vadym Kochan <vkochan@...vell.com>, Michael Buesch <m@...s.ch>,
Jiri Pirko <jiri@...dia.com>,
Salil Mehta <salil.mehta@...wei.com>,
Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
linux-wireless@...r.kernel.org, linux-kernel@...r.kernel.org,
Taras Chornyi <tchornyi@...vell.com>,
Zhou Wang <wangzhou1@...ilicon.com>,
linux-crypto@...r.kernel.org, kernel@...gutronix.de,
netdev@...r.kernel.org, Simon Horman <simon.horman@...igine.com>,
Oliver O'Halloran <oohall@...il.com>,
linuxppc-dev@...ts.ozlabs.org,
"David S. Miller" <davem@...emloft.net>
Subject: Re: [PATCH v3 4/8] PCI: replace pci_dev::driver usage that gets the
driver name
On Thu, Aug 12, 2021 at 10:14:25AM +0200, Uwe Kleine-K??nig wrote:
> dev_driver_string() might return "" (via dev_bus_name()). If that happens
> *drvstr == '\0' becomes true.
>
> Would the following be better?:
>
> const char *drvstr;
>
> if (pdev)
> return "<null>";
>
> drvstr = dev_driver_string(&pdev->dev);
>
> if (!strcmp(drvstr, ""))
> return "<null>";
>
> return drvstr;
>
> When I thought about this hunk I considered it ugly to have "<null>" in
> it twice.
Well, if you want to avoid that you can do:
if (pdev) {
const char *name = dev_driver_string(&pdev->dev);
if (strcmp(drvstr, ""))
return name;
}
return "<null>";
Which would be a lot more readable.
Powered by blists - more mailing lists