Fix type mismatch issue 82/132882/1
authorjino.cho <jino.cho@samsung.com>
Thu, 1 Jun 2017 07:18:28 +0000 (16:18 +0900)
committerjino.cho <jino.cho@samsung.com>
Thu, 8 Jun 2017 06:58:32 +0000 (15:58 +0900)
The type size of bool and gboolean are different.
Therefore, the pointer parameter should not be used directly as
a argument of gdbus functions.

Change-Id: I6ccccab228ca5fa57bee6db02e49bbe44a15eaef
Signed-off-by: jino.cho <jino.cho@samsung.com>
src/peripheral_gdbus_gpio.c
src/peripheral_gdbus_pwm.c

index 721b3d4..6550360 100644 (file)
@@ -126,21 +126,26 @@ int peripheral_gdbus_gpio_get_direction(peripheral_gpio_h gpio, peripheral_gpio_
 {
        GError *error = NULL;
        peripheral_error_e ret = PERIPHERAL_ERROR_NONE;
+       gint value = 0;
 
        if (gpio_proxy == NULL) return PERIPHERAL_ERROR_UNKNOWN;
 
        if (peripheral_io_gdbus_gpio_call_get_direction_sync(
                        gpio_proxy,
                        gpio->handle,
-                       (gint*)direction,
+                       &value,
                        &ret,
                        NULL,
                        &error) == FALSE) {
                _E("Error in %s() : %s\n", __func__, error->message);
                g_error_free(error);
-               return PERIPHERAL_ERROR_UNKNOWN;
        }
 
+       if (value >= PERIPHERAL_GPIO_DIRECTION_IN && value <= PERIPHERAL_GPIO_DIRECTION_OUT_HIGH)
+               *direction = value;
+       else
+               return PERIPHERAL_ERROR_UNKNOWN;
+
        return ret;
 }
 
@@ -214,13 +219,14 @@ int peripheral_gdbus_gpio_get_edge_mode(peripheral_gpio_h gpio, peripheral_gpio_
 {
        GError *error = NULL;
        peripheral_error_e ret = PERIPHERAL_ERROR_NONE;
+       gint value = 0;
 
        if (gpio_proxy == NULL) return PERIPHERAL_ERROR_UNKNOWN;
 
        if (peripheral_io_gdbus_gpio_call_get_edge_mode_sync(
                        gpio_proxy,
                        gpio->handle,
-                       (int*)edge,
+                       &value,
                        &ret,
                        NULL,
                        &error) == FALSE) {
@@ -229,6 +235,11 @@ int peripheral_gdbus_gpio_get_edge_mode(peripheral_gpio_h gpio, peripheral_gpio_
                return PERIPHERAL_ERROR_UNKNOWN;
        }
 
+       if (value >= PERIPHERAL_GPIO_EDGE_NONE && value <= PERIPHERAL_GPIO_EDGE_BOTH)
+               *edge = value;
+       else
+               return PERIPHERAL_ERROR_UNKNOWN;
+
        return ret;
 }
 
index a3b8b51..b32074e 100644 (file)
@@ -122,13 +122,14 @@ int peripheral_gdbus_pwm_get_period(peripheral_pwm_h pwm, int *period)
 {
        GError *error = NULL;
        peripheral_error_e ret = PERIPHERAL_ERROR_NONE;
+       gint value = 0;
 
        if (pwm_proxy == NULL) return PERIPHERAL_ERROR_UNKNOWN;
 
        if (peripheral_io_gdbus_pwm_call_get_period_sync(
                        pwm_proxy,
                        pwm->handle,
-                       (gint*)period,
+                       &value,
                        &ret,
                        NULL,
                        &error) == FALSE) {
@@ -137,6 +138,8 @@ int peripheral_gdbus_pwm_get_period(peripheral_pwm_h pwm, int *period)
                return PERIPHERAL_ERROR_UNKNOWN;
        }
 
+       *period = value;
+
        return ret;
 }
 
@@ -166,13 +169,14 @@ int peripheral_gdbus_pwm_get_duty_cycle(peripheral_pwm_h pwm, int *duty_cycle)
 {
        GError *error = NULL;
        peripheral_error_e ret = PERIPHERAL_ERROR_NONE;
+       gint value = 0;
 
        if (pwm_proxy == NULL) return PERIPHERAL_ERROR_UNKNOWN;
 
        if (peripheral_io_gdbus_pwm_call_get_duty_cycle_sync(
                        pwm_proxy,
                        pwm->handle,
-                       (gint*)duty_cycle,
+                       &value,
                        &ret,
                        NULL,
                        &error) == FALSE) {
@@ -181,6 +185,8 @@ int peripheral_gdbus_pwm_get_duty_cycle(peripheral_pwm_h pwm, int *duty_cycle)
                return PERIPHERAL_ERROR_UNKNOWN;
        }
 
+       *duty_cycle = value;
+
        return ret;
 }
 
@@ -210,13 +216,14 @@ int peripheral_gdbus_pwm_get_polarity(peripheral_pwm_h pwm, peripheral_pwm_polar
 {
        GError *error = NULL;
        peripheral_error_e ret = PERIPHERAL_ERROR_NONE;
+       gint value = 0;
 
        if (pwm_proxy == NULL) return PERIPHERAL_ERROR_UNKNOWN;
 
        if (peripheral_io_gdbus_pwm_call_get_polarity_sync(
                        pwm_proxy,
                        pwm->handle,
-                       (gint*)polarity,
+                       &value,
                        &ret,
                        NULL,
                        &error) == FALSE) {
@@ -225,6 +232,11 @@ int peripheral_gdbus_pwm_get_polarity(peripheral_pwm_h pwm, peripheral_pwm_polar
                return PERIPHERAL_ERROR_UNKNOWN;
        }
 
+       if (!value)
+               *polarity = PERIPHERAL_PWM_POLARITY_NORMAL;
+       else
+               *polarity = PERIPHERAL_PWM_POLARITY_INVERSED;
+
        return ret;
 }
 
@@ -254,13 +266,14 @@ int peripheral_gdbus_pwm_get_enable(peripheral_pwm_h pwm, bool *enable)
 {
        GError *error = NULL;
        peripheral_error_e ret = PERIPHERAL_ERROR_NONE;
+       gboolean value = 0;
 
        if (pwm_proxy == NULL) return PERIPHERAL_ERROR_UNKNOWN;
 
        if (peripheral_io_gdbus_pwm_call_get_enable_sync(
                        pwm_proxy,
                        pwm->handle,
-                       (gint*)enable,
+                       &value,
                        &ret,
                        NULL,
                        &error) == FALSE) {
@@ -269,6 +282,11 @@ int peripheral_gdbus_pwm_get_enable(peripheral_pwm_h pwm, bool *enable)
                return PERIPHERAL_ERROR_UNKNOWN;
        }
 
+       if (!value)
+               *enable = false;
+       else
+               *enable = true;
+
        return ret;
 }