linux-nvme.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] nvme: prefer strlcpy to strncpy
@ 2018-05-29  6:49 Nick Desaulniers
  2018-05-29  8:11 ` Christoph Hellwig
  0 siblings, 1 reply; 3+ messages in thread
From: Nick Desaulniers @ 2018-05-29  6:49 UTC (permalink / raw)


Fixes a stringop-truncation warning from gcc-8.

Signed-off-by: Nick Desaulniers <nick.desaulniers at gmail.com>
---
 drivers/nvme/host/core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c
index 99b857e..b823ecb 100644
--- a/drivers/nvme/host/core.c
+++ b/drivers/nvme/host/core.c
@@ -2017,7 +2017,7 @@ static void nvme_init_subnqn(struct nvme_subsystem *subsys, struct nvme_ctrl *ct
 
 	nqnlen = strnlen(id->subnqn, NVMF_NQN_SIZE);
 	if (nqnlen > 0 && nqnlen < NVMF_NQN_SIZE) {
-		strncpy(subsys->subnqn, id->subnqn, NVMF_NQN_SIZE);
+		strlcpy(subsys->subnqn, id->subnqn, NVMF_NQN_SIZE);
 		return;
 	}
 
-- 
2.7.4

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

* [PATCH] nvme: prefer strlcpy to strncpy
  2018-05-29  6:49 [PATCH] nvme: prefer strlcpy to strncpy Nick Desaulniers
@ 2018-05-29  8:11 ` Christoph Hellwig
  2018-05-30  2:02   ` Nick Desaulniers
  0 siblings, 1 reply; 3+ messages in thread
From: Christoph Hellwig @ 2018-05-29  8:11 UTC (permalink / raw)


On Mon, May 28, 2018@11:49:18PM -0700, Nick Desaulniers wrote:
> Fixes a stringop-truncation warning from gcc-8.

What would that warning be?  Maybe it actually is genuinly useful,
and switching to strlcpy just papers over it..

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

* [PATCH] nvme: prefer strlcpy to strncpy
  2018-05-29  8:11 ` Christoph Hellwig
@ 2018-05-30  2:02   ` Nick Desaulniers
  0 siblings, 0 replies; 3+ messages in thread
From: Nick Desaulniers @ 2018-05-30  2:02 UTC (permalink / raw)


On Tue, May 29, 2018@1:11 AM, Christoph Hellwig <hch@lst.de> wrote:
> On Mon, May 28, 2018@11:49:18PM -0700, Nick Desaulniers wrote:
>> Fixes a stringop-truncation warning from gcc-8.
>
> What would that warning be?  Maybe it actually is genuinly useful,
> and switching to strlcpy just papers over it..

Eric also pointed out to me that strlcpy will not initialize the rest
of dest with zeros if size is less than the length of src.

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

end of thread, other threads:[~2018-05-30  2:02 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-05-29  6:49 [PATCH] nvme: prefer strlcpy to strncpy Nick Desaulniers
2018-05-29  8:11 ` Christoph Hellwig
2018-05-30  2:02   ` Nick Desaulniers

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).