From 813a98c54af85705a6bb5cc150c769efc218b421 Mon Sep 17 00:00:00 2001 From: Yunhee Seo Date: Fri, 3 Nov 2023 17:36:13 +0900 Subject: [PATCH] power: Add type casting to support architecture-independent API porting. At first, in the 32bit architecture, power state enum value is treated as 4 byte. Thus, when dealing with enum value, the type should be converted to unsigned int or int. Especially, this is necessary for C# API porting in the 32bit architecture to avoid abnormal operation. However, when the device_power_change_state uses dbus call, it treats enum value as uint64_t in the g_variant type. To make correct type conversion in g_variant, uint64_t type conversion is needed also. Change-Id: I2e9ef7a715ca5beb13f358e183f5b054cff86ce1 Signed-off-by: Yunhee Seo --- src/power-internal.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/power-internal.c b/src/power-internal.c index 01a9b94..631e11a 100644 --- a/src/power-internal.c +++ b/src/power-internal.c @@ -111,7 +111,7 @@ static void state_signal_callback(GDBusConnection *connection, g_variant_get(parameters, "(ttti)", &prev_state, &next_state, &id, &reason); - h->state_wait_callback(prev_state, next_state, id, reason, h->user_data); + h->state_wait_callback((unsigned int)prev_state, (unsigned int)next_state, id, reason, h->user_data); } static int __register_state_signal_callback(GDBusConnection *connection, @@ -222,7 +222,7 @@ static void transient_state_signal_callback(GDBusConnection *connection, g_variant_get(parameters, "(ttti)", &prev_state, &next_state, &id, &reason); - h->transient_state_wait_callback(next_state, id, reason, h->user_data); + h->transient_state_wait_callback((unsigned int)next_state, id, reason, h->user_data); } static int __register_transient_state_signal_callback(GDBusConnection *connection, @@ -518,13 +518,13 @@ static void change_state_async_callback(GObject *source_object, GAsyncResult *re retval = -ETIMEDOUT; _E("Failed to finish async call, %s(%d)", err->message, err->code); - h->callback(h->state, retval, h->user_data); + h->callback((unsigned int)h->state, retval, h->user_data); goto cleanup; } g_variant_get(retgv, "(i)", &retval); - h->callback(h->state, retval, h->user_data); + h->callback((unsigned int)h->state, retval, h->user_data); cleanup: if (err) @@ -581,7 +581,7 @@ int device_power_change_state(device_power_state_e state, int timeout_sec, devic DEVICED_PATH_POWER, DEVICED_INTERFACE_POWER, "PowerChangeState", - g_variant_new("(t)", state), + g_variant_new("(t)", (uint64_t)state), NULL, G_DBUS_CALL_FLAGS_NONE, timeout_sec * 1000, -- 2.7.4