All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] fix warning and missing failure handling for scsi_add_host in aic7xxx driver
@ 2005-12-13 23:07 Jesper Juhl
  2005-12-14  4:33 ` James Bottomley
  0 siblings, 1 reply; 5+ messages in thread
From: Jesper Juhl @ 2005-12-13 23:07 UTC (permalink / raw)
  To: Linux Kernel Mailing List
  Cc: linux-scsi, James E.J. Bottomley, Daniel M. Eischen,
	Doug Ledford, James.Bottomley, Jesper Juhl

Hi,

Here's a patch to fix a compiler warning and problem with missing failure 
handling of scsi_add_host noted in comment in aic7xxx_osm

The warning I see (with 2.6.15-rc5-git3) is this one:
drivers/scsi/aic7xxx/aic7xxx_osm.c:1100: warning: ignoring return value of \x13csi_add_host', declared with attribute warn_unused_result

The patch has seen the following testing:
 - compile tested
 - boot tested on a machine using the AIC7XXX driver

Please review and consider for inclusion.


Signed-off-by: Jesper Juhl <jeser.juhl@gmail.com>
---

 drivers/scsi/aic7xxx/aic7xxx_osm.c |   22 +++++++++++++++++-----
 1 files changed, 17 insertions(+), 5 deletions(-)

--- linux-2.6.15-rc5-git3-orig/drivers/scsi/aic7xxx/aic7xxx_osm.c	2005-12-04 18:48:12.000000000 +0100
+++ linux-2.6.15-rc5-git3/drivers/scsi/aic7xxx/aic7xxx_osm.c	2005-12-13 23:47:45.000000000 +0100
@@ -1061,10 +1061,11 @@ uint32_t aic7xxx_verbose;
 int
 ahc_linux_register_host(struct ahc_softc *ahc, struct scsi_host_template *template)
 {
-	char	 buf[80];
-	struct	 Scsi_Host *host;
+	char	buf[80];
+	struct	Scsi_Host *host;
 	char	*new_name;
-	u_long	 s;
+	u_long	s;
+	int	retval = 0;
 
 	template->name = ahc->description;
 	host = scsi_host_alloc(template, sizeof(struct ahc_softc *));
@@ -1097,9 +1098,20 @@ ahc_linux_register_host(struct ahc_softc
 
 	host->transportt = ahc_linux_transport_template;
 
-	scsi_add_host(host, (ahc->dev_softc ? &ahc->dev_softc->dev : NULL)); /* XXX handle failure */
+	retval = scsi_add_host(host,
+			(ahc->dev_softc ? &ahc->dev_softc->dev : NULL));
+	if (retval) {
+		printk(KERN_ERR "aic7xxx: scsi_add_host failed\n");
+		goto free_and_out;
+	}
+
 	scsi_scan_host(host);
-	return (0);
+
+out:
+	return retval;
+free_and_out:
+	scsi_remove_host(host);
+	goto out;
 }
 
 /*

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

* Re: [PATCH] fix warning and missing failure handling for scsi_add_host in aic7xxx driver
  2005-12-13 23:07 [PATCH] fix warning and missing failure handling for scsi_add_host in aic7xxx driver Jesper Juhl
@ 2005-12-14  4:33 ` James Bottomley
  2005-12-14  8:02   ` Jesper Juhl
  0 siblings, 1 reply; 5+ messages in thread
From: James Bottomley @ 2005-12-14  4:33 UTC (permalink / raw)
  To: Jesper Juhl
  Cc: Linux Kernel Mailing List, linux-scsi, Daniel M. Eischen, Doug Ledford

On Wed, 2005-12-14 at 00:07 +0100, Jesper Juhl wrote:
> +	if (retval) {
> +		printk(KERN_ERR "aic7xxx: scsi_add_host failed\n");
> +		goto free_and_out;
> +	}
> +
>  	scsi_scan_host(host);
> -	return (0);
> +
> +out:
> +	return retval;
> +free_and_out:
> +	scsi_remove_host(host);
> +	goto out;

I'm not incredibly keen on all this jumping around for no reason.  If
there's a normal out and an error out, then fine, but in this case the
if (retval) { } could contain the entirety of the error path with an
else for the normal path.

scsi_remove_host() is the wrong API, it should be scsi_host_put() (for
an allocated but un added host).

James



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

* Re: [PATCH] fix warning and missing failure handling for scsi_add_host in aic7xxx driver
  2005-12-14  4:33 ` James Bottomley
