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 compilation with -Werror=unused-result #37

Closed
wants to merge 1 commit into from

Conversation

mzanetti
Copy link
Contributor

@mzanetti mzanetti commented Sep 8, 2017

After upgrading to ubuntu artful (17.10) the new gcc seems to have -Werror=unused-result on by default which breaks compilation.

from man 2 getcwd:

On failure, these functions return NULL, and errno is set to indicate the error. The contents of the array pointed to by buf are undefined on error.

Now, the interesting bit is that if I compare the result with NULL, it actually fails with NULL used in arithmetic [-Werror=pointer-arith] so checking for 0... Not sure if this is pretty enough, but at least gets around the issue and shouldn't do any wrong.

@vareddy-zz
Copy link
Contributor

Hi @mzanetti,
Thank you for providing this pull request! We currently haven't tested the SDK in Ubuntu 17.10 hence we weren't able to catch this compile failure.
This pull request has no conflicts so we will include this in a future release.
Please let us know if you have any more questions or suggestions.
Thanks!
Varun

@vareddy-zz
Copy link
Contributor

Hi @mzanetti,
I believe the error with using NULL is due to a typo in your pull request.
The brackets are closed incorrectly, hence the compiler thinks that you are checking the size of the buffer with NULL i.e. :
if (getcwd(CurrentWD, sizeof(CurrentWD) == 0))
should actually be
if (getcwd(CurrentWD, sizeof(CurrentWD)) == NULL)
The above line compiles correctly and throws no errors.
Thanks!
Varun

@mzanetti
Copy link
Contributor Author

facepalm

Thanks for spotting that :) Updated.

@vareddy-zz
Copy link
Contributor

Included in v1.2.0.

@vareddy-zz vareddy-zz closed this Sep 26, 2017
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