Skip to content

Commit

Permalink
[dev.regabi] all: merge master (1901853) into dev.regabi
Browse files Browse the repository at this point in the history
Merge List:

+ 2021-02-08 1901853 runtime/metrics: fix panic in readingAllMetric example
+ 2021-02-08 ed3e4af syscall/plan9: remove spooky fd action at a distance
+ 2021-02-05 724d072 doc/go1.16: add missed heading tag in vet section
+ 2021-02-05 b54cd94 embed, io/fs: clarify that leading and trailing slashes are disallowed
+ 2021-02-05 4516afe testing/fstest: avoid symlink-induced failures in tester
+ 2021-02-04 8869086 runtime: fix typo in histogram.go
+ 2021-02-03 e491c6e math/big: fix comment in divRecursiveStep

Change-Id: I5e2bd18f42251eeb4ad0bf5c93a08c6a9b873d7b
  • Loading branch information
cherrymui committed Feb 8, 2021
2 parents 7b0dfb1 + 1901853 commit 50449de
Show file tree
Hide file tree
Showing 9 changed files with 67 additions and 21 deletions.
2 changes: 2 additions & 0 deletions doc/go1.16.html
Original file line number Diff line number Diff line change
Expand Up @@ -364,6 +364,8 @@ <h4 id="vet-string-int">New warning for invalid testing.T use in
}
</pre>

<h4 id="vet-frame-pointer">New warning for frame pointer</h4>

