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

Fix -Wsign-compare error in keys.c #305

Closed
wants to merge 1 commit into from

Conversation

fangfufu
Copy link
Collaborator

When compiling with -Wall -Wextra under Debian Buster, I get the following error message:

keys.c: In function ‘disable_old_keys’:
keys.c:26:12: warning: comparison of integer expressions of different signedness: ‘int’ and ‘long unsigned int’ [-Wsign-compare]
  if(result < sizeof(tmpfile)) {

snprintf returns a negative value on output error. In the current implementation, there is no error handling for negative return
values. Therefore in this context, it is acceptable to convert int to size_t.

@fangfufu fangfufu added 1.1 Issue related to Tinc 1.1 janitorial Cleanups of code and documentation that are not bug fixes and not new features. labels Aug 10, 2021
@gsliepen
Copy link
Owner

Cherry-picked as 9e917cc. Thanks!

@gsliepen gsliepen closed this Aug 10, 2021
@fangfufu fangfufu deleted the Wsign-compare branch August 10, 2021 18:48
@fangfufu fangfufu linked an issue Aug 10, 2021 that may be closed by this pull request
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
1.1 Issue related to Tinc 1.1 janitorial Cleanups of code and documentation that are not bug fixes and not new features.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Fix compiler warnings on all platforms where possible.
2 participants