Skip to content

Commit

Permalink
Fix UTF16PtrFromString usage
Browse files Browse the repository at this point in the history
  • Loading branch information
RebeccaMahany committed Feb 1, 2024
1 parent c79e3c2 commit fd3a9b2
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions pkg/log/eventlog/writer_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,16 @@ func openHandle(host, source string) (h windows.Handle, err error) {
}
var s *uint16
if host != "" {
s = syscall.UTF16PtrFromString(host)
s, err = syscall.UTF16PtrFromString(host)
if err != nil {
return h, err
}
}
h, err = windows.RegisterEventSource(s, syscall.UTF16PtrFromString(source))
srcPtr, err := syscall.UTF16PtrFromString(source)
if err != nil {
return h, err
}
h, err = windows.RegisterEventSource(s, srcPtr)
return h, err
}

Expand All @@ -46,7 +53,11 @@ func (w *Writer) Close() error {
}

func (w *Writer) Write(p []byte) (n int, err error) {
ss := []*uint16{syscall.UTF16PtrFromString(string(p))}
ptr, err := syscall.UTF16PtrFromString(string(p))
if err != nil {
0, return err

Check failure on line 58 in pkg/log/eventlog/writer_windows.go

View workflow job for this annotation

GitHub Actions / launcher (windows-latest)

expected 1 expression

Check failure on line 58 in pkg/log/eventlog/writer_windows.go

View workflow job for this annotation

GitHub Actions / launcher (windows-latest)

expected ';', found 'return'

Check failure on line 58 in pkg/log/eventlog/writer_windows.go

View workflow job for this annotation

GitHub Actions / launcher (windows-latest)

expected operand, found 'return'

Check failure on line 58 in pkg/log/eventlog/writer_windows.go

View workflow job for this annotation

GitHub Actions / launcher (windows-latest)

0 (untyped int constant) is not used

Check failure on line 58 in pkg/log/eventlog/writer_windows.go

View workflow job for this annotation

GitHub Actions / launcher (windows-latest)

not enough return values
}
ss := []*uint16{ptr}
// always report as Info. Launcher logs as either info or debug, but the event log does not
// appear to have a debug level.
err = windows.ReportEvent(w.handle, windows.EVENTLOG_INFORMATION_TYPE, 0, 1, 0, 1, 0, &ss[0], nil)
Expand Down

0 comments on commit fd3a9b2

Please sign in to comment.