From: Brian King <brking@linux.vnet.ibm.com>
To: "Prakash, Sathya" <sathya.prakash@lsi.com>
Cc: linux-scsi@vger.kernel.org, eric.moore@lsi.com
Subject: Re: [PATCH]mpt fusion: add sysfs attributes to display IOC parameters
Date: Tue, 03 Jul 2007 08:49:38 -0500 [thread overview]
Message-ID: <468A53F2.5000402@linux.vnet.ibm.com> (raw)
In-Reply-To: <20070703130103.GA15841@lsil.com>
Prakash, Sathya wrote:
> +static void
> +mpt_get_manufacturing_pg_0(MPT_ADAPTER *ioc)
> +{
> +
> + memcpy(ioc->board_name, pbuf->BoardName, 16);
> + memcpy(ioc->board_assembly, pbuf->BoardAssembly, 16);
> + memcpy(ioc->board_tracer, pbuf->BoardTracerNumber, 16);
Are these guaranteed to be NULL terminated? The code below appears to
assume they are. Also you might want to use sizeof instead of hardcoding
16 here.
> +static ssize_t
> +mptscsih_version_driver_show(struct class_device *cdev, char *buf)
> +{
> + return snprintf(buf, PAGE_SIZE, "%02d.%02d.%02d.%02d\n",
> + MPT_LINUX_MAJOR_VERSION, MPT_LINUX_MINOR_VERSION,
> + MPT_LINUX_BUILD_VERSION, MPT_LINUX_RELEASE_VERSION);
> +}
> +static CLASS_DEVICE_ATTR(version_driver, S_IRUGO, mptscsih_version_driver_show, NULL);
You should be using the MODULE_VERSION macro instead of this. This results
in the version showing up in /sys/module/mpt_fusion/version
> +
> +static ssize_t
> +mptscsih_io_delay_show(struct class_device *cdev, char *buf)
> +{
> + struct Scsi_Host *host = class_to_shost(cdev);
> + MPT_SCSI_HOST *hd = (MPT_SCSI_HOST *)host->hostdata;
> + MPT_ADAPTER *ioc = hd->ioc;
> + char delay_str[30];
> +
> + sprintf(delay_str, "%02d", ioc->io_missing_delay);
> + return snprintf(buf, PAGE_SIZE, "%s\n", delay_str);
> +}
Why not just do:
return snprintf(buf, PAGE_SIZE, "%02d", ioc->io_missing_delay);
and get rid of the delay_str on the stack? In fact you have a lot
of double sprintf's which seem like they could be just a single snprintf.
-Brian
--
Brian King
Linux on Power Virtualization
IBM Linux Technology Center
next prev parent reply other threads:[~2007-07-03 13:49 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-07-03 13:01 [PATCH]mpt fusion: add sysfs attributes to display IOC parameters Prakash, Sathya
2007-07-03 13:49 ` Brian King [this message]
2007-07-03 17:19 ` Patrick_Boyd
-- strict thread matches above, loose matches on Subject: below --
2007-07-12 8:22 [PATCH] mpt " Prakash, Sathya
2007-07-12 14:12 ` Brian King
2007-07-12 16:30 ` Moore, Eric
[not found] <20070713041041.GA5149@lsil.com>
2007-07-13 17:12 ` Moore, Eric
2007-07-17 9:09 ` Prakash, Sathya
2007-07-17 16:56 ` Moore, Eric
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=468A53F2.5000402@linux.vnet.ibm.com \
--to=brking@linux.vnet.ibm.com \
--cc=eric.moore@lsi.com \
--cc=linux-scsi@vger.kernel.org \
--cc=sathya.prakash@lsi.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 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.