Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid extra char copy in strncpy #32

Merged
merged 1 commit into from
May 17, 2019
Merged

Avoid extra char copy in strncpy #32

merged 1 commit into from
May 17, 2019

Conversation

ony
Copy link
Contributor

@ony ony commented May 5, 2019

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

Also reserve unused extra char in get_atom_name to avoid gcc 8.3.0 error like:
'strncpy' specified bound 4098 equals destination size [-Werror=stringop-truncation]
@kfish kfish merged commit 24bee9c into kfish:master May 17, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants