Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Warning and Note issued on Linux #213

Closed
wdevore opened this issue Jan 19, 2018 · 10 comments
Closed

Warning and Note issued on Linux #213

wdevore opened this issue Jan 19, 2018 · 10 comments
Labels

Comments

@wdevore
Copy link

wdevore commented Jan 19, 2018

Fyi,
go-gl built fine except a warning and note appeared, so I thought I would post it here:

go get -u github.com/go-gl/glfw/v3.2/glfw

_# github.com/go-gl/glfw/v3.2/glfw
In file included from src/github.com/go-gl/glfw/v3.2/glfw/c_glfw_linbsd.go:22:0:
src/github.com/go-gl/glfw/v3.2/glfw/glfw/src/linux_joystick.c: In function ‘_glfwInitJoysticksLinux’:
src/github.com/go-gl/glfw/v3.2/glfw/glfw/src/linux_joystick.c:224:42: warning: ‘%s’ directive output may be truncated writing up to 255 bytes into a region of size 9 [-Wformat-truncation=]

snprintf(path, sizeof(path), "%s/%s", dirname, entry->d_name);
                                                       ^~~~~~~

In file included from /usr/include/stdio.h:862:0,
from /usr/include/X11/Xcursor/Xcursor.h:26,
from src/github.com/go-gl/glfw/v3.2/glfw/glfw/src/x11_platform.h:39,
from src/github.com/go-gl/glfw/v3.2/glfw/glfw/src/internal.h:169,
from src/github.com/go-gl/glfw/v3.2/glfw/glfw/src/x11_init.c:28,
from src/github.com/go-gl/glfw/v3.2/glfw/c_glfw_linbsd.go:17:
/usr/include/x86_64-linux-gnu/bits/stdio2.h:64:10: note: ‘__builtin___snprintf_chk’ output between 12 and 267 bytes into a destination of size 20
return __builtin___snprintf_chk (__s, __n, __USE_FORTIFY_LEVEL - 1,
              ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
              __bos (__s), __fmt, __va_arg_pack ());
              ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

my go environment

GOARCH="amd64"
GOBIN=""
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/home/xxx/Documents/Development/Go"
GORACE=""
GOROOT="/usr/local/bin/go"
GOTOOLDIR="/usr/local/bin/go/pkg/tool/linux_amd64"
GCCGO="gccgo"
CC="gcc"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build583228998=/tmp/go-build -gno-record-gcc-switches"
CXX="/usr/bin/clang++3.9"
CGO_ENABLED="1"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"

@elmindreda
Copy link

This has since been fixed with glfw/glfw@5bcf9c7.

@dmitshur
Copy link
Member

Thank you for confirming that @elmindreda.

We are already using the latest GLFW 3.2.1 version here. When the next version of GLFW containing the fix is released, we’ll update, and the warnings will disappear. They can be ignored until then.

So, there’s nothing to do in go-gl/glfw at this time.

@dmitshur
Copy link
Member

Reopening for visibility (see #222 (comment)). /cc @capnm

Nothing to do here other than to eventually update to the next version of GLFW.

@dmitshur dmitshur reopened this Aug 21, 2018
@capnm
Copy link

capnm commented Aug 30, 2018

In go are the warnings very visible ;-)
I tried to locally cherry-pick the change but asprint is a GNU extension, maybe someone has a better idea?

diff --git a/go.mod b/go.mod
new file mode 100644
index 0000000..3e94336
--- /dev/null
+++ b/go.mod
@@ -0,0 +1 @@
+module github.com/go-gl/glfw
diff --git a/v3.2/glfw/glfw/src/linux_joystick.c b/v3.2/glfw/glfw/src/linux_joystick.c
index 561b1eb..53ffb1a 100644
--- a/v3.2/glfw/glfw/src/linux_joystick.c
+++ b/v3.2/glfw/glfw/src/linux_joystick.c
@@ -215,15 +215,24 @@ GLFWbool _glfwInitJoysticksLinux(void)
 
         while ((entry = readdir(dir)))
         {
-            char path[20];
             regmatch_t match;
+            char* path = NULL;
 
             if (regexec(&_glfw.linux_js.regex, entry->d_name, 1, &match, 0) != 0)
                 continue;
+#pragma GCC diagnostic ignored "-Wimplicit-function-declaration"
+            if (asprintf(&path, "%s/%s", dirname, entry->d_name) < 0)
+            {
+                _glfwInputError(GLFW_PLATFORM_ERROR,
+                                "Linux: Failed to construct device path: %s",
+                                strerror(errno));
+                continue;
+            }
 
-            snprintf(path, sizeof(path), "%s/%s", dirname, entry->d_name);
             if (openJoystickDevice(path))
                 count++;
+
+           free(path);
         }
 
         closedir(dir);

go.mod:

replace github.com/go-gl/glfw => ../glfw-wip

@tapir
Copy link
Member

tapir commented Aug 30, 2018

please see 3.3 branch, this should be fixed there

@capnm
Copy link

capnm commented Aug 30, 2018

please see 3.3 branch, this should be fixed there

