mirror of
https://github.com/rwinkhart/sys.git
synced 2026-09-02 07:07:33 -04:00
unix: use Go 1.21+ clear built-in
Inspired by CL 698495. Change-Id: Ic6ff68a60d41b6ffb6a28f523597c5d36c1e4d2f Reviewed-on: https://go-review.googlesource.com/c/sys/+/704915 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Michael Knyszek <mknyszek@google.com> Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com> Reviewed-by: Sean Liao <sean@liao.dev> Reviewed-by: Mark Freeman <markfreeman@google.com>
This commit is contained in:
committed by
Tobias Klauser
parent
137f2eda35
commit
32e203842b
+1
-3
@@ -23,7 +23,5 @@ func (fds *FdSet) IsSet(fd int) bool {
|
|||||||
|
|
||||||
// Zero clears the set fds.
|
// Zero clears the set fds.
|
||||||
func (fds *FdSet) Zero() {
|
func (fds *FdSet) Zero() {
|
||||||
for i := range fds.Bits {
|
clear(fds.Bits[:])
|
||||||
fds.Bits[i] = 0
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-3
@@ -111,9 +111,7 @@ func (ifr *Ifreq) SetUint32(v uint32) {
|
|||||||
// clear zeroes the ifreq's union field to prevent trailing garbage data from
|
// clear zeroes the ifreq's union field to prevent trailing garbage data from
|
||||||
// being sent to the kernel if an ifreq is reused.
|
// being sent to the kernel if an ifreq is reused.
|
||||||
func (ifr *Ifreq) clear() {
|
func (ifr *Ifreq) clear() {
|
||||||
for i := range ifr.raw.Ifru {
|
clear(ifr.raw.Ifru[:])
|
||||||
ifr.raw.Ifru[i] = 0
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO(mdlayher): export as IfreqData? For now we can provide helpers such as
|
// TODO(mdlayher): export as IfreqData? For now we can provide helpers such as
|
||||||
|
|||||||
@@ -801,9 +801,7 @@ func (sa *SockaddrPPPoE) sockaddr() (unsafe.Pointer, _Socklen, error) {
|
|||||||
// one. The kernel expects SID to be in network byte order.
|
// one. The kernel expects SID to be in network byte order.
|
||||||
binary.BigEndian.PutUint16(sa.raw[6:8], sa.SID)
|
binary.BigEndian.PutUint16(sa.raw[6:8], sa.SID)
|
||||||
copy(sa.raw[8:14], sa.Remote)
|
copy(sa.raw[8:14], sa.Remote)
|
||||||
for i := 14; i < 14+IFNAMSIZ; i++ {
|
clear(sa.raw[14 : 14+IFNAMSIZ])
|
||||||
sa.raw[i] = 0
|
|
||||||
}
|
|
||||||
copy(sa.raw[14:], sa.Dev)
|
copy(sa.raw[14:], sa.Dev)
|
||||||
return unsafe.Pointer(&sa.raw), SizeofSockaddrPPPoX, nil
|
return unsafe.Pointer(&sa.raw), SizeofSockaddrPPPoX, nil
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user