]> Cypherpunks.ru repositories - gostls13.git/commitdiff
syscall: remove dependency on io
authorRuss Cox <rsc@golang.org>
Sun, 5 Jul 2020 20:34:27 +0000 (16:34 -0400)
committerRuss Cox <rsc@golang.org>
Tue, 13 Oct 2020 00:55:35 +0000 (00:55 +0000)
Keep syscall and io separated; neither should depend on the other.

Change-Id: Icdd61bd0c05d874cabd7b5ae6631dd09dec90112
Reviewed-on: https://go-review.googlesource.com/c/go/+/243902
Trust: Russ Cox <rsc@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Rob Pike <r@golang.org>
src/go/build/deps_test.go
src/internal/syscall/windows/registry/key.go
src/internal/syscall/windows/registry/registry_test.go
src/internal/syscall/windows/registry/value.go
src/mime/type_windows.go
src/syscall/fs_js.go
src/time/zoneinfo_windows.go

index ec2a2f93283eef503e1552314c63f1c675071c44..1edd96c5e37dded4c588c4879e34877c182c4d15 100644 (file)
@@ -102,7 +102,7 @@ var depsRules = `
        reflect !< sort;
 
        # SYSCALL is RUNTIME plus the packages necessary for basic system calls.
-       RUNTIME, unicode/utf8, unicode/utf16, io
+       RUNTIME, unicode/utf8, unicode/utf16
        < internal/syscall/windows/sysdll, syscall/js
        < syscall
        < internal/syscall/unix, internal/syscall/windows, internal/syscall/windows/registry
index cc3d0c774bdac37eccfbcc6f81d6ba5429348315..612c48f084060fa7c98339e91c076df070123532 100644 (file)
 //
 package registry
 
-import (
-       "io"
-       "syscall"
-)
+import "syscall"
 
 const (
        // Registry key security and access rights.
@@ -90,20 +87,13 @@ func OpenKey(k Key, path string, access uint32) (Key, error) {
 }
 
 // ReadSubKeyNames returns the names of subkeys of key k.
-// The parameter n controls the number of returned names,
-// analogous to the way os.File.Readdirnames works.
-func (k Key) ReadSubKeyNames(n int) ([]string, error) {
+func (k Key) ReadSubKeyNames() ([]string, error) {
        names := make([]string, 0)
        // Registry key size limit is 255 bytes and described there:
        // https://msdn.microsoft.com/library/windows/desktop/ms724872.aspx
        buf := make([]uint16, 256) //plus extra room for terminating zero byte
 loopItems:
        for i := uint32(0); ; i++ {
-               if n > 0 {
-                       if len(names) == n {
-                               return names, nil
-                       }
-               }
                l := uint32(len(buf))
                for {
                        err := syscall.RegEnumKeyEx(syscall.Handle(k), i, &buf[0], &l, nil, nil, nil, nil)
@@ -123,9 +113,6 @@ loopItems:
                }
                names = append(names, syscall.UTF16ToString(buf[:l]))
        }
-       if n > len(names) {
-               return names, io.EOF
-       }
        return names, nil
 }
 
index 8227232c70382f6a0b6662b17cc5e0499736b575..57971629006a7a842ba748eeca38cf84c58078af 100644 (file)
@@ -34,7 +34,7 @@ func TestReadSubKeyNames(t *testing.T) {
        }
        defer k.Close()
 
-       names, err := k.ReadSubKeyNames(-1)
+       names, err := k.ReadSubKeyNames()
        if err != nil {
                t.Fatal(err)
        }
@@ -190,7 +190,7 @@ func setValues(t *testing.T, k registry.Key) {
 }
 
 func enumerateValues(t *testing.T, k registry.Key) {
-       names, err := k.ReadValueNames(-1)
+       names, err := k.ReadValueNames()
        if err != nil {
                t.Error(err)
                return
@@ -480,7 +480,7 @@ func deleteValues(t *testing.T, k registry.Key) {
                        continue
                }
        }
-       names, err := k.ReadValueNames(-1)
+       names, err := k.ReadValueNames()
        if err != nil {
                t.Error(err)
                return
index bf8ab007590941e7a75b65ee7f63adc2dd7f37f6..dc3930a6bc2edaa753b23a14f49ff2ecc1af6f13 100644 (file)
@@ -8,7 +8,6 @@ package registry
 
 import (
        "errors"
-       "io"
        "syscall"
        "unicode/utf16"
        "unsafe"
@@ -341,9 +340,7 @@ func (k Key) DeleteValue(name string) error {
 }
 
 // ReadValueNames returns the value names of key k.
-// The parameter n controls the number of returned names,
-// analogous to the way os.File.Readdirnames works.
-func (k Key) ReadValueNames(n int) ([]string, error) {
+func (k Key) ReadValueNames() ([]string, error) {
        ki, err := k.Stat()
        if err != nil {
                return nil, err
@@ -352,11 +349,6 @@ func (k Key) ReadValueNames(n int) ([]string, error) {
        buf := make([]uint16, ki.MaxValueNameLen+1) // extra room for terminating null character
 loopItems:
        for i := uint32(0); ; i++ {
-               if n > 0 {
-                       if len(names) == n {
-                               return names, nil
-                       }
-               }
                l := uint32(len(buf))
                for {
                        err := regEnumValue(syscall.Handle(k), i, &buf[0], &l, nil, nil, nil, nil)
@@ -376,8 +368,5 @@ loopItems:
                }
                names = append(names, syscall.UTF16ToString(buf[:l]))
        }
-       if n > len(names) {
-               return names, io.EOF
-       }
        return names, nil
 }
index 97b9aeba7a3dc8916fb41b391d1e4cbb5e8ebde7..cee9c9db041b2beff5e0820698cf2484de20e0cb 100644 (file)
@@ -13,7 +13,7 @@ func init() {
 }
 
 func initMimeWindows() {
-       names, err := registry.CLASSES_ROOT.ReadSubKeyNames(-1)
+       names, err := registry.CLASSES_ROOT.ReadSubKeyNames()
        if err != nil {
                return
        }
index 262ec28afdd2a087275303f0cf3626a4a7443fbe..673feea77f24ac9dd8ca5769511d597bbe154f46 100644 (file)
@@ -8,7 +8,6 @@ package syscall
 
 import (
        "errors"
-       "io"
        "sync"
        "syscall/js"
 )
@@ -456,11 +455,11 @@ func Seek(fd int, offset int64, whence int) (int64, error) {
 
        var newPos int64
        switch whence {
-       case io.SeekStart:
+       case 0:
                newPos = offset
-       case io.SeekCurrent:
+       case 1:
                newPos = f.pos + offset
-       case io.SeekEnd:
+       case 2:
                var st Stat_t
                if err := Fstat(fd, &st); err != nil {
                        return 0, err
index 2b69d06a1dd36df2177853d915d4b8feab7e88b4..ba66f90ffeaf20cf6cdfee762f3782a4be97f73e 100644 (file)
@@ -67,7 +67,7 @@ func toEnglishName(stdname, dstname string) (string, error) {
        }
        defer k.Close()
 
-       names, err := k.ReadSubKeyNames(-1)
+       names, err := k.ReadSubKeyNames()
        if err != nil {
                return "", err
        }