Skip to content

Commit

Permalink
all: gofmt main repo
Browse files Browse the repository at this point in the history
Excluding vendor and testdata.
CL 384268 already reformatted most, but these slipped past.

The struct in the doc comment in debug/dwarf/type.go
was fixed up by hand to indent the first and last lines as well.

For golang#51082.

Change-Id: Iad020f83aafd671ff58238fe491907e85923d0c7
Reviewed-on: https://go-review.googlesource.com/c/go/+/407137
Run-TryBot: Russ Cox <[email protected]>
TryBot-Result: Gopher Robot <[email protected]>
Auto-Submit: Russ Cox <[email protected]>
Reviewed-by: Ian Lance Taylor <[email protected]>
  • Loading branch information
rsc authored and gopherbot committed May 19, 2022
1 parent e23cc08 commit 946b4ba
Show file tree
Hide file tree
Showing 22 changed files with 66 additions and 61 deletions.
2 changes: 1 addition & 1 deletion src/archive/zip/reader.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ type File struct {
zip *Reader
zipr io.ReaderAt
headerOffset int64 // includes overall ZIP archive baseOffset
zip64 bool // zip64 extended information extra field presence
zip64 bool // zip64 extended information extra field presence
}

// OpenReader will open the Zip file specified by name and return a ReadCloser.
Expand Down
12 changes: 7 additions & 5 deletions src/cmd/compile/internal/ir/stmt.go
Original file line number Diff line number Diff line change
Expand Up @@ -264,11 +264,13 @@ func NewIfStmt(pos src.XPos, cond Node, body, els []Node) *IfStmt {
}