Unfortunately, the version from the v2 directory is pulled into my project by 3rd party packages and is still the same in the 3.3 branch :-(

glfw-wip = 845371b

go build
# github.com/go-gl/glfw/v3.2/glfw
In file included from ../../glfw-wip/v3.2/glfw/c_glfw_linbsd.go:24:0:
../../glfw-wip/v3.2/glfw/glfw/src/linux_joystick.c: In function ‘_glfwInitJoysticksLinux’:
../../glfw-wip/v3.2/glfw/glfw/src/linux_joystick.c:224:42: warning: ‘%s’ directive output may be truncated writing up to 255 bytes into a region of size 9 [-Wformat-truncation=]
             snprintf(path, sizeof(path), "%s/%s", dirname, entry->d_name);
                                          ^~~~~~~
In file included from /usr/include/stdio.h:862:0,
                 from /usr/include/X11/Xcursor/Xcursor.h:26,
                 from ../../glfw-wip/v3.2/glfw/glfw/src/x11_platform.h:39,
                 from ../../glfw-wip/v3.2/glfw/glfw/src/internal.h:169,
                 from ../../glfw-wip/v3.2/glfw/glfw/src/x11_init.c:28,
                 from ../../glfw-wip/v3.2/glfw/c_glfw_linbsd.go:19:
/usr/include/x86_64-linux-gnu/bits/stdio2.h:64:10: note: ‘__builtin___snprintf_chk’ output between 12 and 267 bytes into a destination of size 20
   return __builtin___snprintf_chk (__s, __n, __USE_FORTIFY_LEVEL - 1,
          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        __bos (__s), __fmt, __va_arg_pack ());
        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

@capnm
Copy link

capnm commented Aug 30, 2018

Ah build.go was missing -D_GNU_SOURCE.
For anyone interested this patch fixes the issue in v3.2:
glfw-issue.patch.txt

@alexniver
Copy link

share a way to fix this warning.

  1. find your local file v3.2/glfw/glfw/src/linux_joystick.c , open it

  2. change char path[20]; to char path[512];

  3. then go get -u github.com/go-gl/glfw/v3.2/glfw

after that, I got no warning anymore

@rootVIII
Copy link

rootVIII commented Oct 18, 2019

I can't tell if this has been fixed or not... but 18.04 Ubuntu as of 18OCT2019:
EDIT: Same thing on Kali Rolling 2019.3

james@rootVIII:~/Desktop$ go run test.go 
# fyne.io/fyne/vendor/github.com/go-gl/glfw/v3.2/glfw
In file included from ../go/src/fyne.io/fyne/vendor/github.com/go-gl/glfw/v3.2/glfw/c_glfw_linbsd.go:24:0:
../go/src/fyne.io/fyne/vendor/github.com/go-gl/glfw/v3.2/glfw/glfw/src/linux_joystick.c: In function ‘_glfwInitJoysticksLinux’:
../go/src/fyne.io/fyne/vendor/github.com/go-gl/glfw/v3.2/glfw/glfw/src/linux_joystick.c:224:42: warning: ‘%s’ directive output may be truncated writing up to 255 bytes into a region of size 9 [-Wformat-truncation=]
             snprintf(path, sizeof(path), "%s/%s", dirname, entry->d_name);
                                          ^~~~~~~
In file included from /usr/include/stdio.h:862:0,
                 from /usr/include/X11/Xcursor/Xcursor.h:26,
                 from ../go/src/fyne.io/fyne/vendor/github.com/go-gl/glfw/v3.2/glfw/glfw/src/x11_platform.h:39,
                 from ../go/src/fyne.io/fyne/vendor/github.com/go-gl/glfw/v3.2/glfw/glfw/src/internal.h:169,
                 from ../go/src/fyne.io/fyne/vendor/github.com/go-gl/glfw/v3.2/glfw/glfw/src/x11_init.c:28,
                 from ../go/src/fyne.io/fyne/vendor/github.com/go-gl/glfw/v3.2/glfw/c_glfw_linbsd.go:19:
/usr/include/x86_64-linux-gnu/bits/stdio2.h:64:10: note: ‘__builtin___snprintf_chk’ output between 12 and 267 bytes into a destination of size 20
   return __builtin___snprintf_chk (__s, __n, __USE_FORTIFY_LEVEL - 1,
          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        __bos (__s), __fmt, __va_arg_pack ());
        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
^C

@pwaller
Copy link
Member

pwaller commented Nov 24, 2019

Hi Everyone, Sorry about the annoying warning, which came from the underlying glfw sources. Please upgrade to v3.3 (merged today in #256), and if you encounter any errors there, let's get them fixed!

@pwaller pwaller closed this as completed Nov 24, 2019
MattMulhern added a commit to chafgames/chaos-monkey that referenced this issue Feb 3, 2020
stopping it for now as I can't figure out how to disable the C
compiler strict error checking.

once a newer version go go-gl is released with latest glfw (see
go-gl/glfw#213) we can give it another go.

Signed-off-by: Matt Mulhern <mattmulhern01@gmail.com>
cullenr pushed a commit to cullenr/yanhg that referenced this issue Feb 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

8 participants