ebiten icon indicating copy to clipboard operation
ebiten copied to clipboard

go vet fails on Windows

Open hajimehoshi opened this issue 3 years ago • 6 comments

From https://github.com/hajimehoshi/ebiten/runs/990798566:

internal\glfw\glfw_windows.go:90:23: possible misuse of unsafe.Pointer
internal\glfw\glfw_windows.go:335:17: possible misuse of unsafe.Pointer
internal\glfw\glfw_windows.go:352:17: possible misuse of unsafe.Pointer
internal\glfw\glfw_windows.go:369:23: possible misuse of unsafe.Pointer
internal\glfw\glfw_windows.go:381:20: possible misuse of unsafe.Pointer
internal\glfw\glfw_windows.go:393:27: possible misuse of unsafe.Pointer
internal\glfw\glfw_windows.go:397:24: possible misuse of unsafe.Pointer
internal\glfw\native_windows.go:24:9: possible misuse of unsafe.Pointer

hajimehoshi avatar Aug 16 '20 16:08 hajimehoshi

See also #889

hajimehoshi avatar Aug 16 '20 17:08 hajimehoshi

https://github.com/golang/go/issues/41205

Looks like it is hard or impossible to remove go-vet warnings? 🤔

hajimehoshi avatar Sep 03 '20 16:09 hajimehoshi

# github.com/hajimehoshi/ebiten/v2/internal/glfwwin
internal\glfwwin\api_windows.go:1901:41: possible misuse of unsafe.Pointer
internal\glfwwin\api_windows.go:1910:41: possible misuse of unsafe.Pointer
internal\glfwwin\context_windows.go:275:24: possible misuse of unsafe.Pointer
internal\glfwwin\context_windows.go:293:45: possible misuse of unsafe.Pointer
internal\glfwwin\context_windows.go:480:24: possible misuse of unsafe.Pointer
internal\glfwwin\context_windows.go:510:19: possible misuse of unsafe.Pointer
internal\glfwwin\context_windows.go:537:22: possible misuse of unsafe.Pointer
internal\glfwwin\context_windows.go:562:22: possible misuse of unsafe.Pointer
internal\glfwwin\context_windows.go:581:42: possible misuse of unsafe.Pointer
internal\glfwwin\context_windows.go:595:49: possible misuse of unsafe.Pointer
internal\glfwwin\context_windows.go:616:22: possible misuse of unsafe.Pointer
internal\glfwwin\context_windows.go:621:9: possible misuse of unsafe.Pointer
internal\glfwwin\wglcontext_windows.go:279:22: possible misuse of unsafe.Pointer
internal\glfwwin\win32monitor_windows.go:35:25: possible misuse of unsafe.Pointer
internal\glfwwin\win32window_windows.go:583:22: possible misuse of unsafe.Pointer
internal\glfwwin\win32window_windows.go:590:29: possible misuse of unsafe.Pointer
internal\glfwwin\win32window_windows.go:1030:59: possible misuse of unsafe.Pointer
internal\glfwwin\win32window_windows.go:1038:25: possible misuse of unsafe.Pointer
internal\glfwwin\win32window_windows.go:1106:21: possible misuse of unsafe.Pointer
internal\glfwwin\win32window_windows.go:1129:26: possible misuse of unsafe.Pointer
internal\glfwwin\win32window_windows.go:1996:26: possible misuse of unsafe.Pointer

hajimehoshi avatar May 22 '22 13:05 hajimehoshi

https://github.com/golang/go/issues/58625 will resolve this issue.

hajimehoshi avatar Jul 22 '23 17:07 hajimehoshi

If the above feature is available in Go 1.22, we would be able to use this in 3 or 4 years later. I'll set the milesone as v3 for now and let's adjust this when we change the minimum Go version we support.

hajimehoshi avatar Jul 22 '23 17:07 hajimehoshi

Would this be a valid workaround?

Now:

func wglGetExtensionsStringARB(hdc _HDC) string {
	r, _, _ := syscall.Syscall(procWGLGetExtensionsStringARB, 1, uintptr(hdc), 0, 0)
	return windows.BytePtrToString((*byte)(unsafe.Pointer(r)))
}

Workaround:

func wglGetExtensionsStringARB(hdc _HDC) string {
	r, _, _ := syscall.Syscall(procWGLGetExtensionsStringARB, 1, uintptr(hdc), 0, 0)
	return windows.BytePtrToString(*(**byte)(unsafe.Pointer(&r)))
}

JupiterRider avatar May 11 '24 17:05 JupiterRider