public inbox for linux-scsi@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] xen/scsifront: shost_priv() can never return NULL
@ 2023-08-22  6:48 Juergen Gross
  2023-08-25  2:07 ` Martin K. Petersen
  2023-08-31  1:48 ` Martin K. Petersen
  0 siblings, 2 replies; 3+ messages in thread
From: Juergen Gross @ 2023-08-22  6:48 UTC (permalink / raw)
  To: linux-kernel, linux-scsi
  Cc: Juergen Gross, Stefano Stabellini, Oleksandr Tyshchenko,
	James E.J. Bottomley, Martin K. Petersen, xen-devel,
	Dan Carpenter

There is no need to check whether shost_priv() returns a non-NULL
value, as the pointer returned is just an offset to the passed in
parameter.

While at it replace an open coded shost_priv() instance.

Reported-by: Dan Carpenter <dan.carpenter@linaro.org>
Signed-off-by: Juergen Gross <jgross@suse.com>
---
 drivers/scsi/xen-scsifront.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/scsi/xen-scsifront.c b/drivers/scsi/xen-scsifront.c
index caae61aa2afe..9ec55ddc1204 100644
--- a/drivers/scsi/xen-scsifront.c
+++ b/drivers/scsi/xen-scsifront.c
@@ -743,7 +743,7 @@ static int scsifront_sdev_configure(struct scsi_device *sdev)
 	if (info->host_active == STATE_ERROR)
 		return -EIO;
 
-	if (info && current == info->curr) {
+	if (current == info->curr) {
 		err = xenbus_printf(XBT_NIL, info->dev->nodename,
 			      info->dev_state_path, "%d", XenbusStateConnected);
 		if (err) {
@@ -761,7 +761,7 @@ static void scsifront_sdev_destroy(struct scsi_device *sdev)
 	struct vscsifrnt_info *info = shost_priv(sdev->host);
 	int err;
 
-	if (info && current == info->curr) {
+	if (current == info->curr) {
 		err = xenbus_printf(XBT_NIL, info->dev->nodename,
 			      info->dev_state_path, "%d", XenbusStateClosed);
 		if (err)
@@ -903,7 +903,7 @@ static int scsifront_probe(struct xenbus_device *dev,
 		xenbus_dev_fatal(dev, err, "fail to allocate scsi host");
 		return err;
 	}
-	info = (struct vscsifrnt_info *)host->hostdata;
+	info = shost_priv(host);
 
 	dev_set_drvdata(&dev->dev, info);
 	info->dev = dev;
-- 
2.35.3


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] xen/scsifront: shost_priv() can never return NULL
  2023-08-22  6:48 [PATCH] xen/scsifront: shost_priv() can never return NULL Juergen Gross
@ 2023-08-25  2:07 ` Martin K. Petersen
  2023-08-31  1:48 ` Martin K. Petersen
  1 sibling, 0 replies; 3+ messages in thread
From: Martin K. Petersen @ 2023-08-25  2:07 UTC (permalink / raw)
  To: Juergen Gross
  Cc: linux-kernel, linux-scsi, Stefano Stabellini,
	Oleksandr Tyshchenko, James E.J. Bottomley, Martin K. Petersen,
	xen-devel, Dan Carpenter


Juergen,

> There is no need to check whether shost_priv() returns a non-NULL
> value, as the pointer returned is just an offset to the passed in
> parameter.
>
> While at it replace an open coded shost_priv() instance.

Applied to 6.6/scsi-staging, thanks!

-- 
Martin K. Petersen	Oracle Linux Engineering

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] xen/scsifront: shost_priv() can never return NULL
  2023-08-22  6:48 [PATCH] xen/scsifront: shost_priv() can never return NULL Juergen Gross
  2023-08-25  2:07 ` Martin K. Petersen
@ 2023-08-31  1:48 ` Martin K. Petersen
  1 sibling, 0 replies; 3+ messages in thread
From: Martin K. Petersen @ 2023-08-31  1:48 UTC (permalink / raw)
  To: linux-kernel, linux-scsi, Juergen Gross
  Cc: Martin K . Petersen, Stefano Stabellini, Oleksandr Tyshchenko,
	James E.J. Bottomley, xen-devel, Dan Carpenter

On Tue, 22 Aug 2023 08:48:17 +0200, Juergen Gross wrote:

> There is no need to check whether shost_priv() returns a non-NULL
> value, as the pointer returned is just an offset to the passed in
> parameter.
> 
> While at it replace an open coded shost_priv() instance.
> 
> 
> [...]

Applied to 6.6/scsi-queue, thanks!

[1/1] xen/scsifront: shost_priv() can never return NULL
      https://git.kernel.org/mkp/scsi/c/73c7881b5066

-- 
Martin K. Petersen	Oracle Linux Engineering

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2023-08-31  1:49 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-08-22  6:48 [PATCH] xen/scsifront: shost_priv() can never return NULL Juergen Gross
2023-08-25  2:07 ` Martin K. Petersen
2023-08-31  1:48 ` Martin K. Petersen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox