[e_info] use the uint64_t type instead the int32_t for window id
authorKonstantin Drabeniuk <k.drabeniuk@samsung.com>
Tue, 25 Apr 2017 10:25:52 +0000 (13:25 +0300)
committerSooChan Lim <sc1.lim@samsung.com>
Thu, 25 May 2017 23:24:58 +0000 (08:24 +0900)
We have some error when a window id exceeds INT_MAX, because
the Ecore_Window is the uintptr_t type and the  window id the
int32_t type. I think we need use the uint64_t(for arm7l and arm64)
type instead the int32_t type for window id.

Change-Id: I534965bf2d0e50fb23adbf266224c335c08b7a60
Signed-off-by: Konstantin Drabeniuk <k.drabeniuk@samsung.com>
src/bin/e_info_server.c
src/bin/e_utils.c
src/bin/e_utils.h

index cda4ba1812bb28d9efa0c2304a3d2d046178f185..8abf388c3bf1d89ca900ff45826c07c75a963e43 100755 (executable)
@@ -1057,7 +1057,7 @@ _msg_window_prop_append(Eldbus_Message_Iter *iter, uint32_t mode, const char *va
    Eldbus_Message_Iter *array_of_ec;
    E_Client *ec;
    Evas_Object *o;
-   uint32_t value_number = 0;
+   uint64_t value_number = 0;
    Eina_Bool res = EINA_FALSE;
 
    eldbus_message_iter_arguments_append(iter, "a(ss)", &array_of_ec);
@@ -1068,9 +1068,9 @@ _msg_window_prop_append(Eldbus_Message_Iter *iter, uint32_t mode, const char *va
         else
           {
              if (strlen(value) >= 2 && value[0] == '0' && value[1] == 'x')
-               res = e_util_string_to_uint(value, &value_number, 16);
+               res = e_util_string_to_ulong(value, (unsigned long *)&value_number, 16);
              else
-               res = e_util_string_to_uint(value, &value_number, 10);
+               res = e_util_string_to_ulong(value, (unsigned long *)&value_number, 10);
 
              EINA_SAFETY_ON_FALSE_GOTO(res, finish);
           }
@@ -2028,7 +2028,7 @@ e_info_server_cb_transform_message(const Eldbus_Service_Interface *iface EINA_UN
    uint32_t x, y, sx, sy, degree;
    uint32_t background;
    const char *value = NULL;
-   uint32_t value_number;
+   uint64_t value_number;
    Evas_Object *o;
    E_Client *ec;
    Eina_Bool res = EINA_FALSE;
@@ -2040,9 +2040,9 @@ e_info_server_cb_transform_message(const Eldbus_Service_Interface *iface EINA_UN
      }
 
    if (strlen(value) >= 2 && value[0] == '0' && value[1] == 'x')
-     res = e_util_string_to_uint(value, &value_number, 16);
+     res = e_util_string_to_ulong(value, (unsigned long *)&value_number, 16);
    else
-     res = e_util_string_to_uint(value, &value_number, 10);
+     res = e_util_string_to_ulong(value, (unsigned long *)&value_number, 10);
 
    EINA_SAFETY_ON_FALSE_RETURN_VAL(res, reply);
 
@@ -2847,7 +2847,7 @@ e_info_server_cb_aux_message(const Eldbus_Service_Interface *iface EINA_UNUSED,
    Eldbus_Message_Iter *opt_iter;
    const char *win_str, *key, *val, *opt;
    Eina_List *options = NULL;
-   uint32_t win_id = 0;
+   uint64_t win_id = 0;
    E_Client *ec;
    Evas_Object *o;
    Eina_Bool res = EINA_FALSE;
@@ -2872,7 +2872,7 @@ e_info_server_cb_aux_message(const Eldbus_Service_Interface *iface EINA_UNUSED,
         options = eina_list_append(options, str);
      }
 
-   res = e_util_string_to_uint(win_str, &win_id, 16);
+   res = e_util_string_to_ulong(win_str, (unsigned long *)&win_id, 16);
    EINA_SAFETY_ON_FALSE_RETURN_VAL(res, reply);
 
    for (o = evas_object_top_get(e_comp->evas); o; o = evas_object_below_get(o))
index 9e9bbe07a6db775ee3b12504d3a7c5e4a312f5b8..557dfbbb360aa0c33b89c490a55fbb1432a2054e 100644 (file)
@@ -1067,6 +1067,27 @@ e_util_string_to_double(const char *str, double *num)
    return EINA_TRUE;
 }
 
+E_API Eina_Bool
+e_util_string_to_ulong(const char *str, unsigned long *num, int base)
+{
+   char *end;
+   int errsv;
+
+   EINA_SAFETY_ON_NULL_RETURN_VAL(str, EINA_FALSE);
+   EINA_SAFETY_ON_NULL_RETURN_VAL(num, EINA_FALSE);
+
+   const long sul = strtoul(str, &end, base);
+   errsv = errno;
+
+   EINA_SAFETY_ON_TRUE_RETURN_VAL((end == str), EINA_FALSE); /* given string is not a decimal number */
+   EINA_SAFETY_ON_TRUE_RETURN_VAL(('\0' != *end), EINA_FALSE); /* given string has extra characters */
+   EINA_SAFETY_ON_TRUE_RETURN_VAL(((ULONG_MAX == sul) && (ERANGE == errsv)), EINA_FALSE); /* out of range of type unsigned long */
+
+   *num = (int)sul;
+
+   return EINA_TRUE;
+}
+
 E_API void
 e_util_evas_objects_above_print(Evas_Object *o)
 {
index cb4a21640b01534f5141a9c68d2b0be888ae957e..00ae522a51e4fb93b3de80ec58a4cbdb0b81b095 100644 (file)
@@ -58,6 +58,7 @@ E_API Eina_Bool e_util_string_to_uint(const char *str, unsigned int *num, int ba
 E_API Eina_Bool e_util_string_to_int(const char *str, int *num, int base);
 E_API Eina_Bool e_util_string_to_int_token(const char *str, char **next, int *num, int base);
 E_API Eina_Bool e_util_string_to_double(const char *str, double *num);
+E_API Eina_Bool e_util_string_to_ulong(const char *str, unsigned long *num, int base);
 
 E_API void e_util_evas_objects_above_print(Evas_Object *o);
 E_API void e_util_evas_objects_above_print_smart(Evas_Object *o);