[go] syscall: fix ComputerName on Windows

4 views
Skip to first unread message

Quim Muntal (Gerrit)

unread,
May 29, 2023, 5:49:17 AM5/29/23
to goph...@pubsubhelper.golang.org, Alex Brainman, Bryan Mills, golang-co...@googlegroups.com

Attention is currently required from: Alex Brainman, Bryan Mills.

Patch set 1:Run-TryBot +1Commit-Queue +1

View Change

    To view, visit change 499035. To unsubscribe, or for help writing mail filters, visit settings.

    Gerrit-MessageType: comment
    Gerrit-Project: go
    Gerrit-Branch: master
    Gerrit-Change-Id: I3f4b30d2f9825d321a6d28ec82bdc7b6294e04e4
    Gerrit-Change-Number: 499035
    Gerrit-PatchSet: 1
    Gerrit-Owner: Quim Muntal <quimm...@gmail.com>
    Gerrit-Reviewer: Alex Brainman <alex.b...@gmail.com>
    Gerrit-Reviewer: Bryan Mills <bcm...@google.com>
    Gerrit-Reviewer: Quim Muntal <quimm...@gmail.com>
    Gerrit-Attention: Bryan Mills <bcm...@google.com>
    Gerrit-Attention: Alex Brainman <alex.b...@gmail.com>
    Gerrit-Comment-Date: Mon, 29 May 2023 09:49:12 +0000
    Gerrit-HasComments: No
    Gerrit-Has-Labels: Yes

    Alex Brainman (Gerrit)

    unread,
    May 29, 2023, 6:19:44 AM5/29/23
    to Quim Muntal, goph...@pubsubhelper.golang.org, Gopher Robot, Go LUCI, Bryan Mills, golang-co...@googlegroups.com

    Attention is currently required from: Bryan Mills, Quim Muntal.

    Patch set 1:Code-Review +2

    View Change

    1 comment:

    To view, visit change 499035. To unsubscribe, or for help writing mail filters, visit settings.

    Gerrit-MessageType: comment
    Gerrit-Project: go
    Gerrit-Branch: master
    Gerrit-Change-Id: I3f4b30d2f9825d321a6d28ec82bdc7b6294e04e4
    Gerrit-Change-Number: 499035
    Gerrit-PatchSet: 1
    Gerrit-Owner: Quim Muntal <quimm...@gmail.com>
    Gerrit-Reviewer: Alex Brainman <alex.b...@gmail.com>
    Gerrit-Reviewer: Bryan Mills <bcm...@google.com>
    Gerrit-Reviewer: Gopher Robot <go...@golang.org>
    Gerrit-Reviewer: Quim Muntal <quimm...@gmail.com>
    Gerrit-Attention: Bryan Mills <bcm...@google.com>
    Gerrit-Attention: Quim Muntal <quimm...@gmail.com>
    Gerrit-Comment-Date: Mon, 29 May 2023 10:19:38 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: Yes

    Dmitri Shuralyov (Gerrit)

    unread,
    May 29, 2023, 5:20:28 PM5/29/23
    to Quim Muntal, goph...@pubsubhelper.golang.org, Dmitri Shuralyov, Alex Brainman, Gopher Robot, Go LUCI, Bryan Mills, golang-co...@googlegroups.com

    Attention is currently required from: Bryan Mills, Quim Muntal.

    Patch set 1:Code-Review +1

    View Change

      To view, visit change 499035. To unsubscribe, or for help writing mail filters, visit settings.

      Gerrit-MessageType: comment
      Gerrit-Project: go
      Gerrit-Branch: master
      Gerrit-Change-Id: I3f4b30d2f9825d321a6d28ec82bdc7b6294e04e4
      Gerrit-Change-Number: 499035
      Gerrit-PatchSet: 1
      Gerrit-Owner: Quim Muntal <quimm...@gmail.com>
      Gerrit-Reviewer: Alex Brainman <alex.b...@gmail.com>
      Gerrit-Reviewer: Bryan Mills <bcm...@google.com>
      Gerrit-Reviewer: Dmitri Shuralyov <dmit...@google.com>
      Gerrit-Reviewer: Gopher Robot <go...@golang.org>
      Gerrit-Reviewer: Quim Muntal <quimm...@gmail.com>
      Gerrit-CC: Dmitri Shuralyov <dmit...@golang.org>
      Gerrit-Attention: Bryan Mills <bcm...@google.com>
      Gerrit-Attention: Quim Muntal <quimm...@gmail.com>
      Gerrit-Comment-Date: Mon, 29 May 2023 21:20:25 +0000
      Gerrit-HasComments: No
      Gerrit-Has-Labels: Yes

      Bryan Mills (Gerrit)

      unread,
      May 30, 2023, 9:34:05 AM5/30/23
      to Quim Muntal, goph...@pubsubhelper.golang.org, Bryan Mills, Dmitri Shuralyov, Dmitri Shuralyov, Alex Brainman, Gopher Robot, Go LUCI, golang-co...@googlegroups.com

      Attention is currently required from: Quim Muntal.

      Patch set 1:Code-Review +2

      View Change

        To view, visit change 499035. To unsubscribe, or for help writing mail filters, visit settings.

        Gerrit-MessageType: comment
        Gerrit-Project: go
        Gerrit-Branch: master
        Gerrit-Change-Id: I3f4b30d2f9825d321a6d28ec82bdc7b6294e04e4
        Gerrit-Change-Number: 499035
        Gerrit-PatchSet: 1
        Gerrit-Owner: Quim Muntal <quimm...@gmail.com>
        Gerrit-Reviewer: Alex Brainman <alex.b...@gmail.com>
        Gerrit-Reviewer: Bryan Mills <bcm...@google.com>
        Gerrit-Reviewer: Dmitri Shuralyov <dmit...@google.com>
        Gerrit-Reviewer: Gopher Robot <go...@golang.org>
        Gerrit-Reviewer: Quim Muntal <quimm...@gmail.com>
        Gerrit-CC: Dmitri Shuralyov <dmit...@golang.org>
        Gerrit-Attention: Quim Muntal <quimm...@gmail.com>
        Gerrit-Comment-Date: Tue, 30 May 2023 13:34:02 +0000
        Gerrit-HasComments: No
        Gerrit-Has-Labels: Yes

        Quim Muntal (Gerrit)

        unread,
        May 30, 2023, 9:49:00 AM5/30/23
        to goph...@pubsubhelper.golang.org, golang-...@googlegroups.com, Bryan Mills, Dmitri Shuralyov, Dmitri Shuralyov, Alex Brainman, Gopher Robot, Go LUCI, golang-co...@googlegroups.com

        Quim Muntal submitted this change.

        View Change

        Approvals: Alex Brainman: Looks good to me, approved Dmitri Shuralyov: Looks good to me, but someone else must approve Bryan Mills: Looks good to me, approved Quim Muntal: Run TryBots Gopher Robot: TryBots succeeded
        syscall: fix ComputerName on Windows

        GetComputerName expects n to be the size of the buffer, and
        on output contains the number of characters copied to the buffer.

        CL 493036 broke ComputerName by always setting n to 0.

        Change-Id: I3f4b30d2f9825d321a6d28ec82bdc7b6294e04e4
        Reviewed-on: https://go-review.googlesource.com/c/go/+/499035
        Run-TryBot: Quim Muntal <quimm...@gmail.com>
        Reviewed-by: Dmitri Shuralyov <dmit...@google.com>
        TryBot-Result: Gopher Robot <go...@golang.org>
        Reviewed-by: Alex Brainman <alex.b...@gmail.com>
        Reviewed-by: Bryan Mills <bcm...@google.com>
        ---
        M src/syscall/syscall_windows.go
        M src/syscall/syscall_windows_test.go
        2 files changed, 12 insertions(+), 2 deletions(-)

        diff --git a/src/syscall/syscall_windows.go b/src/syscall/syscall_windows.go
        index d721309..9f1b384 100644
        --- a/src/syscall/syscall_windows.go
        +++ b/src/syscall/syscall_windows.go
        @@ -585,8 +585,8 @@
        }

        func ComputerName() (name string, err error) {
        - b := make([]uint16, MAX_COMPUTERNAME_LENGTH+1)
        - var n uint32
        + var n uint32 = MAX_COMPUTERNAME_LENGTH + 1
        + b := make([]uint16, n)
        e := GetComputerName(&b[0], &n)
        if e != nil {
        return "", e
        diff --git a/src/syscall/syscall_windows_test.go b/src/syscall/syscall_windows_test.go
        index 23041ee..7b31a86 100644
        --- a/src/syscall/syscall_windows_test.go
        +++ b/src/syscall/syscall_windows_test.go
        @@ -37,6 +37,16 @@
        }
        }

        +func TestComputerName(t *testing.T) {
        + name, err := syscall.ComputerName()
        + if err != nil {
        + t.Fatalf("ComputerName failed: %v", err)
        + }
        + if len(name) == 0 {
        + t.Error("ComputerName returned empty string")
        + }
        +}
        +
        func TestWin32finddata(t *testing.T) {
        dir := t.TempDir()


        To view, visit change 499035. To unsubscribe, or for help writing mail filters, visit settings.

        Gerrit-MessageType: merged
        Gerrit-Project: go
        Gerrit-Branch: master
        Gerrit-Change-Id: I3f4b30d2f9825d321a6d28ec82bdc7b6294e04e4
        Gerrit-Change-Number: 499035
        Gerrit-PatchSet: 2
        Reply all
        Reply to author
        Forward
        0 new messages