From 3f62e358ea001b400287830187d43cb78ee8d913 Mon Sep 17 00:00:00 2001 From: Jiwan Kim Date: Fri, 24 Mar 2017 16:52:28 +0900 Subject: [PATCH] Change void type functions - Update functions to return int return value Change-Id: I0bad4d1c178edcfeed8c0a66744aba024426a822 Signed-off-by: Jiwan Kim --- include/zb_zcl.h | 40 ++++++++++++++++--------- include/zigbee.h | 7 +++-- lib/zbl.c | 7 +++-- lib/zbl_dbus.c | 8 +++-- lib/zbl_dbus.h | 2 +- lib/zbl_zcl.c | 77 +++++++++++++++++++++++++++++++++++++----------- 6 files changed, 101 insertions(+), 40 deletions(-) diff --git a/include/zb_zcl.h b/include/zb_zcl.h index 1ba0eb8..f370346 100644 --- a/include/zb_zcl.h +++ b/include/zb_zcl.h @@ -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); /** diff --git a/include/zigbee.h b/include/zigbee.h index f54d220..9559cb5 100644 --- a/include/zigbee.h +++ b/include/zigbee.h @@ -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 diff --git a/lib/zbl.c b/lib/zbl.c index 75c7c3e..13f1110 100644 --- 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) diff --git a/lib/zbl_dbus.c b/lib/zbl_dbus.c index 5fbafb0..0b6febf 100644 --- a/lib/zbl_dbus.c +++ b/lib/zbl_dbus.c @@ -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) diff --git a/lib/zbl_dbus.h b/lib/zbl_dbus.h index 2d2c74c..66cd259 100644 --- a/lib/zbl_dbus.h +++ b/lib/zbl_dbus.h @@ -23,7 +23,7 @@ #include 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(); diff --git a/lib/zbl_zcl.c b/lib/zbl_zcl.c index c5532e8..89f78df 100644 --- a/lib/zbl_zcl.c +++ b/lib/zbl_zcl.c @@ -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, -- 2.34.1