<p><!-- CL 248686, CL 276372 -->
The vet tool now warns about amd64 assembly that clobbers the BP
register (the frame pointer) without saving and restoring it,
Expand Down
18 changes: 9 additions & 9 deletions src/embed/embed.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,12 +61,15 @@
// The Go build system will recognize the directives and arrange for the declared variable
// (in the example above, content) to be populated with the matching files from the file system.
//
// The //go:embed directive accepts multiple space-separated patterns for brevity,
// but it can also be repeated, to avoid very long lines when there are many patterns.
// The patterns are interpreted relative to the package directory containing the source file.
// The path separator is a forward slash, even on Windows systems.
// To allow for naming files with spaces in their names, patterns can be written
// as Go double-quoted or back-quoted string literals.
// The //go:embed directive accepts multiple space-separated patterns for
// brevity, but it can also be repeated, to avoid very long lines when there are
// many patterns. The patterns are interpreted relative to the package directory
// containing the source file. The path separator is a forward slash, even on
// Windows systems. Patterns may not contain ‘.’ or ‘..’ or empty path elements,
// nor may they begin or end with a slash. To match everything in the current
// directory, use ‘*’ instead of ‘.’. To allow for naming files with spaces in
// their names, patterns can be written as Go double-quoted or back-quoted
// string literals.
//
// If a pattern names a directory, all files in the subtree rooted at that directory are
// embedded (recursively), except that files with names beginning with ‘.’ or ‘_’
Expand All @@ -87,9 +90,6 @@
// Matches for empty directories are ignored. After that, each pattern in a //go:embed line
// must match at least one file or non-empty directory.
//
// Patterns must not contain ‘.’ or ‘..’ path elements nor begin with a leading slash.
// To match everything in the current directory, use ‘*’ instead of ‘.’.
//
// If any patterns are invalid or have invalid matches, the build will fail.
//
// Strings and Bytes
Expand Down
1 change: 1 addition & 0 deletions src/io/fs/fs.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ type FS interface {
// sequences of path elements, like “x/y/z”.
// Path names must not contain a “.” or “..” or empty element,
// except for the special case that the root directory is named “.”.
// Leading and trailing slashes (like “/x” or “x/”) are not allowed.
//
// Paths are slash-separated on all systems, even Windows.
// Backslashes must not appear in path names.
Expand Down
2 changes: 1 addition & 1 deletion src/math/big/nat.go
Original file line number Diff line number Diff line change
Expand Up @@ -881,7 +881,7 @@ func (z nat) divRecursiveStep(u, v nat, depth int, tmp *nat, temps []*nat) {
// then floor(u1/v1) >= floor(u/v)
//
// Moreover, the difference is at most 2 if len(v1) >= len(u/v)
// We choose s = B-1 since len(v)-B >= B+1 >= len(u/v)
// We choose s = B-1 since len(v)-s >= B+1 >= len(u/v)
s := (B - 1)
// Except for the first step, the top bits are always
// a division remainder, so the quotient length is <= n.
Expand Down
2 changes: 1 addition & 1 deletion src/runtime/histogram.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ const (
// The number of super-buckets (timeHistNumSuperBuckets), on the
// other hand, defines the range. To reserve room for sub-buckets,
// bit timeHistSubBucketBits is the first bit considered for
// super-buckets, so super-bucket indicies are adjusted accordingly.
// super-buckets, so super-bucket indices are adjusted accordingly.
//
// As an example, consider 45 super-buckets with 16 sub-buckets.
//
Expand Down
2 changes: 1 addition & 1 deletion src/runtime/metrics/example_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ func medianBucket(h *metrics.Float64Histogram) float64 {
total = 0
for i, count := range h.Counts {
total += count
if total > thresh {
if total >= thresh {
return h.Buckets[i]
}
}
Expand Down
5 changes: 3 additions & 2 deletions src/syscall/exec_plan9.go
Original file line number Diff line number Diff line change
Expand Up @@ -320,14 +320,15 @@ func cexecPipe(p []int) error {
return e
}

fd, e := Open("#d/"+itoa(p[1]), O_CLOEXEC)
fd, e := Open("#d/"+itoa(p[1]), O_RDWR|O_CLOEXEC)
if e != nil {
Close(p[0])
Close(p[1])
return e
}

Close(fd)
Close(p[1])
p[1] = fd
return nil
}

Expand Down
25 changes: 18 additions & 7 deletions src/testing/fstest/testfs.go
Original file line number Diff line number Diff line change
Expand Up @@ -403,22 +403,33 @@ func (t *fsTester) checkStat(path string, entry fs.DirEntry) {
return
}
fentry := formatEntry(entry)
finfo := formatInfoEntry(info)
if fentry != finfo {
t.errorf("%s: mismatch:\n\tentry = %s\n\tfile.Stat() = %s", path, fentry, finfo)
fientry := formatInfoEntry(info)
// Note: mismatch here is OK for symlink, because Open dereferences symlink.
if fentry != fientry && entry.Type()&fs.ModeSymlink == 0 {
t.errorf("%s: mismatch:\n\tentry = %s\n\tfile.Stat() = %s", path, fentry, fientry)
}

einfo, err := entry.Info()
if err != nil {
t.errorf("%s: entry.Info: %v", path, err)
return
}
fentry = formatInfo(einfo)
finfo = formatInfo(info)
if fentry != finfo {
t.errorf("%s: mismatch:\n\tentry.Info() = %s\n\tfile.Stat() = %s\n", path, fentry, finfo)
finfo := formatInfo(info)
if entry.Type()&fs.ModeSymlink != 0 {
// For symlink, just check that entry.Info matches entry on common fields.
// Open deferences symlink, so info itself may differ.
feentry := formatInfoEntry(einfo)
if fentry != feentry {
t.errorf("%s: mismatch\n\tentry = %s\n\tentry.Info() = %s\n", path, fentry, feentry)
}
} else {
feinfo := formatInfo(einfo)
if feinfo != finfo {
t.errorf("%s: mismatch:\n\tentry.Info() = %s\n\tfile.Stat() = %s\n", path, feinfo, finfo)
}
}

// Stat should be the same as Open+Stat, even for symlinks.
info2, err := fs.Stat(t.fsys, path)
if err != nil {
t.errorf("%s: fs.Stat: %v", path, err)
Expand Down
31 changes: 31 additions & 0 deletions src/testing/fstest/testfs_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
// Copyright 2021 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

package fstest

import (
"internal/testenv"
"os"
"path/filepath"
"testing"
)

func TestSymlink(t *testing.T) {
testenv.MustHaveSymlink(t)

tmp := t.TempDir()
tmpfs := os.DirFS(tmp)

if err := os.WriteFile(filepath.Join(tmp, "hello"), []byte("hello, world\n"), 0644); err != nil {
t.Fatal(err)
}

if err := os.Symlink(filepath.Join(tmp, "hello"), filepath.Join(tmp, "hello.link")); err != nil {
t.Fatal(err)
}

if err := TestFS(tmpfs, "hello", "hello.link"); err != nil {
t.Fatal(err)
}
}

0 comments on commit 50449de

Please sign in to comment.