[PATCH] staging: wlan-ng: prism2fw.c: Cleaning up unnecessary use of memset in conjunction with strncpy

From: Rickard Strandqvist
Date: Sun Sep 14 2014 - 12:02:35 EST


Using memset before strncpy just to ensure a trailing null
character is an unnecessary double writing of a string

Signed-off-by: Rickard Strandqvist <rickard_strandqvist@xxxxxxxxxxxxxxxxxx>
---
drivers/staging/wlan-ng/prism2fw.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/wlan-ng/prism2fw.c b/drivers/staging/wlan-ng/prism2fw.c
index 42c14b0..e66b7d4 100644
--- a/drivers/staging/wlan-ng/prism2fw.c
+++ b/drivers/staging/wlan-ng/prism2fw.c
@@ -733,8 +733,8 @@ static int plugimage(struct imgchunk *fchunk, unsigned int nfchunks,
c, chunkoff);

if (j == -1) { /* plug the filename */
- memset(dest, 0, s3plug[i].len);
strncpy(dest, PRISM2_USB_FWFILE, s3plug[i].len - 1);
+ dest[s3plug[i].len - 1] = '\0';
} else { /* plug a PDR */
memcpy(dest, &(pda->rec[j]->data), s3plug[i].len);
}
--
1.7.10.4

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/