Skip to contentSkip to conversation

xen/scsifront: shost_priv() can never return NULL

PATCH Applied Juergen Gross 2 participants 3 messages Aug 22, 2023 – Aug 31, 2023

Subsystems (3)
lore
Share & tools
lore

Juergen Gross

author maintainer
#0 lore raw

PATCH 1/1 xen/scsifront: shost_priv() can never return NULL

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.

---
 drivers/scsi/xen-scsifront.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/scsi/xen-scsifront.c +3 -3
index caae61aa2afe..9ec55ddc1204 100644
@@ -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;
Signature · 1 line
2.35.3
#1 lore raw

Juergen,

Quoted 5 lines

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!

Signature · 1 line
Martin K. Petersen	Oracle Linux Engineering
#2 lore raw
In reply to Juergen Gross
Quoted 8 lines · Juergen Gross

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
Signature · 1 line
Martin K. Petersen	Oracle Linux Engineering