fix some gcc-reported warnings

This commit is contained in:
Mis012
2024-04-19 23:18:17 +02:00
parent 21627aecad
commit 98d17ac25e
7 changed files with 50 additions and 44 deletions

View File

@@ -364,7 +364,7 @@ void Java_android_app_NativeActivity_unloadNativeCode(JNIEnv* env, jobject clazz
{
printf("STUB - unloadNativeCode_native\n");
/*if (handle != 0) {
struct NativeCode* code = (struct NativeCode*)handle;
struct NativeCode* code = (struct NativeCode*)_PTR(handle);
NativeCode_destroy(code);
}*/
}
@@ -372,7 +372,7 @@ void Java_android_app_NativeActivity_unloadNativeCode(JNIEnv* env, jobject clazz
void Java_android_app_NativeActivity_onStartNative(JNIEnv* env, jobject clazz, jlong handle)
{
if (handle != 0) {
struct NativeCode* code = (struct NativeCode*)handle;
struct NativeCode* code = (struct NativeCode*)_PTR(handle);
if (code->callbacks.onStart != NULL) {
code->callbacks.onStart((ANativeActivity *)code);
}
@@ -382,7 +382,7 @@ void Java_android_app_NativeActivity_onStartNative(JNIEnv* env, jobject clazz, j
void Java_android_app_NativeActivity_onResumeNative(JNIEnv* env, jobject clazz, jlong handle)
{
if (handle != 0) {
struct NativeCode* code = (struct NativeCode*)handle;
struct NativeCode* code = (struct NativeCode*)_PTR(handle);
if (code->callbacks.onResume != NULL) {
code->callbacks.onResume((ANativeActivity *)code);
}
@@ -396,7 +396,7 @@ jbyteArray Java_android_app_NativeActivity_onSaveInstanceStateNative(JNIEnv* env
jbyteArray array = NULL;
if (handle != 0) {
struct NativeCode* code = (struct NativeCode*)handle;
struct NativeCode* code = (struct NativeCode*)_PTR(handle);
if (code->callbacks.onSaveInstanceState != NULL) {
size_t len = 0;
jbyte* state = (jbyte*)code->callbacks.onSaveInstanceState((ANativeActivity *)code, &len);
@@ -418,7 +418,7 @@ jbyteArray Java_android_app_NativeActivity_onSaveInstanceStateNative(JNIEnv* env
void Java_android_app_NativeActivity_onPauseNative(JNIEnv* env, jobject clazz, jlong handle)
{
if (handle != 0) {
struct NativeCode* code = (struct NativeCode*)handle;
struct NativeCode* code = (struct NativeCode*)_PTR(handle);
if (code->callbacks.onPause != NULL) {
code->callbacks.onPause((ANativeActivity *)code);
}
@@ -428,7 +428,7 @@ void Java_android_app_NativeActivity_onPauseNative(JNIEnv* env, jobject clazz, j
void Java_android_app_NativeActivity_onStopNative(JNIEnv* env, jobject clazz, jlong handle)
{
if (handle != 0) {
struct NativeCode* code = (struct NativeCode*)handle;
struct NativeCode* code = (struct NativeCode*)_PTR(handle);
if (code->callbacks.onStop != NULL) {
code->callbacks.onStop((ANativeActivity *)code);
}
@@ -439,7 +439,7 @@ void Java_android_app_NativeActivity_onConfigurationChangedNative(JNIEnv* env, j
{
printf("STUB - onConfigurationChanged_native\n");
/* if (handle != 0) {
struct NativeCode* code = (struct NativeCode*)handle;
struct NativeCode* code = (struct NativeCode*)_PTR(handle);
if (code->callbacks.onConfigurationChanged != NULL) {
code->callbacks.onConfigurationChanged((ANativeActivity *)code);
}
@@ -450,7 +450,7 @@ void Java_android_app_NativeActivity_onLowMemoryNative(JNIEnv* env, jobject claz
{
printf("STUB - onLowMemory_native\n");
/* if (handle != 0) {
struct NativeCode* code = (struct NativeCode*)handle;
struct NativeCode* code = (struct NativeCode*)_PTR(handle);
if (code->callbacks.onLowMemory != NULL) {
code->callbacks.onLowMemory((ANativeActivity *)code);
}
@@ -460,7 +460,7 @@ void Java_android_app_NativeActivity_onLowMemoryNative(JNIEnv* env, jobject claz
void Java_android_app_NativeActivity_onWindowFocusChangedNative(JNIEnv* env, jobject clazz, jlong handle, jboolean focused)
{
if (handle != 0) {
struct NativeCode* code = (struct NativeCode*)handle;
struct NativeCode* code = (struct NativeCode*)_PTR(handle);
if (code->callbacks.onWindowFocusChanged != NULL) {
code->callbacks.onWindowFocusChanged((ANativeActivity *)code, focused ? 1 : 0);
}
@@ -471,7 +471,7 @@ void Java_android_app_NativeActivity_onSurfaceCreatedNative(JNIEnv* env, jobject
{
printf("STUB - onSurfaceCreated_native\n");
/* if (handle != 0) {
struct NativeCode* code = (struct NativeCode*)handle;
struct NativeCode* code = (struct NativeCode*)_PTR(handle);
code->setSurface(surface);
if (code->nativeWindow != NULL && code->callbacks.onNativeWindowCreated != NULL) {
code->callbacks.onNativeWindowCreated((ANativeActivity *)code, code->nativeWindow.get());
@@ -483,7 +483,7 @@ void Java_android_app_NativeActivity_onSurfaceChangedNative(JNIEnv* env, jobject
jint format, jint width, jint height)
{
if (handle != 0) {
struct NativeCode *code = (struct NativeCode *)handle;
struct NativeCode *code = (struct NativeCode*)_PTR(handle);
ANativeWindow *oldNativeWindow = code->nativeWindow;
NativeCode_setSurface(code, surface);
if (oldNativeWindow != code->nativeWindow) {
@@ -514,7 +514,7 @@ void Java_android_app_NativeActivity_onSurfaceRedrawNeededNative(JNIEnv* env, jo
{
printf("STUB - onSurfaceRedrawNeeded_native\n");
/* if (handle != 0) {
struct NativeCode* code = (struct NativeCode*)handle;
struct NativeCode* code = (struct NativeCode*)_PTR(handle);
if (code->nativeWindow != NULL && code->callbacks.onNativeWindowRedrawNeeded != NULL) {
code->callbacks.onNativeWindowRedrawNeeded((ANativeActivity *)code, code->nativeWindow.get());
}
@@ -525,7 +525,7 @@ void Java_android_app_NativeActivity_onSurfaceDestroyedNative(JNIEnv* env, jobje
{
printf("STUB - onSurfaceDestroyed_native\n");
/* if (handle != 0) {
struct NativeCode* code = (struct NativeCode*)handle;
struct NativeCode* code = (struct NativeCode*)_PTR(handle);
if (code->nativeWindow != NULL && code->callbacks.onNativeWindowDestroyed != NULL) {
code->callbacks.onNativeWindowDestroyed(code,
code->nativeWindow.get());
@@ -538,9 +538,9 @@ void Java_android_app_NativeActivity_onInputQueueCreatedNative(JNIEnv* env, jobj
{
printf("STUB - onInputChannelCreated_native\n");
if (handle != 0) {
struct NativeCode* code = (struct NativeCode*)handle;
struct NativeCode* code = (struct NativeCode*)_PTR(handle);
if (code->callbacks.onInputQueueCreated != NULL) {
code->callbacks.onInputQueueCreated((ANativeActivity *)code, (AInputQueue *)queue);
code->callbacks.onInputQueueCreated((ANativeActivity *)code, (AInputQueue *)_PTR(queue));
}
}
}
@@ -549,7 +549,7 @@ void Java_android_app_NativeActivity_onInputQueueDestroyedNative(JNIEnv* env, jo
{
printf("STUB - onInputChannelDestroyed_native\n");
/* if (handle != 0) {
struct NativeCode* code = (struct NativeCode*)handle;
struct NativeCode* code = (struct NativeCode*)_PTR(handle);
if (code->callbacks.onInputQueueDestroyed != NULL) {
AInputQueue* queue = reinterpret_cast<AInputQueue*>(queuePtr);
code->callbacks.onInputQueueDestroyed((ANativeActivity *)code, queue);
@@ -562,7 +562,7 @@ void Java_android_app_NativeActivity_onContentRectChangedNative(JNIEnv* env, job
{
printf("STUB - onContentRectChanged_native\n");
/* if (handle != 0) {
struct NativeCode* code = (struct NativeCode*)handle;
struct NativeCode* code = (struct NativeCode*)_PTR(handle);
if (code->callbacks.onContentRectChanged != NULL) {
ARect rect;
rect.left = x;

View File

@@ -411,10 +411,9 @@ JNIEXPORT void JNICALL Java_android_content_res_AssetManager_setConfiguration(
JNIEXPORT jobjectArray JNICALL Java_android_content_res_AssetManager_list(JNIEnv *env, jobject this, jstring _path)
{
DIR *d;
int fd;
struct dirent *dir;
char* path_rel = _CSTRING(_path);
const char* path_rel = _CSTRING(_path);
char *app_data_dir = get_app_data_dir();
char *path_abs = malloc(strlen(app_data_dir) + strlen(ASSET_DIR) + strlen(path_rel) + 1);
@@ -423,7 +422,7 @@ JNIEXPORT jobjectArray JNICALL Java_android_content_res_AssetManager_list(JNIEnv
strcat(path_abs, path_rel);
d = opendir(path_abs);
GArray *assets = g_array_new(false, false, sizeof(const char *));
int i = 0;
if (d)
@@ -436,15 +435,15 @@ JNIEXPORT jobjectArray JNICALL Java_android_content_res_AssetManager_list(JNIEnv
}
closedir(d);
}
jobjectArray array = (*env)->NewObjectArray(env, assets->len, (*env)->FindClass(env, "java/lang/String"), NULL);
for (i = 0; i < assets->len; i++)
{
const char *asset = g_array_index(assets, const char *, i);
(*env)->SetObjectArrayElement(env, array, i, (*env)->NewString(env, asset, strlen(asset)));
(*env)->SetObjectArrayElement(env, array, i, (*env)->NewStringUTF(env, asset));
}
g_array_free(assets, TRUE);
return array;
}

View File

@@ -61,7 +61,7 @@ JNIEXPORT jboolean JNICALL Java_com_google_android_gles_1jni_EGLImpl_native_1egl
jint* num_config_base = get_int_array_crit(env, num_config);
ret = eglChooseConfig(_PTR(egl_display), attrib_base, egl_configs ? _PTR(configs_base) : NULL, config_size, num_config_base);
printf(".. eglChooseConfig: egl_display: %ld, egl_configs: %p, _PTR(configs_base): %p, config_size: %d, num_config_base[0]: %d\n", egl_display, egl_configs, _PTR(configs_base), config_size, num_config_base[0]);
printf(".. eglChooseConfig: egl_display: %w64x, egl_configs: %p, _PTR(configs_base): %p, config_size: %d, num_config_base[0]: %d\n", egl_display, egl_configs, _PTR(configs_base), config_size, num_config_base[0]);
release_int_array_crit(env, attrib_list, attrib_base);
release_long_array_crit(env, egl_configs, configs_base);

View File

@@ -5,6 +5,8 @@
#include <gtk/gtk.h>
#include "looper.h"
enum {
AINPUT_EVENT_TYPE_KEY = 1,
AINPUT_EVENT_TYPE_MOTION = 2,
@@ -162,7 +164,7 @@ struct AInputEvent fixme_ugly_current_event;
static inline void make_touch_event(GdkEvent* event, GtkEventControllerLegacy* event_controller, struct AInputEvent *ainput_event)
{
GtkWidget *window = gtk_event_controller_get_widget(event_controller);
GtkWidget *window = gtk_event_controller_get_widget(GTK_EVENT_CONTROLLER(event_controller));
GtkWidget *child;
gdk_event_get_position(event, &ainput_event->x, &ainput_event->y);
@@ -210,7 +212,12 @@ static gboolean on_event(GtkEventControllerLegacy* self, GdkEvent* event, int in
make_touch_event(event, self, &ainput_event);
write(input_queue_pipe_fd, &ainput_event, sizeof(struct AInputEvent));
break;
default:
return false;
break;
}
return true;
}
// FIXME put this in a header file
@@ -222,8 +229,9 @@ struct input_queue {
void AInputQueue_attachLooper(struct input_queue* queue, struct ALooper* looper, int ident, Looper_callbackFunc callback, void* data)
{
struct android_poll_source *poll_source = (struct android_poll_source *)data;
printf("AInputQueue_attachLooper called: queue: %p, looper: %p, ident: %d, callback %p, data: %p, process_func: %p\n", queue, looper, ident, callback, poll_source, poll_source->process);
//printf("AInputQueue_attachLooper called: queue: %p, looper: %p, ident: %d, callback %p, data: %p, process_func: %p\n", queue, looper, ident, callback, poll_source, poll_source ? poll_source->process : 0);
if (poll_source == NULL)
return;
int input_queue_pipe[2];
if (pipe(input_queue_pipe)) {
fprintf(stderr, "could not create pipe: %s", strerror(errno));
@@ -231,7 +239,7 @@ void AInputQueue_attachLooper(struct input_queue* queue, struct ALooper* looper,
}
fcntl(input_queue_pipe[0], F_SETFL, O_NONBLOCK);
ALooper_addFd(looper, input_queue_pipe[0], ident, (1 << 0)/*? ALOOPER_EVENT_INPUT*/, callback, data);
g_signal_connect(queue->controller, "event", G_CALLBACK(on_event), (gpointer)input_queue_pipe[1]);
g_signal_connect(queue->controller, "event", G_CALLBACK(on_event), GINT_TO_POINTER(input_queue_pipe[1]));
queue->fd = input_queue_pipe[0];
}
@@ -255,7 +263,7 @@ void AInputQueue_finishEvent(AInputQueue* queue, struct AInputEvent* event, int
// should we do something here?
}
void AKeyEvent_getKeyCode (struct AInputEvent *event)
int32_t AKeyEvent_getKeyCode(struct AInputEvent *event)
{
/*
* TODO: Minecraft PE misuses this function on an event

View File

@@ -4,8 +4,6 @@
#include "looper.h"
typedef int (*Looper_callbackFunc)(int fd, int events, void* data);
// dummy strong pointer class
struct sp {
ALooper *ptr;

View File

@@ -2,9 +2,12 @@
#define LOOPER_H
typedef void ALooper;
typedef int (*Looper_callbackFunc)(int fd, int events, void* data);
ALooper * ALooper_prepare(int opts);
void ALooper_wake(ALooper *looper);
bool ALooper_isPolling(ALooper *looper);
int ALooper_pollOnce(int timeoutMillis, int* outFd, int* outEvents, void** outData);
int ALooper_addFd(ALooper* looper, int fd, int ident, int events, Looper_callbackFunc callback, void* data);
#endif

View File

@@ -578,7 +578,7 @@ struct XrGraphicsBindingOpenGLESAndroidKHR {
XrResult bionic_xrCreateSession(XrInstance instance, XrSessionCreateInfo *createInfo, XrSession *session)
{
struct XrGraphicsBindingOpenGLESAndroidKHR *android_bind = createInfo->next;
struct XrGraphicsBindingOpenGLESAndroidKHR *android_bind = (struct XrGraphicsBindingOpenGLESAndroidKHR *)createInfo->next;
XrGraphicsBindingEGLMNDX egl_bind = {XR_TYPE_GRAPHICS_BINDING_EGL_MNDX};
if (android_bind->type == XR_TYPE_GRAPHICS_BINDING_OPENGL_ES_ANDROID_KHR) {
@@ -602,7 +602,7 @@ XrResult bionic_xrGetInstanceProperties(XrInstance instance, XrInstancePropertie
XrResult ret = xr_lazy_call("xrGetInstanceProperties", instance, instanceProperties);
strncat(instanceProperties->runtimeName, " (With ATL meta-layer)",
XR_MAX_RUNTIME_NAME_SIZE - 1 - strlen(instanceProperties->runtimeName));
XR_MAX_RUNTIME_NAME_SIZE - 1 - strlen(instanceProperties->runtimeName));
return ret;
}
@@ -620,11 +620,10 @@ XrResult bionic_xrCreateInstance(XrInstanceCreateInfo *createInfo, XrInstance *i
"XR_EXT_local_floor",
};
char **old_names = createInfo->enabledExtensionNames, **new_names;
const char * const*old_names = createInfo->enabledExtensionNames;
const char **new_names;
int new_count = createInfo->enabledExtensionCount + ARRRAY_SIZE(extra_exts);
printf("eee xrCreateInstance\n");
//FIXME: Leak?
new_names = malloc(sizeof(*new_names) * new_count);
memcpy(new_names, old_names, createInfo->enabledExtensionCount * sizeof(*old_names));
@@ -647,12 +646,9 @@ XrResult bionic_xrCreateInstance(XrInstanceCreateInfo *createInfo, XrInstance *i
return xr_lazy_call("xrCreateInstance", createInfo, instance);
}
XrResult bionic_xrCreateReferenceSpace(
XrSession session,
const XrReferenceSpaceCreateInfo* createInfo,
XrSpace* space)
XrResult bionic_xrCreateReferenceSpace(XrSession session, const XrReferenceSpaceCreateInfo *createInfo, XrSpace *space)
{
fprintf(stderr, "xrCreateReferenceSpace(s=0x%x, info={rs_type=%d})\n", session, createInfo->referenceSpaceType);
fprintf(stderr, "xrCreateReferenceSpace(s=0x%w64x, info={rs_type=%d})\n", (uint64_t)session, createInfo->referenceSpaceType);
//FIXME: this is sad for oculus refspace extension it assumes we have...
if (createInfo->referenceSpaceType > 100)
@@ -684,7 +680,7 @@ struct xr_proc_override {
PFN_xrVoidFunction *func;
};
#define XR_PROC_BIONIC(name) {#name, bionic_ ## name }
#define XR_PROC_BIONIC(name) {#name, (void (**)(void))bionic_ ## name }
/* Please keep the alphabetical order */
static const struct xr_proc_override xr_proc_override_tbl[] = {
@@ -700,10 +696,12 @@ XrResult bionic_xrGetInstanceProcAddr(XrInstance instance, const char *name, PFN
printf("xrGetInstanceProcAddr(%s)\n", name);
struct xr_proc_override *match = bsearch(name, xr_proc_override_tbl,
ARRRAY_SIZE(xr_proc_override_tbl), sizeof(xr_proc_override_tbl[0]), strcmp);
ARRRAY_SIZE(xr_proc_override_tbl),
sizeof(xr_proc_override_tbl[0]),
(int (*)(const void *, const void *))strcmp);
if (match) {
*func = match->func;
*func = (PFN_xrVoidFunction)match->func;
return XR_SUCCESS;
}