From baf535676025303f4e713fdf9f45d2d5a024cf6c Mon Sep 17 00:00:00 2001 From: GrĂ©goire DuchĂȘne Date: Sun, 4 Jul 2021 15:46:25 +0100 Subject: Use syscall.Errno to wrap C error codes --- socket_linux.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/socket_linux.go b/socket_linux.go index 6616d04..cab9701 100644 --- a/socket_linux.go +++ b/socket_linux.go @@ -12,8 +12,8 @@ package gosdd import "C" import ( - "fmt" "os" + "syscall" "unsafe" ) @@ -24,7 +24,7 @@ func sdListenFDs(unsetenv bool) ([]*os.File, error) { } c := C.sd_listen_fds(i) if c < 0 { - return nil, fmt.Errorf("sd_listen_fds: %s", C.GoString(C.strerror(-c))) + return nil, syscall.Errno(-c) } if c == 0 { return nil, nil @@ -44,7 +44,7 @@ func sdListenFDsWithNames(unsetenv bool) (map[string]*os.File, error) { var arr **C.char c := C.sd_listen_fds_with_names(i, &arr) if c < 0 { - return nil, fmt.Errorf("sd_listen_fds_with_names: %s", C.GoString(C.strerror(-c))) + return nil, syscall.Errno(-c) } if c == 0 { return nil, nil -- cgit v1.2.3-70-g09d2