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

Errno::result() #247

Closed
wants to merge 2 commits into from
Closed

Errno::result() #247

wants to merge 2 commits into from

Conversation

arcnmx
Copy link
Contributor

@arcnmx arcnmx commented Jan 26, 2016

A replacement of from_ffi, and updates all methods to use it. Partial preparation for #230 where Error will be replaced by Errno.

Changes are on top of #246, so merge that first!

@kamalmarhubi
Copy link
Member

I'm going to take a look at this tomorrow. I also think we'll want input from an extra reviewer or two since it's a major change to the API.

@arcnmx
Copy link
Contributor Author

arcnmx commented Jan 26, 2016

Well, to be fair the only API change is renaming from_ffi to Errno::result :P

But yeah, it touches a lot of the codebase! Not sure who else to pull in.

@kamalmarhubi
Copy link
Member

Well, to be fair the only API change is renaming from_ffi to Errno::result :P

I thought this was changing the return type of every function in the library from ::std::result::Result<_, ::nix::Error> to ::std::result::Result<_, ::nix::errno::Errno>? Am I confused?

@arcnmx
Copy link
Contributor Author

arcnmx commented Jan 26, 2016

No, this doesn't change anything externally (except from_ffi, which is a public function). Signatures are otherwise all the same, and nix::Error is still used because this doesn't include the NixString changes (and therefore InvalidPath is still an applicable error).

@@ -56,8 +57,6 @@ use std::fmt;
use std::error;
use libc::PATH_MAX;

pub type Result<T> = result::Result<T, Error>;
Copy link
Member

Choose a reason for hiding this comment

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

My confusion stemmed from moving this into the errno module. What's the rationale?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh, it should probably be moved back. Mostly it's there because that's where #230 had it.

Copy link
Member

Choose a reason for hiding this comment

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

Mind moving it back? :-)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, I'll do it when I get a chance sometime tomorrow night. Don't let that keep you from reviewing the rest of it though!

Copy link
Member

Choose a reason for hiding this comment

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

Based on what you said, and when I'm more awake, I'm pretty sure this will be fine. I'd been meaning to do a from_ffi sweep soon, so...

@kamalmarhubi
Copy link
Member

Ah, I was confused. See inline comment #247 (comment)

@arcnmx
Copy link
Contributor Author

arcnmx commented Jan 26, 2016

Essentially, this is just a PR to change every function to use from_ffi. It also just happens to rename it to Errno::result(), for two reasons:

  1. It's more self-documenting, etc. It returns a nix::Result from a POSIX function return value containing an Errno.
  2. It prepares for the change that actually does swap nix::Result to Result<T, Errno>. None of the code this touches will need to be changed as part of NixPath -> NixString and Error -> Errno #230 (which will actually change the function signatures).

@kamalmarhubi
Copy link
Member

Thanks for the clarification!

@arcnmx
Copy link
Contributor Author

arcnmx commented Jan 26, 2016

Moved Result back.

@kamalmarhubi
Copy link
Member

CI failed on apple. Please apply:

diff --git a/src/sys/event.rs b/src/sys/event.rs
index eb99f7d..1563a74 100644
--- a/src/sys/event.rs
+++ b/src/sys/event.rs
@@ -1,7 +1,8 @@
 /* TOOD: Implement for other kqueue based systems
  */

-use errno::{Errno, Result};
+use Result;
+use errno::Errno;
 #[cfg(not(target_os = "netbsd"))]
 use libc::{timespec, time_t, c_int, c_long, uintptr_t};
 #[cfg(target_os = "netbsd")]

:-)

@kamalmarhubi
Copy link
Member

Ok I'm going over this once more and then let's get the damned thing merged!

@posborne
Copy link
Member

Did a quick review. I'm happy with this change.

@kamalmarhubi
Copy link
Member

Rebased and merged as 01e8416...f167e8f

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.

None yet

3 participants