From e919f6811f7933b120f783e5003727c91dae467f Mon Sep 17 00:00:00 2001 From: Michael Yang Date: Wed, 22 May 2024 09:26:45 -0700 Subject: [PATCH] lint windows --- app/lifecycle/server_windows.go | 6 ++++-- app/tray/wintray/eventloop.go | 5 ++--- app/tray/wintray/tray.go | 10 +++------- gpu/amd_windows.go | 2 +- 4 files changed, 10 insertions(+), 13 deletions(-) diff --git a/app/lifecycle/server_windows.go b/app/lifecycle/server_windows.go index cd4244ff..5f9fe124 100644 --- a/app/lifecycle/server_windows.go +++ b/app/lifecycle/server_windows.go @@ -24,7 +24,8 @@ func terminate(cmd *exec.Cmd) error { if err != nil { return err } - defer dll.Release() // nolint: errcheck + //nolint:errcheck + defer dll.Release() pid := cmd.Process.Pid @@ -73,7 +74,8 @@ func isProcessExited(pid int) (bool, error) { if err != nil { return false, fmt.Errorf("failed to open process: %v", err) } - defer windows.CloseHandle(hProcess) // nolint: errcheck + //nolint:errcheck + defer windows.CloseHandle(hProcess) var exitCode uint32 err = windows.GetExitCodeProcess(hProcess, &exitCode) diff --git a/app/tray/wintray/eventloop.go b/app/tray/wintray/eventloop.go index a0af9787..0f944894 100644 --- a/app/tray/wintray/eventloop.go +++ b/app/tray/wintray/eventloop.go @@ -47,7 +47,6 @@ func nativeLoop() { default: pTranslateMessage.Call(uintptr(unsafe.Pointer(m))) //nolint:errcheck pDispatchMessage.Call(uintptr(unsafe.Pointer(m))) //nolint:errcheck - } } } @@ -160,8 +159,8 @@ func (t *winTray) wndProc(hWnd windows.Handle, message uint32, wParam, lParam ui lResult, _, _ = pDefWindowProc.Call( uintptr(hWnd), uintptr(message), - uintptr(wParam), - uintptr(lParam), + wParam, + lParam, ) } return diff --git a/app/tray/wintray/tray.go b/app/tray/wintray/tray.go index 69d4487d..027ec5a5 100644 --- a/app/tray/wintray/tray.go +++ b/app/tray/wintray/tray.go @@ -186,7 +186,7 @@ func (t *winTray) initInstance() error { t.muNID.Lock() defer t.muNID.Unlock() t.nid = ¬ifyIconData{ - Wnd: windows.Handle(t.window), + Wnd: t.window, ID: 100, Flags: NIF_MESSAGE, CallbackMessage: t.wmSystrayMessage, @@ -197,7 +197,6 @@ func (t *winTray) initInstance() error { } func (t *winTray) createMenu() error { - menuHandle, _, err := pCreatePopupMenu.Call() if menuHandle == 0 { return err @@ -246,7 +245,7 @@ func (t *winTray) addOrUpdateMenuItem(menuItemId uint32, parentId uint32, title mi := menuItemInfo{ Mask: MIIM_FTYPE | MIIM_STRING | MIIM_ID | MIIM_STATE, Type: MFT_STRING, - ID: uint32(menuItemId), + ID: menuItemId, TypeData: titlePtr, Cch: uint32(len(title)), } @@ -302,11 +301,10 @@ func (t *winTray) addOrUpdateMenuItem(menuItemId uint32, parentId uint32, title } func (t *winTray) addSeparatorMenuItem(menuItemId, parentId uint32) error { - mi := menuItemInfo{ Mask: MIIM_FTYPE | MIIM_ID | MIIM_STATE, Type: MFT_SEPARATOR, - ID: uint32(menuItemId), + ID: menuItemId, } mi.Size = uint32(unsafe.Sizeof(mi)) @@ -426,7 +424,6 @@ func iconBytesToFilePath(iconBytes []byte) (string, error) { // Loads an image from file and shows it in tray. // Shell_NotifyIcon: https://msdn.microsoft.com/en-us/library/windows/desktop/bb762159(v=vs.85).aspx func (t *winTray) setIcon(src string) error { - h, err := t.loadIconFrom(src) if err != nil { return err @@ -444,7 +441,6 @@ func (t *winTray) setIcon(src string) error { // Loads an image from file to be shown in tray or menu item. // LoadImage: https://msdn.microsoft.com/en-us/library/windows/desktop/ms648045(v=vs.85).aspx func (t *winTray) loadIconFrom(src string) (windows.Handle, error) { - // Save and reuse handles of loaded images t.muLoadedImages.RLock() h, ok := t.loadedImages[src] diff --git a/gpu/amd_windows.go b/gpu/amd_windows.go index aae6c5b7..987b543b 100644 --- a/gpu/amd_windows.go +++ b/gpu/amd_windows.go @@ -65,7 +65,7 @@ func AMDGetGPUInfo() []GpuInfo { slog.Debug("detected hip devices", "count", count) // TODO how to determine the underlying device ID when visible devices is causing this to subset? - for i := 0; i < count; i++ { + for i := range count { err = hl.HipSetDevice(i) if err != nil { slog.Warn("set device", "id", i, "error", err)