Skip to content

Commit

Permalink
fix: remove redundant type conversions
Browse files Browse the repository at this point in the history
  • Loading branch information
liaohanqin authored and jsouthworth committed Oct 27, 2021
1 parent daa0174 commit d379abe
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions transport_unix.go
Original file line number Diff line number Diff line change
Expand Up @@ -154,17 +154,15 @@ func (t *unixTransport) ReadMessage() (*Message, error) {
// substitute the values in the message body (which are indices for the
// array receiver via OOB) with the actual values
for i, v := range msg.Body {
switch v.(type) {
switch index := v.(type) {
case UnixFDIndex:
j := v.(UnixFDIndex)
if uint32(j) >= unixfds {
if uint32(index) >= unixfds {
return nil, InvalidMessageError("invalid index for unix fd")
}
msg.Body[i] = UnixFD(fds[j])
msg.Body[i] = UnixFD(fds[index])
case []UnixFDIndex:
idxArray := v.([]UnixFDIndex)
fdArray := make([]UnixFD, len(idxArray))
for k, j := range idxArray {
fdArray := make([]UnixFD, len(index))
for k, j := range index {
if uint32(j) >= unixfds {
return nil, InvalidMessageError("invalid index for unix fd")
}
Expand Down

0 comments on commit d379abe

Please sign in to comment.