Change void type functions
authorJiwan Kim <ji-wan.kim@samsung.com>
Fri, 24 Mar 2017 07:52:28 +0000 (16:52 +0900)
committersaerome.kim <saerome.kim@samsung.com>
Thu, 11 May 2017 09:07:20 +0000 (18:07 +0900)
- Update functions to return int return value

Change-Id: I0bad4d1c178edcfeed8c0a66744aba024426a822
Signed-off-by: Jiwan Kim <ji-wan.kim@samsung.com>
include/zb_zcl.h
include/zigbee.h
lib/zbl.c
lib/zbl_dbus.c
lib/zbl_dbus.h
lib/zbl_zcl.c

index 1ba0eb85957c752d039cdb284bfdc4b50be4102d..f3703462036d489bdda6925fe1fe3b5637f44598 100644 (file)
@@ -151,11 +151,14 @@ int zb_create_value(
  *
  * @param[in] handle handle of simple data value
  *
- * @return None
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #ZIGBEE_ERROR_NONE Successful
+ * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #ZIGBEE_ERROR_NOT_SUPPORTED Not supported
  *
  * @see zb_create_value()
  */
-void zb_destroy_value(
+int zb_destroy_value(
                zb_value_h handle);
 
 /**
@@ -258,7 +261,7 @@ int zb_create_read_attr_status_record(read_attr_status_record_h *handle);
  * @see zb_get_value_from_read_attr_status_record()
  * @see zb_zcl_global_read_attr_rsp()
  */
-void zb_destroy_read_attr_status_record(read_attr_status_record_h handle);
+int zb_destroy_read_attr_status_record(read_attr_status_record_h handle);
 
 /**
  * @brief Gets identifier from read attribute status record
@@ -571,7 +574,7 @@ int zb_create_discover_attr_info(discover_attr_info_record_h *handle);
  * @see zb_get_type_from_discover_attr_info()
  * @see zb_zcl_global_discover_attr_rsp()
  */
-void zb_destroy_discover_attr_info(discover_attr_info_record_h handle);
+int zb_destroy_discover_attr_info(discover_attr_info_record_h handle);
 
 /**
  * @brief Gets identifier from discover attribute info
@@ -711,7 +714,10 @@ int zb_create_write_attr_record(
  *
  * @param[in] handle handle of write attribute record
  *
- * @return None
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #ZIGBEE_ERROR_NONE Successful
+ * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #ZIGBEE_ERROR_NOT_SUPPORTED Not supported
  *
  * @see zb_zcl_global_write_attr()
  * @see zb_zcl_global_write_attr_undivided()
@@ -722,7 +728,7 @@ int zb_create_write_attr_record(
  * @see zb_set_buf_to_write_attr_record()
  * @see zb_set_value_to_write_attr_record()
  */
-void zb_destroy_write_attr_record(
+int zb_destroy_write_attr_record(
                write_attr_record_h handle);
 
 /**
@@ -874,7 +880,10 @@ int zb_create_write_attr_status(write_attr_status_record_h *handle);
  *
  * @param[in] handle handle of write attribute status record
  *
- * @return None
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #ZIGBEE_ERROR_NONE Successful
+ * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #ZIGBEE_ERROR_NOT_SUPPORTED Not supported
  *
  * @see zb_zcl_global_write_attr_rsp()
  * @see zb_create_write_attr_status()
@@ -882,7 +891,7 @@ int zb_create_write_attr_status(write_attr_status_record_h *handle);
  * @see zb_get_type_from_discover_attr_info()
 
  */
-void zb_destroy_write_attr_status(write_attr_status_record_h handle);
+int zb_destroy_write_attr_status(write_attr_status_record_h handle);
 
 /**
  * @brief Gets status from write attribute status record
@@ -1064,7 +1073,7 @@ int zb_create_report_config_record(
  * @see zb_get_timeout_from_report_config_record()
  * @see zb_set_timeout_to_report_config_record()
  */
-void zb_destroy_report_config_record(
+int zb_destroy_report_config_record(
                report_config_record_h handle);
 
 /**
@@ -1938,7 +1947,10 @@ int zb_create_read_report_config_record(
  *
  * @param[in] handle handle of write attribute record
  *
- * @return None
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #ZIGBEE_ERROR_NONE Successful
+ * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #ZIGBEE_ERROR_NOT_SUPPORTED Not supported
  *
  * @see zb_create_read_report_config_record()
  * @see zb_destroy_read_report_config_record()
@@ -1947,7 +1959,7 @@ int zb_create_read_report_config_record(
  * @see zb_get_dir_from_read_report_config_record()
  * @see zb_set_dir_to_read_report_config_record()
  */
-void zb_destroy_read_report_config_record(
+int zb_destroy_read_report_config_record(
                read_report_config_record_h handle);
 
 /**
@@ -2110,7 +2122,7 @@ int zb_create_report_config_response_record(
  * @see zb_get_id_from_report_config_response_record()
  * @see zb_set_id_to_report_config_response_record()
  */
-void zb_destroy_report_config_response_record(
+int zb_destroy_report_config_response_record(
                report_config_response_record_h handle);
 
 /**
@@ -2367,7 +2379,7 @@ int zb_create_attr_report(
  * @see zb_get_value_from_attr_report()
  * @see zb_set_value_to_attr_report()
  */
-void zb_destroy_attr_report(
+int zb_destroy_attr_report(
                attr_report_h handle);
 
 /**
@@ -2602,7 +2614,7 @@ int zb_create_extended_attr_info(
  * @see zb_get_acl_from_extended_attr_info()
  * @see zb_set_acl_to_extended_attr_info()
  */
-void zb_destroy_extended_attr_info(
+int zb_destroy_extended_attr_info(
                extended_attr_info_h handle);
 
 /**
index f54d2207a34368a0845e25e1a65bd0311a0e375f..9559cb5eeb3a5ae7dcb7eefccb0440569ff679bf 100644 (file)
@@ -75,11 +75,14 @@ int zb_create(zigbee_h *handle);
  *
  * @param[in] handle The handle of zigbee
  *
- * @return None
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #ZIGBEE_ERROR_NONE Successful
+ * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #ZIGBEE_ERROR_NOT_SUPPORTED Not supported
  *
  * @see zb_create()
  */
-void zb_destroy(zigbee_h handle);
+int zb_destroy(zigbee_h handle);
 
 /**
  * @brief Called after receiving events from zigbee service
index 75c7c3ebcf80aebca8cb4550a4de02fad88681ce..13f111070fbf8a3101f97b2306b8bc3cd94712fa 100644 (file)
--- a/lib/zbl.c
+++ b/lib/zbl.c
@@ -47,10 +47,13 @@ API int zb_create(zigbee_h *handle)
        return ret;
 }
 
-API void zb_destroy(zigbee_h handle)
+API int zb_destroy(zigbee_h handle)
 {
-       RET_IF(NULL == handle);
+       CHECK_FEATURE_SUPPORTED(ZIGBEE_FEATURE);
+       RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER);
+
        zbl_dbus_stop(handle);
+       return ZIGBEE_ERROR_NONE;
 }
 
 API int zb_enable(zigbee_h handle, zb_enable_cb cb, void *user_data)
index 5fbafb00d9fe5e36be6010d828c77f3dcb19c9ec..0b6febfa7d39126e397984ba88d441955a71e4ef 100644 (file)
@@ -8376,20 +8376,20 @@ int zbl_dbus_start(zigbee_h handle)
        return ZIGBEE_ERROR_NONE;
 }
 
-void zbl_dbus_stop(zigbee_h handle)
+int zbl_dbus_stop(zigbee_h handle)
 {
        struct zbl_zigbee_s *h = handle;
        DBG("zbl_dbus_stop()");
 
        if (0 >= zbl_ref_count) {
                WARN("dbus does not initiaized\n");
-               return;
+               return ZIGBEE_ERROR_NONE;
        }
 
        if (0 > --zbl_ref_count) {
                DBG("all connections closed\n");
                zbl_ref_count = 0;
-               return;
+               return ZIGBEE_ERROR_NONE;
        }
 
        if (gdbus_conn) {
@@ -8425,6 +8425,8 @@ void zbl_dbus_stop(zigbee_h handle)
 
                DBG("zbl_dbus_stop() finished");
        }
+
+       return ZIGBEE_ERROR_NONE;
 }
 
 GDBusConnection* zbl_dbus_get_object(void)
index 2d2c74cbb9460083fb3198dcfd3a7c0eb3b795be..66cd2594a91b393bded265d0262012e1fc84a29a 100644 (file)
@@ -23,7 +23,7 @@
 #include <zb_type.h>
 
 int zbl_dbus_start(zigbee_h handle);
-void zbl_dbus_stop(zigbee_h handle);
+int zbl_dbus_stop(zigbee_h handle);
 GDBusConnection* zbl_dbus_get_object(void);
 int zbl_dbus_get_timeout(GDBusProxy *proxy);
 int zbl_check_privilege();
index c5532e8a3b54993a92b57ae5d1f1199c90755bdf..89f78df6c36313bf6bbe5ebdb50f2646bdaa29ce 100644 (file)
@@ -443,15 +443,18 @@ API int zb_create_read_attr_status_record(read_attr_status_record_h *handle)
        return ZIGBEE_ERROR_NONE;
 }
 
-API void zb_destroy_read_attr_status_record(read_attr_status_record_h handle)
+API int zb_destroy_read_attr_status_record(read_attr_status_record_h handle)
 {
        struct read_attribute_status_record_s* h = handle;
 
-       RET_IF(NULL == h);
+       CHECK_FEATURE_SUPPORTED(ZIGBEE_FEATURE);
+       RETV_IF(NULL == h, ZIGBEE_ERROR_INVALID_PARAMETER);
 
        if (h->value)
                free(h->value);
        free(h);
+
+       return ZIGBEE_ERROR_NONE;
 }
 
 API int zb_get_id_from_read_attr_status_record(read_attr_status_record_h handle,
@@ -646,11 +649,12 @@ API int zb_create_value(zb_value_h *handle)
        return ZIGBEE_ERROR_NONE;
 }
 
-API void zb_destroy_value(zb_value_h handle)
+API int zb_destroy_value(zb_value_h handle)
 {
        struct zb_value_s* h = handle;
 
-       RET_IF(NULL == h);
+       CHECK_FEATURE_SUPPORTED(ZIGBEE_FEATURE);
+       RETV_IF(NULL == h, ZIGBEE_ERROR_INVALID_PARAMETER);
 
        if (h->str) {
                if (h->str->v)
@@ -663,6 +667,8 @@ API void zb_destroy_value(zb_value_h handle)
                free(h->wstr);
        }
        free(h);
+
+       return ZIGBEE_ERROR_NONE;
 }
 
 API int zb_set_value(zb_value_h handle, unsigned char type, unsigned char *value,
@@ -774,11 +780,16 @@ API int zb_create_discover_attr_info(discover_attr_info_record_h *handle)
        return ZIGBEE_ERROR_NONE;
 }
 
-API void zb_destroy_discover_attr_info(discover_attr_info_record_h handle)
+API int zb_destroy_discover_attr_info(discover_attr_info_record_h handle)
 {
        struct discover_attribute_info_record_s *h = handle;
 
+       CHECK_FEATURE_SUPPORTED(ZIGBEE_FEATURE);
+       RETV_IF(NULL == h, ZIGBEE_ERROR_INVALID_PARAMETER);
+
        free(h);
+
+       return ZIGBEE_ERROR_NONE;
 }
 
 API int zb_get_id_from_discover_attr_info(
@@ -847,13 +858,18 @@ API int zb_create_write_attr_record(
        return ZIGBEE_ERROR_NONE;
 }
 
-API void zb_destroy_write_attr_record(write_attr_record_h handle)
+API int zb_destroy_write_attr_record(write_attr_record_h handle)
 {
        struct write_attribute_record_s* h = handle;
 
+       CHECK_FEATURE_SUPPORTED(ZIGBEE_FEATURE);
+       RETV_IF(NULL == h, ZIGBEE_ERROR_INVALID_PARAMETER);
+
        if (h->value)
                free(h->value);
        free(h);
+
+       return ZIGBEE_ERROR_NONE;
 }
 
 API int zb_set_id_to_write_attr_record(write_attr_record_h handle,
@@ -976,11 +992,15 @@ API int zb_create_write_attr_status(write_attr_status_record_h *handle)
        return ZIGBEE_ERROR_NONE;
 }
 
-API void zb_destroy_write_attr_status(write_attr_status_record_h handle)
+API int zb_destroy_write_attr_status(write_attr_status_record_h handle)
 {
        struct write_attribute_status_record_s *h = handle;
 
+       CHECK_FEATURE_SUPPORTED(ZIGBEE_FEATURE);
+       RETV_IF(NULL == h, ZIGBEE_ERROR_INVALID_PARAMETER);
+
        free(h);
+       return ZIGBEE_ERROR_NONE;
 }
 
 API int zb_get_status_from_write_attr_status(write_attr_status_record_h handle,
@@ -1044,15 +1064,18 @@ API int zb_create_report_config_record(report_config_record_h *handle)
        return ZIGBEE_ERROR_NONE;
 }
 
-API void zb_destroy_report_config_record(report_config_record_h handle)
+API int zb_destroy_report_config_record(report_config_record_h handle)
 {
        struct reporting_configuration_record_s *h = handle;
 
-       RET_IF(NULL == h);
+       CHECK_FEATURE_SUPPORTED(ZIGBEE_FEATURE);
+       RETV_IF(NULL == h, ZIGBEE_ERROR_INVALID_PARAMETER);
 
        if (h->change)
                free(h->change);
        free(h);
+
+       return ZIGBEE_ERROR_NONE;
 }
 
 API int zb_get_dir_from_report_config_record(report_config_record_h handle,
@@ -1362,11 +1385,16 @@ API int zb_create_read_report_config_record(read_report_config_record_h *handle)
        return ZIGBEE_ERROR_NONE;
 }
 
-API void zb_destroy_read_report_config_record(read_report_config_record_h handle)
+API int zb_destroy_read_report_config_record(read_report_config_record_h handle)
 {
        struct read_reporting_configuration_record_s *h = handle;
 
+       CHECK_FEATURE_SUPPORTED(ZIGBEE_FEATURE);
+       RETV_IF(NULL == h, ZIGBEE_ERROR_INVALID_PARAMETER);
+
        free(h);
+
+       return ZIGBEE_ERROR_NONE;
 }
 
 API int zb_set_dir_to_read_report_config_record(read_report_config_record_h handle,
@@ -1433,12 +1461,17 @@ API int zb_create_report_config_response_record(
        return ZIGBEE_ERROR_NONE;
 }
 
-API void zb_destroy_report_config_response_record(
+API int zb_destroy_report_config_response_record(
                report_config_response_record_h handle)
 {
        struct reporting_configuration_response_record_s *h = handle;
 
+       CHECK_FEATURE_SUPPORTED(ZIGBEE_FEATURE);
+       RETV_IF(NULL == h, ZIGBEE_ERROR_INVALID_PARAMETER);
+
        free(h);
+
+       return ZIGBEE_ERROR_NONE;
 }
 
 API int zb_get_status_from_report_config_response_record(
@@ -1531,15 +1564,18 @@ API int zb_create_attr_report(attr_report_h *handle)
        return ZIGBEE_ERROR_NONE;
 }
 
-API void zb_destroy_attr_report(attr_report_h handle)
+API int zb_destroy_attr_report(attr_report_h handle)
 {
        struct attribute_report_s *h = handle;
 
-       if (h) {
-               if (h->value)
-                       free(h->value);
-               free(h);
-       }
+       CHECK_FEATURE_SUPPORTED(ZIGBEE_FEATURE);
+       RETV_IF(NULL == h, ZIGBEE_ERROR_INVALID_PARAMETER);
+
+       if (h->value)
+               free(h->value);
+       free(h);
+
+       return ZIGBEE_ERROR_NONE;
 }
 
 API int zb_get_id_from_attr_report(attr_report_h handle, unsigned short *id)
@@ -1761,11 +1797,16 @@ API int zb_create_extended_attr_info(extended_attr_info_h *handle)
        return ZIGBEE_ERROR_NONE;
 }
 
-API void zb_destroy_extended_attr_info(extended_attr_info_h handle)
+API int zb_destroy_extended_attr_info(extended_attr_info_h handle)
 {
        struct extended_attribute_infomation_s *h = handle;
 
+       CHECK_FEATURE_SUPPORTED(ZIGBEE_FEATURE);
+       RETV_IF(NULL == h, ZIGBEE_ERROR_INVALID_PARAMETER);
+
        free(h);
+
+       return ZIGBEE_ERROR_NONE;
 }
 
 API int zb_get_id_from_extended_attr_info(extended_attr_info_h handle,