Netdev Archive on lore.kernel.org
help / color / mirror / Atom feed
From: Christoph Hellwig <hch@infradead.org>
To: Uwe Kleine-K??nig <u.kleine-koenig@pengutronix.de>
Cc: Christoph Hellwig <hch@infradead.org>,
	Benjamin Herrenschmidt <benh@kernel.crashing.org>,
	linux-pci@vger.kernel.org,
	Alexander Duyck <alexanderduyck@fb.com>,
	oss-drivers@corigine.com, Paul Mackerras <paulus@samba.org>,
	Herbert Xu <herbert@gondor.apana.org.au>,
	Michael Ellerman <mpe@ellerman.id.au>,
	Rafa?? Mi??ecki <zajec5@gmail.com>,
	Jesse Brandeburg <jesse.brandeburg@intel.com>,
	Bjorn Helgaas <helgaas@kernel.org>,
	Ido Schimmel <idosch@nvidia.com>,
	Jakub Kicinski <kuba@kernel.org>,
	Yisen Zhuang <yisen.zhuang@huawei.com>,
	Vadym Kochan <vkochan@marvell.com>, Michael Buesch <m@bues.ch>,
	Jiri Pirko <jiri@nvidia.com>,
	Salil Mehta <salil.mehta@huawei.com>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	linux-wireless@vger.kernel.org, linux-kernel@vger.kernel.org,
	Taras Chornyi <tchornyi@marvell.com>,
	Zhou Wang <wangzhou1@hisilicon.com>,
	linux-crypto@vger.kernel.org, kernel@pengutronix.de,
	netdev@vger.kernel.org, Simon Horman <simon.horman@corigine.com>,
	Oliver O'Halloran <oohall@gmail.com>,
	linuxppc-dev@lists.ozlabs.org,
	"David S. Miller" <davem@davemloft.net>
Subject: Re: [PATCH v3 4/8] PCI: replace pci_dev::driver usage that gets the driver name
Date: Sat, 14 Aug 2021 09:38:34 +0100	[thread overview]
Message-ID: <YReBCtWxvmDx7Uqg@infradead.org> (raw)
In-Reply-To: <20210812081425.7pjy4a25e2ehkr3x@pengutronix.de>

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.

      reply	other threads:[~2021-08-14  8:39 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-11  8:06 [PATCH v3 0/8] PCI: Drop duplicated tracking of a pci_dev's bound driver Uwe Kleine-König
2021-08-11  8:06 ` [PATCH v3 4/8] PCI: replace pci_dev::driver usage that gets the driver name Uwe Kleine-König
2021-08-12  7:07   ` Christoph Hellwig
2021-08-12  8:14     ` Uwe Kleine-König
2021-08-14  8:38       ` Christoph Hellwig [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=YReBCtWxvmDx7Uqg@infradead.org \
    --to=hch@infradead.org \
    --cc=alexanderduyck@fb.com \
    --cc=benh@kernel.crashing.org \
    --cc=davem@davemloft.net \
    --cc=gregkh@linuxfoundation.org \
    --cc=helgaas@kernel.org \
    --cc=herbert@gondor.apana.org.au \
    --cc=idosch@nvidia.com \
    --cc=jesse.brandeburg@intel.com \
    --cc=jiri@nvidia.com \
    --cc=kernel@pengutronix.de \
    --cc=kuba@kernel.org \
    --cc=linux-crypto@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pci@vger.kernel.org \
    --cc=linux-wireless@vger.kernel.org \
    --cc=linuxppc-dev@lists.ozlabs.org \
    --cc=m@bues.ch \
    --cc=mpe@ellerman.id.au \
    --cc=netdev@vger.kernel.org \
    --cc=oohall@gmail.com \
    --cc=oss-drivers@corigine.com \
    --cc=paulus@samba.org \
    --cc=salil.mehta@huawei.com \
    --cc=simon.horman@corigine.com \
    --cc=tchornyi@marvell.com \
    --cc=u.kleine-koenig@pengutronix.de \
    --cc=vkochan@marvell.com \
    --cc=wangzhou1@hisilicon.com \
    --cc=yisen.zhuang@huawei.com \
    --cc=zajec5@gmail.com \
    --subject='Re: [PATCH v3 4/8] PCI: replace pci_dev::driver usage that gets the driver name' \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).