kfish / xsel

A command-line program for getting and setting the contents of the X selection
http://www.kfish.org/software/xsel/
Other
336 stars 37 forks source link

Avoid extra char copy in strncpy #32

Closed ony closed 5 years ago

ony commented 5 years ago

Also reserve unused extra char in get_atom_name to avoid gcc 8.3.0 error like:

x86_64-pc-linux-gnu-gcc -DHAVE_CONFIG_H -I.     -g -O2 -fno-strict-aliasing -Wall -Werror -g -std=gnu99 -Wdeclaration-after-statement -Wno-unused -c -o xsel.o xsel.c
In function 'get_atom_name.part.1',
    inlined from 'get_atom_name' at xsel.c:233:1:
xsel.c:252:3: error: 'strncpy' specified bound 4097 equals destination size [-Werror=stringop-truncation]
   strncpy (atom_name, ret, sizeof (atom_name));
   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In function '_xs_strncpy',
    inlined from 'main' at xsel.c:2114:7:
xsel.c:331:5: error: 'strncpy' specified bound 1024 equals destination size [-Werror=stringop-truncation]
     strncpy (dest, src, n);
     ^~~~~~~~~~~~~~~~~~~~~~
cc1: all warnings being treated as errors