Description: Fix GCC8 warnings
Origin: backport, https://github.com/java-native-access/jna/pull/999/commits/d956532f803c237a3d82396f5879e550f55d0fef
Bug: https://github.com/java-native-access/jna/issues/996
diff --git a/native/dispatch.c b/native/dispatch.c
index a09bac6da..6ea1a6b81 100644
--- a/native/dispatch.c
+++ b/native/dispatch.c
@@ -652,7 +652,7 @@ dispatch(JNIEnv *env, void* func, jint flags, jobjectArray args,
       int err = GET_LAST_ERROR();
       JNA_set_last_error(env, err);
       if ((flags & THROW_LAST_ERROR) && err) {
-        char emsg[MSG_SIZE];
+        char emsg[MSG_SIZE - 3 /* literal characters */ - 10 /* max length of %d */];
         snprintf(msg, sizeof(msg), "[%d] %s", err, STR_ERROR(err, emsg, sizeof(emsg)));
         throw_type = ELastError;
         throw_msg = msg;
@@ -1891,7 +1891,7 @@ dispatch_direct(ffi_cif* cif, void* volatile resp, void** argp, void *cdata) {
       int err = GET_LAST_ERROR();
       JNA_set_last_error(env, err);
       if (data->throw_last_error && err) {
-        char emsg[MSG_SIZE];
+        char emsg[MSG_SIZE - 3 /* literal characters */ - 10 /* max length of %d */];
         snprintf(msg, sizeof(msg), "[%d] %s", err, STR_ERROR(err, emsg, sizeof(emsg)));
         throw_type = ELastError;
         throw_msg = msg;
@@ -3086,7 +3086,7 @@ Java_com_sun_jna_Native_getWindowHandle0(JNIEnv* UNUSED_JAWT(env), jclass UNUSED
       return -1;
     }
     if ((pJAWT_GetAWT = (void*)FIND_ENTRY(jawt_handle, METHOD_NAME)) == NULL) {
-      char msg[MSG_SIZE], buf[MSG_SIZE];
+      char msg[MSG_SIZE], buf[MSG_SIZE - 31 /* literal characters */ - sizeof(METHOD_NAME)];
       snprintf(msg, sizeof(msg), "Error looking up JAWT method %s: %s",
                METHOD_NAME, LOAD_ERROR(buf, sizeof(buf)));
       throwByName(env, EUnsatisfiedLink, msg);
diff --git a/native/testlib.c b/native/testlib.c
index 575cf010a..609ed75ed 100644
--- a/native/testlib.c
+++ b/native/testlib.c
@@ -805,7 +805,7 @@ callCallbackWithStructByValue(TestStructureByValue (*func)(TestStructureByValue)
 
 EXPORT callback_t
 callCallbackWithCallback(cb_callback_t cb) {
-  return (*cb)((callback_t)cb);
+  return (*cb)((callback_t)(void*)cb);
 }
 
 static int32_t 
