* [patch 2/2] target: don't truncate the fail intr address
@ 2013-01-31 8:19 Dan Carpenter
2013-01-31 20:31 ` Nicholas A. Bellinger
0 siblings, 1 reply; 2+ messages in thread
From: Dan Carpenter @ 2013-01-31 8:19 UTC (permalink / raw)
To: Nicholas A. Bellinger; +Cc: linux-scsi, target-devel, kernel-janitors
The temporary buffer was only 32 characters but ->last_intr_fail_ip_addr
is a 48 character buffer. We don't need to use a temporary buffer at
all, we can just print directly to "page".
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
---
Compile tested only.
diff --git a/drivers/target/iscsi/iscsi_target_stat.c b/drivers/target/iscsi/iscsi_target_stat.c
index 54a6f38..464b420 100644
--- a/drivers/target/iscsi/iscsi_target_stat.c
+++ b/drivers/target/iscsi/iscsi_target_stat.c
@@ -429,16 +429,19 @@ static ssize_t iscsi_stat_tgt_attr_show_attr_fail_intr_addr(
struct iscsi_tiqn *tiqn = container_of(igrps,
struct iscsi_tiqn, tiqn_stat_grps);
struct iscsi_login_stats *lstat = &tiqn->login_stats;
- unsigned char buf[32];
+ int ret;
spin_lock(&lstat->lock);
- if (lstat->last_intr_fail_ip_family == AF_INET6)
- snprintf(buf, 32, "[%s]", lstat->last_intr_fail_ip_addr);
- else
- snprintf(buf, 32, "%s", lstat->last_intr_fail_ip_addr);
+ if (lstat->last_intr_fail_ip_family == AF_INET6) {
+ ret = snprintf(page, PAGE_SIZE, "[%s]\n",
+ lstat->last_intr_fail_ip_addr);
+ } else {
+ ret = snprintf(page, PAGE_SIZE, "%s\n",
+ lstat->last_intr_fail_ip_addr);
+ }
spin_unlock(&lstat->lock);
- return snprintf(page, PAGE_SIZE, "%s\n", buf);
+ return ret;
}
ISCSI_STAT_TGT_ATTR_RO(fail_intr_addr);
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [patch 2/2] target: don't truncate the fail intr address
2013-01-31 8:19 [patch 2/2] target: don't truncate the fail intr address Dan Carpenter
@ 2013-01-31 20:31 ` Nicholas A. Bellinger
0 siblings, 0 replies; 2+ messages in thread
From: Nicholas A. Bellinger @ 2013-01-31 20:31 UTC (permalink / raw)
To: Dan Carpenter; +Cc: linux-scsi, target-devel, kernel-janitors
On Thu, 2013-01-31 at 11:19 +0300, Dan Carpenter wrote:
> The temporary buffer was only 32 characters but ->last_intr_fail_ip_addr
> is a 48 character buffer. We don't need to use a temporary buffer at
> all, we can just print directly to "page".
>
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> ---
Also applied to for-next.
Thanks Dan!
--nab
> Compile tested only.
>
> diff --git a/drivers/target/iscsi/iscsi_target_stat.c b/drivers/target/iscsi/iscsi_target_stat.c
> index 54a6f38..464b420 100644
> --- a/drivers/target/iscsi/iscsi_target_stat.c
> +++ b/drivers/target/iscsi/iscsi_target_stat.c
> @@ -429,16 +429,19 @@ static ssize_t iscsi_stat_tgt_attr_show_attr_fail_intr_addr(
> struct iscsi_tiqn *tiqn = container_of(igrps,
> struct iscsi_tiqn, tiqn_stat_grps);
> struct iscsi_login_stats *lstat = &tiqn->login_stats;
> - unsigned char buf[32];
> + int ret;
>
> spin_lock(&lstat->lock);
> - if (lstat->last_intr_fail_ip_family == AF_INET6)
> - snprintf(buf, 32, "[%s]", lstat->last_intr_fail_ip_addr);
> - else
> - snprintf(buf, 32, "%s", lstat->last_intr_fail_ip_addr);
> + if (lstat->last_intr_fail_ip_family == AF_INET6) {
> + ret = snprintf(page, PAGE_SIZE, "[%s]\n",
> + lstat->last_intr_fail_ip_addr);
> + } else {
> + ret = snprintf(page, PAGE_SIZE, "%s\n",
> + lstat->last_intr_fail_ip_addr);
> + }
> spin_unlock(&lstat->lock);
>
> - return snprintf(page, PAGE_SIZE, "%s\n", buf);
> + return ret;
> }
> ISCSI_STAT_TGT_ATTR_RO(fail_intr_addr);
>
> --
> To unsubscribe from this list: send the line "unsubscribe target-devel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2013-01-31 20:31 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-01-31 8:19 [patch 2/2] target: don't truncate the fail intr address Dan Carpenter
2013-01-31 20:31 ` Nicholas A. Bellinger
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).