public inbox for linux-s390@vger.kernel.org
 help / color / mirror / Atom feed
From: Swen Schillig <swen@vnet.ibm.com>
To: Heiko Carstens <heiko.carstens@de.ibm.com>
Cc: christof.schmitt@de.ibm.com,
	James Bottomley <James.Bottomley@hansenpartnership.com>,
	linux-scsi@vger.kernel.org, linux-s390@vger.kernel.org
Subject: Re: [patch 07/11] zfcp: Cleanup of code in zfcp_aux.c
Date: Tue, 1 Jul 2008 15:44:13 +0200	[thread overview]
Message-ID: <200807011544.14178.swen@vnet.ibm.com> (raw)
In-Reply-To: <20080630225259.GB4727@osiris.boeblingen.de.ibm.com>

On Tuesday 01 July 2008 00:52, Heiko Carstens wrote:
> > +static int __init zfcp_device_setup(char *devstr)
> >  {
> > -	char *tmp, *str;
> > -	size_t len;
> > +	char *token;
> > 
> >  	if (!devstr)
> >  		return 0;
> > 
> > -	len = strlen(devstr) + 1;
> > -	str = kmalloc(len, GFP_KERNEL);
> > -	if (!str) {
> > -		pr_err("zfcp: Could not allocate memory for "
> > -		       "device parameter string, device not attached.\n");
> > -		return 0;
> > -	}
> > -	memcpy(str, devstr, len);
> > -
> > -	tmp = strchr(str, ',');
> > -	if (!tmp)
> > +	token = strsep(&devstr, ",");
> > +	if (!token || strlen(token) >= BUS_ID_SIZE)
> >  		goto err_out;
> > -	*tmp++ = '\0';
> > -	strncpy(zfcp_data.init_busid, str, BUS_ID_SIZE);
> > -	zfcp_data.init_busid[BUS_ID_SIZE-1] = '\0';
> > +	strncpy(zfcp_data.init_busid, token, BUS_ID_SIZE);
> > 
> > -	zfcp_data.init_wwpn = simple_strtoull(tmp, &tmp, 0);
> > -	if (*tmp++ != ',')
> > -		goto err_out;
> > -	if (*tmp == '\0')
> > +	token = strsep(&devstr, ",");
> > +	if (!token || strict_strtoull(token, 0, &zfcp_data.init_wwpn))
> >  		goto err_out;
> > 
> > -	zfcp_data.init_fcp_lun = simple_strtoull(tmp, &tmp, 0);
> > -	if (*tmp != '\0')
> > +	token = strsep(&devstr, ",");
> > +	if (!token || strict_strtoull(token, 0, &zfcp_data.init_fcp_lun))
> >  		goto err_out;
> > -	kfree(str);
> >  	return 1;
> > 
> >   err_out:
> >  	pr_err("zfcp: Parse error for device parameter string %s, "
> > -	       "device not attached.\n", str);
> > -	kfree(str);
> > +	       "device not attached.\n", devstr);
> >  	return 0;
> >  }
> 
> Sorry, but this still seems to be incorrect. strsep modifies the string that
> gets passed to it. In this case you let it operate on the original module
> parameter string which is also exported via sysfs.
> So after parsing finished the exported string is much shorter than the
> original string. That was actually the whole point why the old code allocated
> memory and copied the string so the copy could be modified.
> A comment would have been good ;)
> --
Correct,

I fixed the patch and Christof will send it soon to the list.

Cheers Swen

  reply	other threads:[~2008-07-01 13:44 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-06-30 10:52 [patch 00/11] zfcp updates for 2.6.27 christof.schmitt
2008-06-30 10:52 ` [patch 01/11] zfcp: wait until adapter is finished with ERP during auto-port christof.schmitt
2008-06-30 10:52 ` [patch 02/11] zfcp: Fix error checking for ELS ADISC requests christof.schmitt
2008-06-30 10:52 ` [patch 03/11] zfcp: Adapter reopen for large number of unsolicited status christof.schmitt
2008-06-30 10:52 ` [patch 04/11] zfcp: Small QDIO cleanups christof.schmitt
2008-06-30 10:52 ` [patch 05/11] zfcp: Move status accessors from zfcp to SCSI include file christof.schmitt
2008-06-30 10:52 ` [patch 06/11] zfcp: Cleanup of code in zfcp_scsi.c christof.schmitt
2008-06-30 10:52 ` [patch 07/11] zfcp: Cleanup of code in zfcp_aux.c christof.schmitt
2008-06-30 22:52   ` Heiko Carstens
2008-07-01 13:44     ` Swen Schillig [this message]
2008-07-02  7:03       ` Christof Schmitt
2008-06-30 10:52 ` [patch 08/11] zfcp: consolidate sysfs things into one file christof.schmitt
2008-06-30 10:52 ` [patch 09/11] zfcp: zfcp_fsf cleanup christof.schmitt
2008-06-30 10:52 ` [patch 10/11] zfcp: Cleanup code in zfcp_erp.c christof.schmitt
2008-06-30 10:52 ` [patch 11/11] zfcp: Cleanup external header file christof.schmitt
  -- strict thread matches above, loose matches on Subject: below --
2008-07-02  8:56 [patch 00/11] Updated zfcp patches for 2.6.27 Christof Schmitt
2008-07-02  8:56 ` [patch 07/11] zfcp: Cleanup of code in zfcp_aux.c Christof Schmitt

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=200807011544.14178.swen@vnet.ibm.com \
    --to=swen@vnet.ibm.com \
    --cc=James.Bottomley@hansenpartnership.com \
    --cc=christof.schmitt@de.ibm.com \
    --cc=heiko.carstens@de.ibm.com \
    --cc=linux-s390@vger.kernel.org \
    --cc=linux-scsi@vger.kernel.org \
    /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
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox