netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Bart Van Assche <bvanassche@acm.org>
To: Robert Love <robert.w.love@intel.com>
Cc: netdev@vger.kernel.org, gregkh@linuxfoundation.org,
	linux-scsi@vger.kernel.org, bprakash@broadcom.com,
	devel@open-fcoe.org
Subject: Re: [RFC PATCH 1/5] libfcoe, fcoe: Allow user to set a ctlr's mode
Date: Tue, 11 Sep 2012 07:51:41 +0200	[thread overview]
Message-ID: <504ED16D.5080607@acm.org> (raw)
In-Reply-To: <20120910225914.13140.22190.stgit@fritz>

On 09/11/12 00:59, Robert Love wrote:
> +static enum fip_conn_type fcoe_parse_mode(const char *buf,
> +				  const struct fcoe_ctlr_mode_table *tbl)
> +{
> +	int modeint = -1, i, rv;
> +	char *p, modestr[FCOE_MAX_MODENAME_LEN + 1] = { 0, };
> +
> +	for (p = (char *)buf; *p; p++)
> +		if (!(isdigit(*p) || isspace(*p)))
> +			break;

If you change the declaration of p from "char *p" into "const char *p"
you won't need a cast in the above for loop.

[ ... ]

> -static FCOE_DEVICE_ATTR(ctlr, mode, S_IRUGO,
> -			show_ctlr_mode, NULL);
> +
> +static ssize_t store_ctlr_mode(struct device *dev,
> +			       struct device_attribute *attr,
> +			       const char *buf, size_t count)
> +{
> +	struct fcoe_ctlr_device *ctlr = dev_to_ctlr(dev);
> +
> +	if (!ctlr->f->set_fcoe_ctlr_mode)
> +		return -EINVAL;
> +
> +	ctlr->mode = fcoe_parse_mode(buf, ctlr_mode_tbl);

As far as I know sysfs doesn't terminate buf with a '\0' before calling
a store method. Does that mean that you are passing a string that is not
'\0'-terminated to a function that expects a '\0'-terminated string ?

Bart.

  parent reply	other threads:[~2012-09-11  5:51 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-09-10 22:59 [RFC PATCH 0/5] Reorganize libfcoe control interfaces Robert Love
2012-09-10 22:59 ` [RFC PATCH 1/5] libfcoe, fcoe: Allow user to set a ctlr's mode Robert Love
2012-09-10 23:12   ` Greg KH
2012-09-11  5:51   ` Bart Van Assche [this message]
2012-09-12 19:24     ` Love, Robert W
2012-09-10 22:59 ` [RFC PATCH 2/5] libfcoe: Create new libfcoe control interfaces Robert Love
2012-09-14  7:06   ` Bhanu Prakash Gollapudi
2012-09-10 22:59 ` [RFC PATCH 3/5] fcoe: Use new fcoe_sysfs control interface Robert Love
2012-09-10 22:59 ` [RFC PATCH 4/5] bnx2fc: " Robert Love
2012-09-14  7:28   ` Bhanu Prakash Gollapudi
2012-09-10 22:59 ` [RFC PATCH 5/5] libfcoe, fcoe: Remove libfcoe module parameters Robert Love
2012-09-11  0:05 ` [RFC PATCH 0/5] Reorganize libfcoe control interfaces Bhanu Prakash Gollapudi
2012-09-11  1:41   ` Love, Robert W
2012-09-11  5:46     ` Bhanu Prakash Gollapudi
2012-09-11 17:12   ` Chris Leech
2012-09-11 17:43     ` Love, Robert W
2012-09-11 17:06 ` Chris Leech
2012-09-11 17:36   ` Love, Robert W
2012-09-11 17:46     ` [Open-FCoE] " Love, Robert W
2012-09-11 18:31     ` Bhanu Prakash Gollapudi
2012-09-11 18:47       ` Love, Robert W
     [not found]     ` <504F76A1.50809-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
2012-09-12 19:35       ` Love, Robert W

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=504ED16D.5080607@acm.org \
    --to=bvanassche@acm.org \
    --cc=bprakash@broadcom.com \
    --cc=devel@open-fcoe.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-scsi@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=robert.w.love@intel.com \
    /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;
as well as URLs for NNTP newsgroup(s).