wxgtk30: fix format strings for printing kevent data

WxWidgets can watch for filesystem changes via kevent(2). To aid debugging,
incoming events are passed to a logging function (log level TRACE, which
will be discarded unless explicitely enabled). The format strings used
here did not match FreeBSD's struct kevent, and this mismatch triggered
an assertion inside wx. (The assertion message was
  ./include/wx/strvararg.h(456): assert
    "(argtype & (wxFormatStringSpecifier<T>::value)) == argtype" failed
    in wxArgNormalizer(): format specifier doesn't match argument type
for your search engine's reference). (Observed e.g. in cad/kicad when
(auto-)saving a project, where the assertion failure was passed as an
error dialog to the GUI - having this pop up when saving your work does
not instill confidence).
This patch uses the format specifiers from inttypes.h and accounts for
the changes to struct kevent between FreeBSD 11 and 12.
NB: wxgtk31 has similar code in the same place, with some improvements,
but IMO the fix is incomplete (it doesn't account for 11 vs 12). Maintainer
will be notified.
This commit is contained in:
Christoph Moench-Tegeder 2019-03-09 21:00:40 +00:00
parent 698ee5b4d0
commit 4f0e6046ce
Notes: svn2git 2021-03-31 03:12:20 +00:00
svn path=/head/; revision=495200
2 changed files with 29 additions and 1 deletions

View file

@ -3,7 +3,7 @@
PORTNAME= wx
PORTVERSION= 3.0.4
DISTVERSIONPREFIX= v
PORTREVISION= 6
PORTREVISION= 7
CATEGORIES= x11-toolkits
PKGNAMESUFFIX= 30-gtk3

View file

@ -0,0 +1,28 @@
--- src/unix/fswatcher_kqueue.cpp.orig 2018-03-07 17:21:58 UTC
+++ src/unix/fswatcher_kqueue.cpp
@@ -20,8 +20,10 @@
#ifdef wxHAS_KQUEUE
+#include <inttypes.h>
#include <sys/types.h>
#include <sys/event.h>
+#include <sys/param.h>
#include "wx/dynarray.h"
#include "wx/evtloop.h"
@@ -279,8 +281,12 @@ class wxFSWatcherImplKqueue : public wxFSWatcherImpl (
{
wxASSERT_MSG(e.udata, "Null user data associated with kevent!");
- wxLogTrace(wxTRACE_FSWATCHER, "Event: ident=%d, filter=%d, flags=%u, "
- "fflags=%u, data=%d, user_data=%p",
+ wxLogTrace(wxTRACE_FSWATCHER, "Event: ident=%" PRIuPTR ", filter=%hd, flags=%hu, "
+#if __FreeBSD_version >= 1200033
+ "fflags=%u, data=%" PRId64 ", user_data=%p",
+#else
+ "fflags=%u, data=%" PRIdPTR ", user_data=%p",
+#endif
e.ident, e.filter, e.flags, e.fflags, e.data, e.udata);
// for ease of use