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

device: have IpcSetOperation not return typed error #7

Closed
wants to merge 2 commits into from

Conversation

crawshaw
Copy link
Collaborator

No description provided.

tklauser and others added 2 commits March 5, 2020 13:59
Update the golang.org/x/sys/unix dependency and use the newly introduced
RTMGRP_* consts instead of using the corresponding RTNLGRP_* const to
create a mask.

Signed-off-by: Tobias Klauser <[email protected]>
Signed-off-by: Jason A. Donenfeld <[email protected]>
status = device.IpcSetOperation(buffered.Reader)
err := device.IpcSetOperation(buffered.Reader)
if err != nil {
status, _ = err.(*IPCError)
Copy link
Member

Choose a reason for hiding this comment

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

Isn't there a new Go 1.13 error API for this?

Copy link
Contributor

@danderson danderson Apr 1, 2020

Choose a reason for hiding this comment

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

There is. In 1.13 this could be:

if !errors.As(err, &status) {
  device.log.Error.Println("Invalid UAPI error:", err)
  status = &IPCError{1}
}
...

@zx2c4
Copy link
Member

zx2c4 commented Mar 20, 2020

Shouldn't you be doing this to IpcGet as well as IpcSet?

Copy link
Contributor

@danderson danderson left a comment

Choose a reason for hiding this comment

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

I'll send a followup to make the same change to IpcGetOperation.

status = device.IpcSetOperation(buffered.Reader)
err := device.IpcSetOperation(buffered.Reader)
if err != nil {
status, _ = err.(*IPCError)
Copy link
Contributor

@danderson danderson Apr 1, 2020

Choose a reason for hiding this comment

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

There is. In 1.13 this could be:

if !errors.As(err, &status) {
  device.log.Error.Println("Invalid UAPI error:", err)
  status = &IPCError{1}
}
...

@crawshaw
Copy link
Collaborator Author

crawshaw commented Apr 2, 2020

Closing in favor of #17.

@crawshaw crawshaw closed this Apr 2, 2020
nshalman pushed a commit to nshalman/wireguard-go that referenced this pull request Apr 23, 2023
spikecurtis pushed a commit to coder/wireguard-go that referenced this pull request Mar 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

4 participants