Skip to content

Conversation

valeriyvan
Copy link

No description provided.

let filename = Data(capacity: Int(PATH_MAX))
let pointer = filename.bytes.bindMemory(to: CChar.self, capacity: filename.capacity)
let size = readlink("/proc/self/fd/\(descriptor)", pointer, filename.capacity)
let _ = readlink("/proc/self/fd/\(descriptor)", pointer, filename.capacity)
Copy link
Member

Choose a reason for hiding this comment

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

Would probably make sense to check if the operation succeeded instead of silently handling the error.

What about changing this to something like:

let size = readlink("/proc/self/fd/\(descriptor)", pointer, filename.capacity)
if size == -1 {
  fatalError("readLink failed, errno: \(errno)")
}

Copy link
Author

Choose a reason for hiding this comment

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

That's better. But fatalError? Do you think it's OK here?

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