]> Cypherpunks repositories - gostls13.git/commitdiff
syscall: On Windows, Errstr FormatMessage has no values to insert.
authorPeter Mundy <go.peter.90@gmail.com>
Wed, 21 Jul 2010 16:40:08 +0000 (09:40 -0700)
committerRuss Cox <rsc@golang.org>
Wed, 21 Jul 2010 16:40:08 +0000 (09:40 -0700)
For the Windows version of syscall Errstr, set the
FORMAT_MESSAGE_IGNORE_INSERTS value of the FormatMessage
Flags argument when there are no values to insert.

R=rsc, brainman
CC=golang-dev
https://golang.org/cl/1868043

src/pkg/syscall/syscall_windows.go

index a7f03add440caa80e279253edf5b3dcf84d7e8bd..6aef0ded0e77d5f2d3e8c4a961c922997355a5d2 100644 (file)
@@ -142,8 +142,9 @@ func Errstr(errno int) string {
        if errno == EWINDOWS {
                return "not supported by windows"
        }
+       var flags uint32 = FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_ARGUMENT_ARRAY | FORMAT_MESSAGE_IGNORE_INSERTS
        b := make([]uint16, 300)
-       n, err := FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM|FORMAT_MESSAGE_ARGUMENT_ARRAY, 0, uint32(errno), 0, b, nil)
+       n, err := FormatMessage(flags, 0, uint32(errno), 0, b, nil)
        if err != 0 {
                return "error " + str(errno) + " (FormatMessage failed with err=" + str(err) + ")"
        }