Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion cmd/ntpcheck/cmd/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,10 @@ func receiveNTPPacketWithRetries(connFd int, buf, oob []byte, tries int) (*ntp.P
return nil, clientReceiveTime, err
}
response, err := ntp.BytesToPacket(buf[:n])
return response, clientReceiveTime, err
if err != nil {
return nil, clientReceiveTime, err
}
return response, clientReceiveTime, nil
}

// ntpDate prints data similar to 'ntptime' command output
Expand Down
5 changes: 4 additions & 1 deletion fbclock/daemon/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,5 +97,8 @@ func ReadConfig(path string) (*Config, error) {
}
c := Config{}
err = yaml.UnmarshalStrict(data, &c)
return &c, err
if err != nil {
return nil, err
}
return &c, nil
}
9 changes: 4 additions & 5 deletions ntp/control/packet.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ func NormalizeData(data []byte) (map[string]string, error) {
result[k] = v
}
if len(result) == 0 {
return result, fmt.Errorf("malformed packet, no k=v pairs decoded")
return nil, fmt.Errorf("malformed packet, no k=v pairs decoded")
}
return result, nil
}
Expand Down Expand Up @@ -348,7 +348,7 @@ func (n NTPControlMsg) GetPeerStatus() (*PeerStatusWord, error) {
func (n NTPControlMsg) GetAssociations() (map[uint16]*PeerStatusWord, error) {
result := map[uint16]*PeerStatusWord{}
if n.GetOperation() != OpReadStatus {
return result, fmt.Errorf("no peer list supported for operation=%d", n.GetOperation())
return nil, fmt.Errorf("no peer list supported for operation=%d", n.GetOperation())
}
for i := 0; i < int(n.Count/4); i++ {
assoc := n.Data[i*4 : i*4+4] // 2 uint16 encoded as 4 bytes
Expand All @@ -361,13 +361,12 @@ func (n NTPControlMsg) GetAssociations() (map[uint16]*PeerStatusWord, error) {

// GetAssociationInfo returns parsed normalized variables if present
func (n NTPControlMsg) GetAssociationInfo() (map[string]string, error) {
result := map[string]string{}
if n.GetOperation() != OpReadVariables {
return result, fmt.Errorf("no variables supported for operation=%d", n.GetOperation())
return nil, fmt.Errorf("no variables supported for operation=%d", n.GetOperation())
}
data, err := NormalizeData(n.Data)
if err != nil {
return result, err
return nil, err
}
return data, nil
}
14 changes: 7 additions & 7 deletions phc/unix/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -154,13 +154,13 @@ func Recvmsg(a int, b, c []byte, d int) (int, int, int, Sockaddr, error) {
// Cross-platform constants from golang.org/x/sys/unix

const (
AF_INET = unix.AF_INET //nolint:revive
EAGAIN = unix.EAGAIN //nolint:revive
EINVAL = unix.EINVAL //nolint:revive
ENOENT = unix.ENOENT //nolint:revive
ENOTSUP = unix.ENOTSUP //nolint:revive
IFNAMSIZ = unix.IFNAMSIZ //nolint:revive
POLLERR = unix.POLLERR //nolint:revive
AF_INET = unix.AF_INET //nolint:revive
EAGAIN = unix.EAGAIN
EINVAL = unix.EINVAL
ENOENT = unix.ENOENT
ENOTSUP = unix.ENOTSUP
IFNAMSIZ = unix.IFNAMSIZ
POLLERR = unix.POLLERR
POLLIN = unix.POLLIN
POLLPRI = unix.POLLPRI
SizeofPtr = unix.SizeofPtr
Expand Down
2 changes: 1 addition & 1 deletion ptp/ptp4u/server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ func readPacketBuf(connFd int, buf []byte) (int, unix.Sockaddr, error) {
return 0, nil, err
}

return n, saddr, err
return n, saddr, nil
}

func updateSockaddrWithPort(sa unix.Sockaddr, port int) {
Expand Down
Loading