From: Graham Miller Date: Mon, 20 Jun 2011 19:42:17 +0000 (-0400) Subject: os: change Waitmsg String method to use pointer receiver X-Git-Tag: weekly.2011-06-23~38 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=cf201ed6a00223e1e6dd69e884f9bcd25ce2b62c;p=gostls13.git os: change Waitmsg String method to use pointer receiver Fixes #1851. R=rsc CC=golang-dev https://golang.org/cl/4628045 --- diff --git a/src/pkg/os/exec_plan9.go b/src/pkg/os/exec_plan9.go index 0598adc0fa..2590dd67de 100644 --- a/src/pkg/os/exec_plan9.go +++ b/src/pkg/os/exec_plan9.go @@ -123,6 +123,9 @@ func FindProcess(pid int) (p *Process, err Error) { return newProcess(pid, 0), nil } -func (w Waitmsg) String() string { +func (w *Waitmsg) String() string { + if w == nil { + return "" + } return "exit status: " + w.Msg } diff --git a/src/pkg/os/exec_posix.go b/src/pkg/os/exec_posix.go index 734bf887b3..7dfcdd4861 100644 --- a/src/pkg/os/exec_posix.go +++ b/src/pkg/os/exec_posix.go @@ -128,7 +128,10 @@ func itod(i int) string { return string(b[bp:]) } -func (w Waitmsg) String() string { +func (w *Waitmsg) String() string { + if w == nil { + return "" + } // TODO(austin) Use signal names when possible? res := "" switch { diff --git a/src/pkg/os/os_test.go b/src/pkg/os/os_test.go index e442e7c28a..c22b536d55 100644 --- a/src/pkg/os/os_test.go +++ b/src/pkg/os/os_test.go @@ -1042,3 +1042,11 @@ func TestStatDirWithTrailingSlash(t *testing.T) { t.Fatal("stat failed:", err) } } + +func TestNilWaitmsgString(t *testing.T) { + var w *Waitmsg + s := w.String() + if s != "" { + t.Errorf("(*Waitmsg)(nil).String() = %q, want %q", s, "") + } +}