Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751426AbeAPJcN (ORCPT + 1 other); Tue, 16 Jan 2018 04:32:13 -0500 Received: from szxga07-in.huawei.com ([45.249.212.35]:32987 "EHLO huawei.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1750846AbeAPJcL (ORCPT ); Tue, 16 Jan 2018 04:32:11 -0500 From: Xiongfeng Wang To: CC: , , , Subject: [PATCH V2] auxdisplay: use correct string length Date: Tue, 16 Jan 2018 17:38:10 +0800 Message-ID: <1516095490-83827-1-git-send-email-wangxiongfeng2@huawei.com> X-Mailer: git-send-email 1.8.3.1 MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.175.113.25] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Return-Path: From: Xiongfeng Wang gcc-8 reports drivers/auxdisplay/panel.c: In function 'panel_attach': ./include/linux/string.h:245:9: warning: '__builtin_strncpy' specified bound 12 equals destination size [-Wstringop-truncation] We need one less byte or call strlcpy() to make it a nul-terminated string. Signed-off-by: Xiongfeng Wang --- drivers/auxdisplay/panel.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/auxdisplay/panel.c b/drivers/auxdisplay/panel.c index ea7869c..d288900 100644 --- a/drivers/auxdisplay/panel.c +++ b/drivers/auxdisplay/panel.c @@ -1506,10 +1506,10 @@ static struct logical_input *panel_bind_key(const char *name, const char *press, key->rise_time = 1; key->fall_time = 1; - strncpy(key->u.kbd.press_str, press, sizeof(key->u.kbd.press_str)); - strncpy(key->u.kbd.repeat_str, repeat, sizeof(key->u.kbd.repeat_str)); + strncpy(key->u.kbd.press_str, press, sizeof(key->u.kbd.press_str) - 1); + strncpy(key->u.kbd.repeat_str, repeat, sizeof(key->u.kbd.repeat_str) - 1); strncpy(key->u.kbd.release_str, release, - sizeof(key->u.kbd.release_str)); + sizeof(key->u.kbd.release_str) - 1); list_add(&key->list, &logical_inputs); return key; } -- 1.8.3.1