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

Correct last compilation warnings in readpassphrase #424

Merged
merged 1 commit into from
Oct 20, 2017
Merged

Correct last compilation warnings in readpassphrase #424

merged 1 commit into from
Oct 20, 2017

Conversation

benrubson
Copy link
Contributor

@benrubson benrubson commented Oct 11, 2017

Hi,

This PR corrects last compilation warnings regarding readpassphrase.cpp.
It comes back to the original file, simply adding a dummy test to avoid the (void)write() warnings.
Will then help to progress on #426.

/home/makerpm/rpmbuild/BUILD/encfs-master/encfs/readpassphrase.cpp:128:46: warning: ignoring return value of 'ssize_t write(int, const void*, size_t)', declared with attribute warn_unused_result [-Wunused-result]
   (void)write(output, prompt, strlen(prompt));
                                              ^
/home/makerpm/rpmbuild/BUILD/encfs-master/encfs/readpassphrase.cpp:149:33: warning: ignoring return value of 'ssize_t write(int, const void*, size_t)', declared with attribute warn_unused_result [-Wunused-result]
     (void)write(output, "\n", 1);
                                 ^

Thank you !

@vgough
Copy link
Owner

vgough commented Oct 11, 2017

I'd rather not maintain a custom version of readpassphrase. Do you know if upstream versions of this code still produce warnings?

@benrubson
Copy link
Contributor Author

benrubson commented Oct 11, 2017

Yes, I had a look, it does.
Finally I just transformed :
(void)write
into :
if(write) {}
To avoid compilation warnings of non-checked returned value.

@rfjakob
Copy link
Collaborator

rfjakob commented Oct 11, 2017

Shouldn't we error out if the write fails?

@benrubson
Copy link
Contributor Author

It's the write() which outputs the password prompt, so I think this is why it is simply not checked, password can be get even if prompt is not shown 👍

@benrubson
Copy link
Contributor Author

benrubson commented Oct 12, 2017

If we look at the modifications finally made to this upstream file, they are rather tiny :

The 2 write calls :

(void)write(output, prompt, strlen(prompt));

Have simply been changed to :

if (write(output, prompt, strlen(prompt)) != -1) {
  //dummy test to get rid of warn_unused_result compilation warning
}

That's it 👍
And this allows us to get rid of warning messages.
It's worth it I think :)

@benrubson benrubson requested a review from vgough October 13, 2017 05:46
@vgough
Copy link
Owner

vgough commented Oct 13, 2017

Looks to me like a few things have changed. I've created a PR #425 to import a new version. I don't see any compiler warnings when building.

@benrubson benrubson mentioned this pull request Oct 15, 2017
@benrubson benrubson changed the title Correct last clang warnings in readpassphrase Correct last compilation warnings in readpassphrase Oct 15, 2017
@benrubson
Copy link
Contributor Author

benrubson commented Oct 19, 2017

At least if we could commit this @vgough to get rid of compilation warnings + clang warnings visible in master CI, I think it would be perfect 👍
Then we could think about the update ?
Many thanks 👍

Copy link
Owner

@vgough vgough left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok, go for it.

@benrubson benrubson merged commit 4293ce4 into vgough:master Oct 20, 2017
@benrubson
Copy link
Contributor Author

Many thanks @vgough 👍

@benrubson benrubson deleted the readpassphrase branch October 20, 2017 05:32
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.

3 participants