// A JumpTableStmt is used to implement switches. Its semantics are:
// tmp := jt.Idx
// if tmp == Cases[0] goto Targets[0]
// if tmp == Cases[1] goto Targets[1]
// ...
// if tmp == Cases[n] goto Targets[n]
//
// tmp := jt.Idx
// if tmp == Cases[0] goto Targets[0]
// if tmp == Cases[1] goto Targets[1]
// ...
// if tmp == Cases[n] goto Targets[n]
//
// Note that a JumpTableStmt is more like a multiway-goto than
// a multiway-if. In particular, the case bodies are just
// labels to jump to, not not full Nodes lists.
Expand Down
6 changes: 3 additions & 3 deletions src/cmd/compile/internal/types2/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -420,9 +420,9 @@ func (conf *Config) Check(path string, files []*syntax.File, info *Info) (*Packa
// AssertableTo reports whether a value of type V can be asserted to have type T.
//
// The behavior of AssertableTo is undefined in two cases:
// - if V is a generalized interface; i.e., an interface that may only be used
// as a type constraint in Go code
// - if T is an uninstantiated generic type
// - if V is a generalized interface; i.e., an interface that may only be used
// as a type constraint in Go code
// - if T is an uninstantiated generic type
func AssertableTo(V *Interface, T Type) bool {
// Checker.newAssertableTo suppresses errors for invalid types, so we need special
// handling here.
Expand Down
2 changes: 1 addition & 1 deletion src/cmd/pprof/doc.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
//
// For detailed usage information:
//
// go tool pprof -h
// go tool pprof -h
//
// For an example, see https://blog.golang.org/profiling-go-programs.
package main
1 change: 1 addition & 0 deletions src/crypto/aes/cbc_ppc64x.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ func (b *aesCipherAsm) NewCBCDecrypter(iv []byte) cipher.BlockMode {
func (x *cbc) BlockSize() int { return BlockSize }

// cryptBlocksChain invokes the cipher message identifying encrypt or decrypt.
//
//go:noescape
func cryptBlocksChain(src, dst *byte, length int, key *uint32, iv *byte, enc int, nr int)

Expand Down
39 changes: 19 additions & 20 deletions src/debug/dwarf/type.go
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ type StructType struct {

// A StructField represents a field in a struct, union, or C++ class type.
//
// Bit Fields
// # Bit Fields
//
// The BitSize, BitOffset, and DataBitOffset fields describe the bit
// size and offset of data members declared as bit fields in C/C++
Expand Down Expand Up @@ -185,24 +185,24 @@ type StructType struct {
// Here is an example of C/C++ bit field use, along with what to
// expect in terms of DWARF bit offset info. Consider this code:
//
// struct S {
// int q;
// int j:5;
// int k:6;
// int m:5;
// int n:8;
// } s;
// struct S {
// int q;
// int j:5;
// int k:6;
// int m:5;
// int n:8;
// } s;
//
// For the code above, one would expect to see the following for
// DW_AT_bit_offset values (using GCC 8):
//
// Little | Big
// Endian | Endian
// |
// "j": 27 | 0
// "k": 21 | 5
// "m": 16 | 11
// "n": 8 | 16
// Little | Big
// Endian | Endian
// |
// "j": 27 | 0
// "k": 21 | 5
// "m": 16 | 11
// "n": 8 | 16
//
// Note that in the above the offsets are purely with respect to the
// containing storage unit for j/k/m/n -- these values won't vary based
Expand All @@ -211,10 +211,10 @@ type StructType struct {
// If the compiler emits DW_AT_data_bit_offset, the expected values
// would be:
//
// "j": 32
// "k": 37
// "m": 43
// "n": 48
// "j": 32
// "k": 37
// "m": 43
// "n": 48
//
// Here the value 32 for "j" reflects the fact that the bit field is
// preceded by other data members (recall that DW_AT_data_bit_offset
Expand All @@ -226,7 +226,6 @@ type StructType struct {
// non-zero bit size and bit offset, so this information is also
// captured for base types, but it is worth noting that it is not
// possible to trigger this behavior using mainstream languages.
//
type StructField struct {
Name string
Type Type
Expand Down
1 change: 0 additions & 1 deletion src/debug/dwarf/type_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,6 @@ var bitfieldTests = map[string]string{
// another_struct {quix short unsigned int@0; xyz [-1]int@4; x unsigned int@4 : 1@31; array [40]long long int@8}
//
// Note the "-1" for the xyz field, which should be zero.
//
func TestBitFieldZeroArrayIssue50685(t *testing.T) {
f := "testdata/bitfields.elf4"
testTypedefs(t, elfData(t, f), "elf", bitfieldTests)
Expand Down
18 changes: 9 additions & 9 deletions src/debug/pe/symbol.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,19 +30,19 @@ type COFFSymbol struct {
// symbols for a given primary symbol are placed following it in the
// array, e.g.
//
// ...
// k+0: regular sym k
// k+1: 1st aux symbol for k
// k+2: 2nd aux symbol for k
// k+3: regular sym k+3
// k+4: 1st aux symbol for k+3
// k+5: regular sym k+5
// k+6: regular sym k+6
// ...
// k+0: regular sym k
// k+1: 1st aux symbol for k
// k+2: 2nd aux symbol for k
// k+3: regular sym k+3
// k+4: 1st aux symbol for k+3
// k+5: regular sym k+5
// k+6: regular sym k+6
//
// The PE format allows for several possible aux symbol formats. For
// more info see:
//
// https://docs.microsoft.com/en-us/windows/win32/debug/pe-format#auxiliary-symbol-records
// https://docs.microsoft.com/en-us/windows/win32/debug/pe-format#auxiliary-symbol-records
//
// At the moment this package only provides APIs for looking at
// aux symbols of format 5 (associated with section definition symbols).
Expand Down
1 change: 0 additions & 1 deletion src/go/internal/gcimporter/exportdata.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ func readGopackHeader(r *bufio.Reader) (name string, size int, err error) {
// file by reading from it. The reader must be positioned at the
// start of the file before calling this function. The hdr result
// is the string before the export data, either "$$" or "$$B".
//
func FindExportData(r *bufio.Reader) (hdr string, size int, err error) {
// Read first line to make sure this is an object file.
line, err := r.ReadSlice('\n')
Expand Down
1 change: 0 additions & 1 deletion src/internal/diff/diff.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ type pair struct{ x, y int }
// Second, the name is frequently interpreted as meaning that you have
// to wait longer (to be patient) for the diff, meaning that it is a slower algorithm,
// when in fact the algorithm is faster than the standard one.
//
func Diff(oldName string, old []byte, newName string, new []byte) []byte {
if bytes.Equal(old, new) {
return nil
Expand Down
2 changes: 1 addition & 1 deletion src/io/multi.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ func (mr *multiReader) Read(p []byte) (n int, err error) {
}

func (mr *multiReader) WriteTo(w Writer) (sum int64, err error) {
return mr.writeToWithBuffer(w, make([]byte, 1024 * 32))
return mr.writeToWithBuffer(w, make([]byte, 1024*32))
}

func (mr *multiReader) writeToWithBuffer(w Writer, buf []byte) (sum int64, err error) {
Expand Down
4 changes: 2 additions & 2 deletions src/math/big/alias_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ func (smallUint) Generate(rand *rand.Rand, size int) reflect.Value {
// f is a function that takes x as an argument, doesn't modify it, sets v to the
// result, and returns v. It is the function signature of unbound methods like
//
// func (v *big.Int) m(x *big.Int) *big.Int
// func (v *big.Int) m(x *big.Int) *big.Int
//
// v and x are two random Int values. v is randomized even if it will be
// overwritten to test for improper buffer reuse.
Expand Down Expand Up @@ -122,7 +122,7 @@ func checkAliasingOneArg(t *testing.T, f func(v, x *big.Int) *big.Int, v, x *big
// to the result, and returns v. It is the function signature of unbound methods
// like
//
// func (v *big.Int) m(x, y *big.Int) *big.Int
// func (v *big.Int) m(x, y *big.Int) *big.Int
//
// v, x and y are random Int values. v is randomized even if it will be
// overwritten to test for improper buffer reuse.
Expand Down
4 changes: 3 additions & 1 deletion src/net/net.go
Original file line number Diff line number Diff line change
Expand Up @@ -588,7 +588,9 @@ func (e InvalidAddrError) Temporary() bool { return false }
//
// TODO(iant): We could consider changing this to os.ErrDeadlineExceeded
// in the future, if we make
// errors.Is(os.ErrDeadlineExceeded, context.DeadlineExceeded)
//
// errors.Is(os.ErrDeadlineExceeded, context.DeadlineExceeded)
//
// return true.
var errTimeout error = &timeoutError{}

Expand Down
5 changes: 2 additions & 3 deletions src/runtime/debug/garbage.go
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,6 @@ func SetTraceback(level string)
// aggressively. This limit will be respected even if GOGC=off (or,
// if SetGCPercent(-1) is executed).
//
//
// The input limit is provided as bytes, and includes all memory
// mapped, managed, and not released by the Go runtime. Notably, it
// does not account for space used by the Go binary and memory
Expand All @@ -202,11 +201,11 @@ func SetTraceback(level string)
// More specifically, the following expression accurately reflects
// the value the runtime attempts to maintain as the limit:
//
// runtime.MemStats.Sys - runtime.MemStats.HeapReleased
// runtime.MemStats.Sys - runtime.MemStats.HeapReleased
//
// or in terms of the runtime/metrics package:
//
// /memory/classes/total:bytes - /memory/classes/heap/released:bytes
// /memory/classes/total:bytes - /memory/classes/heap/released:bytes
//
// A zero limit or a limit that's lower than the amount of memory
// used by the Go runtime may cause the garbage collector to run
Expand Down
2 changes: 2 additions & 0 deletions src/runtime/mem.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ import "unsafe"
//
// Don't split the stack as this function may be invoked without a valid G,
// which prevents us from allocating more stack.
//
//go:nosplit
func sysAlloc(n uintptr, sysStat *sysMemStat) unsafe.Pointer {
sysStat.add(int64(n))
Expand Down Expand Up @@ -94,6 +95,7 @@ func sysHugePage(v unsafe.Pointer, n uintptr) {
//
// Don't split the stack as this function may be invoked without a valid G,
// which prevents us from allocating more stack.
//
//go:nosplit
func sysFree(v unsafe.Pointer, n uintptr, sysStat *sysMemStat) {
sysStat.add(-int64(n))
Expand Down
2 changes: 2 additions & 0 deletions src/runtime/mgcpacer.go
Original file line number Diff line number Diff line change
Expand Up @@ -1456,6 +1456,7 @@ func (c *piController) reset() {
// If this returns false, the caller must NOT become an idle mark worker.
//
// nosplit because it may be called without a P.
//
//go:nosplit
func (c *gcControllerState) addIdleMarkWorker() bool {
for {
Expand Down Expand Up @@ -1483,6 +1484,7 @@ func (c *gcControllerState) addIdleMarkWorker() bool {
// useful for a quick check before an expensive operation.
//
// nosplit because it may be called without a P.
//
//go:nosplit
func (c *gcControllerState) needIdleMarkWorker() bool {
p := c.idleMarkWorkers.Load()
Expand Down
1 change: 1 addition & 0 deletions src/runtime/os_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -864,6 +864,7 @@ func syscall_runtime_doAllThreadsSyscall(trap, a1, a2, a3, a4, a5, a6 uintptr) (
//
// This function throws if the system call returns with anything other than the
// expected values.
//
//go:nosplit
func runPerThreadSyscall() {
gp := getg()
Expand Down
2 changes: 1 addition & 1 deletion src/runtime/string.go
Original file line number Diff line number Diff line change
Expand Up @@ -425,7 +425,7 @@ func atoi32(s string) (int32, bool) {
//
// s must match the following regular expression:
//
// ^[0-9]+(([KMGT]i)?B)?$
// ^[0-9]+(([KMGT]i)?B)?$
//
// In other words, an integer byte count with an optional unit
// suffix. Acceptable suffixes include one of
Expand Down
3 changes: 1 addition & 2 deletions src/runtime/vdso_linux_s390x.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@
// license that can be found in the LICENSE file.

//go:build linux && s390x
// +build linux
// +build s390x
// +build linux,s390x

package runtime

Expand Down
17 changes: 9 additions & 8 deletions src/sort/search.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,14 +87,15 @@ func Search(n int, f func(int) bool) int {
//
// For example, to look for a particular string in a sorted, random-access
// list of strings:
// i, found := sort.Find(x.Len(), func(i int) int {
// return strings.Compare(target, x.At(i))
// })
// if found {
// fmt.Printf("found %s at entry %d\n", target, i)
// } else {
// fmt.Printf("%s not found, would insert at %d", target, i)
// }
//
// i, found := sort.Find(x.Len(), func(i int) int {
// return strings.Compare(target, x.At(i))
// })
// if found {
// fmt.Printf("found %s at entry %d\n", target, i)
// } else {
// fmt.Printf("%s not found, would insert at %d", target, i)
// }
func Find(n int, cmp func(int) int) (i int, found bool) {
// The invariants here are similar to the ones in Search.
// Define cmp(-1) > 0 and cmp(n) <= 0
Expand Down
1 change: 0 additions & 1 deletion src/sync/atomic/doc.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@
// The load and store operations, implemented by the LoadT and StoreT
// functions, are the atomic equivalents of "return *addr" and
// "*addr = val".
//
package atomic

import (
Expand Down
1 change: 1 addition & 0 deletions src/syscall/syscall_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ func RawSyscall6(trap, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2 uintptr, err Errn

//go:linkname runtime_entersyscall runtime.entersyscall
func runtime_entersyscall()

//go:linkname runtime_exitsyscall runtime.exitsyscall
func runtime_exitsyscall()

Expand Down

0 comments on commit 946b4ba

Please sign in to comment.