Skip to content

Commit

Permalink
auxdisplay: use correct string length
Browse files Browse the repository at this point in the history
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 <xiongfeng.wang@linaro.org>
  • Loading branch information
Xiongfeng Wang authored and 0day robot committed Jan 10, 2018
1 parent cf1fb15 commit eab240f
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions drivers/auxdisplay/panel.c
Expand Up @@ -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;
}
Expand Down

0 comments on commit eab240f

Please sign in to comment.