• Arnaldo Carvalho de Melo's avatar
    perf ui helpline: Use strlcpy() as a shorter form of strncpy() + explicit set nul · 4d0f16d0
    Arnaldo Carvalho de Melo authored
    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: e6e90468 ("perf ui: Introduce struct ui_helpline")
    Link: https://lkml.kernel.org/n/tip-d1wz0hjjsh19xbalw69qpytj@git.kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
    4d0f16d0
Name
Last commit
Last update
..
browsers Loading commit data...
gtk Loading commit data...
stdio Loading commit data...
tui Loading commit data...
Build Loading commit data...
browser.c Loading commit data...
browser.h Loading commit data...
helpline.c Loading commit data...
helpline.h Loading commit data...
hist.c Loading commit data...
keysyms.h Loading commit data...
libslang.h Loading commit data...
progress.c Loading commit data...
progress.h Loading commit data...
setup.c Loading commit data...
ui.h Loading commit data...
util.c Loading commit data...
util.h Loading commit data...