@ 2005-12-14  8:02   ` Jesper Juhl
  2005-12-14  8:20     ` James Bottomley
  0 siblings, 1 reply; 5+ messages in thread
From: Jesper Juhl @ 2005-12-14  8:02 UTC (permalink / raw)
  To: James Bottomley
  Cc: Linux Kernel Mailing List, linux-scsi, Daniel M. Eischen, Doug Ledford

On 12/14/05, James Bottomley <James.Bottomley@steeleye.com> wrote:
> On Wed, 2005-12-14 at 00:07 +0100, Jesper Juhl wrote:
> > +     if (retval) {
> > +             printk(KERN_ERR "aic7xxx: scsi_add_host failed\n");
> > +             goto free_and_out;
> > +     }
> > +
> >       scsi_scan_host(host);
> > -     return (0);
> > +
> > +out:
> > +     return retval;
> > +free_and_out:
> > +     scsi_remove_host(host);
> > +     goto out;
>
> I'm not incredibly keen on all this jumping around for no reason.  If
> there's a normal out and an error out, then fine, but in this case the
> if (retval) { } could contain the entirety of the error path with an
> else for the normal path.
>
Ok, I'll change that.

> scsi_remove_host() is the wrong API, it should be scsi_host_put() (for
> an allocated but un added host).
>
Ohh, I misunderstood things then, I'll correct that.

I'll send a new patch later today when I get home from work.

Thank you for taking a look at the patch and your feedback.

--
Jesper Juhl <jesper.juhl@gmail.com>
Don't top-post  http://www.catb.org/~esr/jargon/html/T/top-post.html
Plain text mails only, please      http://www.expita.com/nomime.html

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

* Re: [PATCH] fix warning and missing failure handling for scsi_add_host in aic7xxx driver
  2005-12-14  8:02   ` Jesper Juhl
@ 2005-12-14  8:20     ` James Bottomley
  2005-12-14  8:37       ` Jesper Juhl
  0 siblings, 1 reply; 5+ messages in thread
From: James Bottomley @ 2005-12-14  8:20 UTC (permalink / raw)
  To: Jesper Juhl
  Cc: Linux Kernel Mailing List, linux-scsi, Daniel M. Eischen, Doug Ledford

On Wed, 2005-12-14 at 09:02 +0100, Jesper Juhl wrote:
> I'll send a new patch later today when I get home from work.

Actually, the aic79xx has the identical problem, if you want to fix that
too ...

James



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

* Re: [PATCH] fix warning and missing failure handling for scsi_add_host in aic7xxx driver
  2005-12-14  8:20     ` James Bottomley
@ 2005-12-14  8:37       ` Jesper Juhl
  0 siblings, 0 replies; 5+ messages in thread
From: Jesper Juhl @ 2005-12-14  8:37 UTC (permalink / raw)
  To: James Bottomley
  Cc: Linux Kernel Mailing List, linux-scsi, Daniel M. Eischen, Doug Ledford

On 12/14/05, James Bottomley <James.Bottomley@steeleye.com> wrote:
> On Wed, 2005-12-14 at 09:02 +0100, Jesper Juhl wrote:
> > I'll send a new patch later today when I get home from work.
>
> Actually, the aic79xx has the identical problem, if you want to fix that
> too ...
>
Sure, will do.

--
Jesper Juhl <jesper.juhl@gmail.com>
Don't top-post  http://www.catb.org/~esr/jargon/html/T/top-post.html
Plain text mails only, please      http://www.expita.com/nomime.html

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

end of thread, other threads:[~2005-12-14  8:37 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-12-13 23:07 [PATCH] fix warning and missing failure handling for scsi_add_host in aic7xxx driver Jesper Juhl
2005-12-14  4:33 ` James Bottomley
2005-12-14  8:02   ` Jesper Juhl
2005-12-14  8:20     ` James Bottomley
2005-12-14  8:37       ` Jesper Juhl

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.