[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <1410710471-14341-1-git-send-email-rickard_strandqvist@spectrumdigital.se>
Date: Sun, 14 Sep 2014 18:01:11 +0200
From: Rickard Strandqvist <rickard_strandqvist@...ctrumdigital.se>
To: Karsten Keil <isdn@...ux-pingi.de>,
Rickard Strandqvist <rickard_strandqvist@...ctrumdigital.se>
Cc: netdev@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: [PATCH] isdn: act2000: capi.c: Cleaning up unnecessary use of memset in conjunction with strncpy
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@...ctrumdigital.se>
---
drivers/isdn/act2000/capi.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/drivers/isdn/act2000/capi.c b/drivers/isdn/act2000/capi.c
index 3f66ca2..1267739 100644
--- a/drivers/isdn/act2000/capi.c
+++ b/drivers/isdn/act2000/capi.c
@@ -907,10 +907,10 @@ actcapi_dispatch(struct work_struct *work)
case 0xff02:
/* MANUFACTURER_IND */
if (msg->msg.manuf_msg == 3) {
- memset(tmp, 0, sizeof(tmp));
strncpy(tmp,
&msg->msg.manufacturer_ind_err.errstring,
- msg->hdr.len - 16);
+ sizeof(tmp));
+ tmp[sizeof(tmp) - 1] = '\0';
if (msg->msg.manufacturer_ind_err.errcode)
printk(KERN_WARNING "act2000: %s\n", tmp);
else {
@@ -1136,9 +1136,9 @@ actcapi_debug_msg(struct sk_buff *skb, int direction)
msg->msg.manufacturer_ind_err.controller);
printk(KERN_DEBUG " Code = 0x%08x\n",
msg->msg.manufacturer_ind_err.errcode);
- memset(tmp, 0, sizeof(tmp));
strncpy(tmp, &msg->msg.manufacturer_ind_err.errstring,
- msg->hdr.len - 16);
+ sizeof(tmp));
+ tmp[sizeof(tmp) - 1] = '\0';
printk(KERN_DEBUG " Emsg = '%s'\n", tmp);
break;
}
--
1.7.10.4
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists