All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v3 2/4] target: don't assume t10_wwn.vendor is null terminated
@ 2018-11-19 21:06 David Disseldorp
  2018-11-20 16:49 ` Christoph Hellwig
  2018-11-20 17:37 ` David Disseldorp
  0 siblings, 2 replies; 3+ messages in thread
From: David Disseldorp @ 2018-11-19 21:06 UTC (permalink / raw)
  To: target-devel

Signed-off-by: David Disseldorp <ddiss@suse.de>
---
 drivers/target/target_core_stat.c | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/drivers/target/target_core_stat.c b/drivers/target/target_core_stat.c
index f0db91ebd735..89f35167f036 100644
--- a/drivers/target/target_core_stat.c
+++ b/drivers/target/target_core_stat.c
@@ -804,10 +804,17 @@ static ssize_t target_stat_transport_dev_name_show(struct config_item *item,
 	if (dev) {
 		wwn = &dev->t10_wwn;
 		/* scsiTransportDevName */
-		ret = snprintf(page, PAGE_SIZE, "%s+%s\n",
+		if (strlen(wwn->unit_serial)) {
+			ret = snprintf(page, PAGE_SIZE, "%s+%s\n",
+				tpg->se_tpg_tfo->tpg_get_wwn(tpg),
+				wwn->unit_serial);
+		} else {
+			ret = snprintf(page, PAGE_SIZE, "%s+%."
+				__stringify(INQUIRY_VENDOR_IDENTIFIER_LEN)
+				"s\n",
 				tpg->se_tpg_tfo->tpg_get_wwn(tpg),
-				(strlen(wwn->unit_serial)) ? wwn->unit_serial :
 				wwn->vendor);
+		}
 	}
 	rcu_read_unlock();
 	return ret;
-- 
2.13.7

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

* Re: [PATCH v3 2/4] target: don't assume t10_wwn.vendor is null terminated
  2018-11-19 21:06 [PATCH v3 2/4] target: don't assume t10_wwn.vendor is null terminated David Disseldorp
@ 2018-11-20 16:49 ` Christoph Hellwig
  2018-11-20 17:37 ` David Disseldorp
  1 sibling, 0 replies; 3+ messages in thread
From: Christoph Hellwig @ 2018-11-20 16:49 UTC (permalink / raw)
  To: target-devel

This could use a little more explanation, the code doesn't just
add a little if but also changes the existing case.  Also where
can't it be null currently?

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

* Re: [PATCH v3 2/4] target: don't assume t10_wwn.vendor is null terminated
  2018-11-19 21:06 [PATCH v3 2/4] target: don't assume t10_wwn.vendor is null terminated David Disseldorp
  2018-11-20 16:49 ` Christoph Hellwig
@ 2018-11-20 17:37 ` David Disseldorp
  1 sibling, 0 replies; 3+ messages in thread
From: David Disseldorp @ 2018-11-20 17:37 UTC (permalink / raw)
  To: target-devel

On Tue, 20 Nov 2018 08:49:24 -0800, Christoph Hellwig wrote:

> This could use a little more explanation, the code doesn't just
> add a little if but also changes the existing case.  Also where
> can't it be null currently?

I'll add an explanation in the next round. This patch shouldn't cause
any change in behaviour. The vendor string is currently always NULL
terminated, but won't be once patch 3/4 is applied, hence the need to
add the maximum string width specifier.

Thanks for the feedback.

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

end of thread, other threads:[~2018-11-20 17:37 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-11-19 21:06 [PATCH v3 2/4] target: don't assume t10_wwn.vendor is null terminated David Disseldorp
2018-11-20 16:49 ` Christoph Hellwig
2018-11-20 17:37 ` David Disseldorp

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.