From 2124140b044c3cbbd6a3ed7c45e2d4420be7039d Mon Sep 17 00:00:00 2001 From: cuishuang Date: Wed, 1 Jan 2025 22:16:31 +0800 Subject: [PATCH] all: make function and struct comments match the names Change-Id: I1f4a4c8daec5ac7d26f1d4df76726af664adcb36 Reviewed-on: https://go-review.googlesource.com/c/net/+/639576 Reviewed-by: Jorropo Auto-Submit: Damien Neil Commit-Queue: Ian Lance Taylor Reviewed-by: Damien Neil Auto-Submit: Ian Lance Taylor LUCI-TryBot-Result: Go LUCI Auto-Submit: Jorropo Reviewed-by: Ian Lance Taylor --- http2/config.go | 2 +- http2/config_go124.go | 2 +- http2/gate_test.go | 4 ++-- http2/netconn_test.go | 2 +- http2/server_test.go | 2 +- quic/conn_close.go | 2 +- quic/conn_test.go | 2 +- quic/endpoint.go | 2 +- quic/gate.go | 4 ++-- quic/packet_protection.go | 2 +- quic/packet_writer.go | 4 ++-- quic/qlog/json_writer.go | 4 ++-- quic/rtt.go | 2 +- quic/sent_val.go | 2 +- quic/stream.go | 2 +- quic/wire.go | 2 +- route/sys_netbsd.go | 2 +- 17 files changed, 21 insertions(+), 21 deletions(-) diff --git a/http2/config.go b/http2/config.go index de58dfb8d..ca645d9a1 100644 --- a/http2/config.go +++ b/http2/config.go @@ -60,7 +60,7 @@ func configFromServer(h1 *http.Server, h2 *Server) http2Config { return conf } -// configFromServer merges configuration settings from h2 and h2.t1.HTTP2 +// configFromTransport merges configuration settings from h2 and h2.t1.HTTP2 // (the net/http Transport). func configFromTransport(h2 *Transport) http2Config { conf := http2Config{ diff --git a/http2/config_go124.go b/http2/config_go124.go index e3784123c..5b516c55f 100644 --- a/http2/config_go124.go +++ b/http2/config_go124.go @@ -13,7 +13,7 @@ func fillNetHTTPServerConfig(conf *http2Config, srv *http.Server) { fillNetHTTPConfig(conf, srv.HTTP2) } -// fillNetHTTPServerConfig sets fields in conf from tr.HTTP2. +// fillNetHTTPTransportConfig sets fields in conf from tr.HTTP2. func fillNetHTTPTransportConfig(conf *http2Config, tr *http.Transport) { fillNetHTTPConfig(conf, tr.HTTP2) } diff --git a/http2/gate_test.go b/http2/gate_test.go index e5e6a315b..9b18bccfb 100644 --- a/http2/gate_test.go +++ b/http2/gate_test.go @@ -24,7 +24,7 @@ func newGate() gate { return g } -// newLocked gate returns a new, locked gate. +// newLockedGate returns a new, locked gate. func newLockedGate() gate { return gate{ set: make(chan struct{}, 1), @@ -78,7 +78,7 @@ func (g *gate) unlock(set bool) { } } -// unlock sets the condition to the result of f and releases the gate. +// unlockFunc sets the condition to the result of f and releases the gate. // Useful in defers. func (g *gate) unlockFunc(f func() bool) { g.unlock(f()) diff --git a/http2/netconn_test.go b/http2/netconn_test.go index 0f1b5fb1f..5a1759579 100644 --- a/http2/netconn_test.go +++ b/http2/netconn_test.go @@ -76,7 +76,7 @@ func (c *synctestNetConn) Write(b []byte) (n int, err error) { return c.rem.write(b) } -// IsClosed reports whether the peer has closed its end of the connection. +// IsClosedByPeer reports whether the peer has closed its end of the connection. func (c *synctestNetConn) IsClosedByPeer() bool { if c.autoWait { c.group.Wait() diff --git a/http2/server_test.go b/http2/server_test.go index 201cf0d00..08f2dd3b2 100644 --- a/http2/server_test.go +++ b/http2/server_test.go @@ -4327,7 +4327,7 @@ func TestCanonicalHeaderCacheGrowth(t *testing.T) { } } -// TestServerWriteDoesNotRetainBufferAfterStreamClose checks for access to +// TestServerWriteDoesNotRetainBufferAfterReturn checks for access to // the slice passed to ResponseWriter.Write after Write returns. // // Terminating the request stream on the client causes Write to return. diff --git a/quic/conn_close.go b/quic/conn_close.go index 1798d0536..18c7d2645 100644 --- a/quic/conn_close.go +++ b/quic/conn_close.go @@ -178,7 +178,7 @@ func (c *Conn) sendOK(now time.Time) bool { } } -// sendConnectionClose reports that the conn has sent a CONNECTION_CLOSE to the peer. +// sentConnectionClose reports that the conn has sent a CONNECTION_CLOSE to the peer. func (c *Conn) sentConnectionClose(now time.Time) { switch c.lifetime.state { case connStatePeerClosed: diff --git a/quic/conn_test.go b/quic/conn_test.go index f4f1818a6..51402630f 100644 --- a/quic/conn_test.go +++ b/quic/conn_test.go @@ -436,7 +436,7 @@ func (tc *testConn) write(d *testDatagram) { tc.endpoint.writeDatagram(d) } -// writeFrame sends the Conn a datagram containing the given frames. +// writeFrames sends the Conn a datagram containing the given frames. func (tc *testConn) writeFrames(ptype packetType, frames ...debugFrame) { tc.t.Helper() space := spaceForPacketType(ptype) diff --git a/quic/endpoint.go b/quic/endpoint.go index a55336b24..bf0217516 100644 --- a/quic/endpoint.go +++ b/quic/endpoint.go @@ -448,7 +448,7 @@ func (m *connsMap) updateConnIDs(f func(*connsMap)) { m.updateNeeded.Store(true) } -// applyConnIDUpdates is called by the datagram receive loop to update its connection ID map. +// applyUpdates is called by the datagram receive loop to update its connection ID map. func (m *connsMap) applyUpdates() { m.updateMu.Lock() defer m.updateMu.Unlock() diff --git a/quic/gate.go b/quic/gate.go index a2fb53711..8f1db2be6 100644 --- a/quic/gate.go +++ b/quic/gate.go @@ -27,7 +27,7 @@ func newGate() gate { return g } -// newLocked gate returns a new, locked gate. +// newLockedGate returns a new, locked gate. func newLockedGate() gate { return gate{ set: make(chan struct{}, 1), @@ -84,7 +84,7 @@ func (g *gate) unlock(set bool) { } } -// unlock sets the condition to the result of f and releases the gate. +// unlockFunc sets the condition to the result of f and releases the gate. // Useful in defers. func (g *gate) unlockFunc(f func() bool) { g.unlock(f()) diff --git a/quic/packet_protection.go b/quic/packet_protection.go index fe48c14c5..9f1bbc6a4 100644 --- a/quic/packet_protection.go +++ b/quic/packet_protection.go @@ -519,7 +519,7 @@ func hashForSuite(suite uint16) (h crypto.Hash, keySize int) { } } -// hdkfExpandLabel implements HKDF-Expand-Label from RFC 8446, Section 7.1. +// hkdfExpandLabel implements HKDF-Expand-Label from RFC 8446, Section 7.1. // // Copied from crypto/tls/key_schedule.go. func hkdfExpandLabel(hash func() hash.Hash, secret []byte, label string, context []byte, length int) []byte { diff --git a/quic/packet_writer.go b/quic/packet_writer.go index e4d71e622..2057fd026 100644 --- a/quic/packet_writer.go +++ b/quic/packet_writer.go @@ -47,7 +47,7 @@ func (w *packetWriter) datagram() []byte { return w.b } -// packet returns the size of the current packet. +// packetLen returns the size of the current packet. func (w *packetWriter) packetLen() int { return len(w.b[w.pktOff:]) + aeadOverhead } @@ -527,7 +527,7 @@ func (w *packetWriter) appendConnectionCloseTransportFrame(code transportError, return true } -// appendConnectionCloseTransportFrame appends a CONNECTION_CLOSE frame +// appendConnectionCloseApplicationFrame appends a CONNECTION_CLOSE frame // carrying an application protocol error code. func (w *packetWriter) appendConnectionCloseApplicationFrame(code uint64, reason string) (added bool) { if w.avail() < 1+sizeVarint(code)+sizeVarint(uint64(len(reason)))+len(reason) { diff --git a/quic/qlog/json_writer.go b/quic/qlog/json_writer.go index 6fb8d33b2..7867c590d 100644 --- a/quic/qlog/json_writer.go +++ b/quic/qlog/json_writer.go @@ -58,7 +58,7 @@ func (w *jsonWriter) writeAttr(a slog.Attr) { w.writeValue(a.Value) } -// writeAttr writes a []slog.Attr as an object field. +// writeAttrsField writes a []slog.Attr as an object field. func (w *jsonWriter) writeAttrsField(name string, attrs []slog.Attr) { w.writeName(name) w.writeAttrs(attrs) @@ -113,7 +113,7 @@ func (w *jsonWriter) writeObject(f func()) { w.buf.WriteByte('}') } -// writeObject writes an object-valued object field. +// writeObjectField writes an object-valued object field. // The function f is called to write the contents. func (w *jsonWriter) writeObjectField(name string, f func()) { w.writeName(name) diff --git a/quic/rtt.go b/quic/rtt.go index 4942f8cca..494060c67 100644 --- a/quic/rtt.go +++ b/quic/rtt.go @@ -37,7 +37,7 @@ func (r *rttState) establishPersistentCongestion() { r.minRTT = r.latestRTT } -// updateRTTSample is called when we generate a new RTT sample. +// updateSample is called when we generate a new RTT sample. // https://www.rfc-editor.org/rfc/rfc9002.html#section-5 func (r *rttState) updateSample(now time.Time, handshakeConfirmed bool, spaceID numberSpace, latestRTT, ackDelay, maxAckDelay time.Duration) { r.latestRTT = latestRTT diff --git a/quic/sent_val.go b/quic/sent_val.go index 31f69e47d..920658919 100644 --- a/quic/sent_val.go +++ b/quic/sent_val.go @@ -37,7 +37,7 @@ func (s sentVal) isSet() bool { return s != 0 } // shouldSend reports whether the value is set and has not been sent to the peer. func (s sentVal) shouldSend() bool { return s.state() == sentValUnsent } -// shouldSend reports whether the value needs to be sent to the peer. +// shouldSendPTO reports whether the value needs to be sent to the peer. // The value needs to be sent if it is set and has not been sent. // If pto is true, indicating that we are sending a PTO probe, the value // should also be sent if it is set and has not been acknowledged. diff --git a/quic/stream.go b/quic/stream.go index cb45534f8..817eb19a2 100644 --- a/quic/stream.go +++ b/quic/stream.go @@ -418,7 +418,7 @@ func (s *Stream) Write(b []byte) (n int, err error) { return n, nil } -// WriteBytes writes a single byte to the stream. +// WriteByte writes a single byte to the stream. func (s *Stream) WriteByte(c byte) error { if s.outbufoff < len(s.outbuf) { s.outbuf[s.outbufoff] = c diff --git a/quic/wire.go b/quic/wire.go index 848602915..dd7ebed0b 100644 --- a/quic/wire.go +++ b/quic/wire.go @@ -44,7 +44,7 @@ func consumeVarint(b []byte) (v uint64, n int) { return 0, -1 } -// consumeVarint64 parses a variable-length integer as an int64. +// consumeVarintInt64 parses a variable-length integer as an int64. func consumeVarintInt64(b []byte) (v int64, n int) { u, n := consumeVarint(b) // QUIC varints are 62-bits large, so this conversion can never overflow. diff --git a/route/sys_netbsd.go b/route/sys_netbsd.go index be4460e13..c6bb6bc8a 100644 --- a/route/sys_netbsd.go +++ b/route/sys_netbsd.go @@ -25,7 +25,7 @@ func (m *RouteMessage) Sys() []Sys { } } -// RouteMetrics represents route metrics. +// InterfaceMetrics represents route metrics. type InterfaceMetrics struct { Type int // interface type MTU int // maximum transmission unit