]> git.ipfire.org Git - thirdparty/wireguard-go.git/commitdiff
rwcancel: use errors.Is for unwrapping
authorJason A. Donenfeld <Jason@zx2c4.com>
Tue, 9 Feb 2021 18:54:00 +0000 (19:54 +0100)
committerJason A. Donenfeld <Jason@zx2c4.com>
Tue, 9 Feb 2021 18:54:00 +0000 (19:54 +0100)
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
rwcancel/rwcancel.go

index 7d50f83eb56a1907369f15eb2b747953d5ed947d..8a6300a28dd47496c5317773ad67e92ff05cdeae 100644 (file)
@@ -46,17 +46,7 @@ func NewRWCancel(fd int) (*RWCancel, error) {
 }
 
 func RetryAfterError(err error) bool {
-       if pe, ok := err.(*os.PathError); ok {
-               err = pe.Err
-       }
-       if errno, ok := err.(syscall.Errno); ok {
-               switch errno {
-               case syscall.EAGAIN, syscall.EINTR:
-                       return true
-               }
-
-       }
-       return false
+       return errors.Is(err, syscall.EAGAIN) || errors.Is(err, syscall.EINTR)
 }
 
 func (rw *RWCancel) ReadyRead() bool {