android_kernel_samsung_a7y1.../tools/perf/ui
Arnaldo Carvalho de Melo 774828fd0d perf ui helpline: Use strlcpy() as a shorter form of strncpy() + explicit set nul
commit 4d0f16d059ddb91424480d88473f7392f24aebdc upstream.

The strncpy() function may leave the destination string buffer
unterminated, better use strlcpy() that we have a __weak fallback
implementation for systems without it.

In this case we are actually setting the null byte at the right place,
but since we pass the buffer size as the limit to strncpy() and not
it minus one, gcc ends up warning us about that, see below. So, lets
just switch to the shorter form provided by strlcpy().

This fixes this warning on an Alpine Linux Edge system with gcc 8.2:

  ui/tui/helpline.c: In function 'tui_helpline__push':
  ui/tui/helpline.c:27:2: error: 'strncpy' specified bound 512 equals destination size [-Werror=stringop-truncation]
    strncpy(ui_helpline__current, msg, sz)[sz - 1] = '\0';
    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  cc1: all warnings being treated as errors

Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Fixes: e6e904687949 ("perf ui: Introduce struct ui_helpline")
Link: https://lkml.kernel.org/n/tip-d1wz0hjjsh19xbalw69qpytj@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2020-04-06 19:17:02 +02:00
..
browsers A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
gtk A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
stdio A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
tui perf ui helpline: Use strlcpy() as a shorter form of strncpy() + explicit set nul 2020-04-06 19:17:02 +02:00
browser.c A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
browser.h A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
Build A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
helpline.c A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
helpline.h A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
hist.c A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
keysyms.h A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
libslang.h A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
progress.c A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
progress.h A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
setup.c A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
ui.h A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
util.c A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
util.h A750FXXU4CTBC 2020-03-27 21:51:54 +05:30