From: Cheoleun Moon Date: Tue, 3 Mar 2020 11:58:57 +0000 (+0900) Subject: Use const before unsigned char * and char * as needed X-Git-Tag: submit/tizen/20200403.050222~2^2~48^2~1 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=ad85c358fe88382f53a65fc824a8eb2a920f2336;p=platform%2Fcore%2Fapi%2Fwifi-aware.git Use const before unsigned char * and char * as needed --- diff --git a/include/wifi-aware.h b/include/wifi-aware.h index 645e6c2..99cc282 100644 --- a/include/wifi-aware.h +++ b/include/wifi-aware.h @@ -242,7 +242,7 @@ int wifi_aware_publish_set_service_name(wifi_aware_publish_h publish, const char * @return 0 on success, otherwise a negative error value * @retval #WIFI_AWARE_ERROR_NONE */ -int wifi_aware_publish_set_service_specific_info(wifi_aware_publish_h publish, unsigned char *service_specific_info, size_t len); +int wifi_aware_publish_set_service_specific_info(wifi_aware_publish_h publish, const unsigned char *service_specific_info, size_t len); /** * @brief Set the match filter of the service. It is used to decide whether accepting a subscribe request or not. @@ -253,7 +253,7 @@ int wifi_aware_publish_set_service_specific_info(wifi_aware_publish_h publish, u * @return 0 on success, otherwise a negative error value * @retval #WIFI_AWARE_ERROR_NONE */ -int wifi_aware_publish_set_match_filter(wifi_aware_publish_h publish, unsigned char *match_filter, size_t len); +int wifi_aware_publish_set_match_filter(wifi_aware_publish_h publish, const unsigned char *match_filter, size_t len); /** * @brief TODO (Need decision to add) Set whether notifying a termination of the service or not. @@ -318,7 +318,7 @@ int wifi_aware_subscribe_set_service_name(wifi_aware_subscribe_h subscribe, cons * @return 0 on success, otherwise a negative error value * @retval #WIFI_AWARE_ERROR_NONE */ -int wifi_aware_subscribe_set_service_specific_info(wifi_aware_subscribe_h subscribe, unsigned char *service_specific_info, size_t len); +int wifi_aware_subscribe_set_service_specific_info(wifi_aware_subscribe_h subscribe, const unsigned char *service_specific_info, size_t len); /** * @brief @@ -329,7 +329,7 @@ int wifi_aware_subscribe_set_service_specific_info(wifi_aware_subscribe_h subscr * @return 0 on success, otherwise a negative error value * @retval #WIFI_AWARE_ERROR_NONE */ -int wifi_aware_subscribe_set_match_filter(wifi_aware_subscribe_h subscribe, unsigned char *match_filter, size_t len); +int wifi_aware_subscribe_set_match_filter(wifi_aware_subscribe_h subscribe, const unsigned char *match_filter, size_t len); /** * @brief @@ -506,7 +506,7 @@ int wifi_aware_session_update_subscribe(wifi_aware_session_h session, */ typedef void(*wifi_aware_service_discovered_cb)(wifi_aware_session_h session, wifi_aware_peer_h peer, - unsigned char *service_specific_info, size_t service_specific_info_len, + const unsigned char *service_specific_info, size_t service_specific_info_len, void *user_data); /** @@ -546,7 +546,7 @@ typedef void(*wifi_aware_send_message_result_cb)(wifi_aware_session_h session, int wifi_aware_send_message( wifi_aware_session_h session, wifi_aware_peer_h peer, - unsigned char *message, size_t len, + const unsigned char *message, size_t len, wifi_aware_send_message_result_cb callback, void *user_data); /** @@ -562,7 +562,7 @@ int wifi_aware_send_message( typedef void(*wifi_aware_message_received_cb)( wifi_aware_session_h session, wifi_aware_peer_h peer, - unsigned char *message, size_t len, void *user_data); + const unsigned char *message, size_t len, void *user_data); /** * @brief @@ -626,7 +626,7 @@ int wifi_aware_data_path_set_security(wifi_aware_data_path_h data_path, wifi_awa * @param[in] data_path * @param[in] key */ -int wifi_aware_data_path_set_psk(wifi_aware_data_path_h data_path, char *key); +int wifi_aware_data_path_set_psk(wifi_aware_data_path_h data_path, const char *key); /** * @brief Set a PMK for Wi-Fi Aware Data Path. It can be used only when secury_type is WIFI_AWARE_SECURITY_TYPE_PMK. @@ -634,7 +634,7 @@ int wifi_aware_data_path_set_psk(wifi_aware_data_path_h data_path, char *key); * @param[in] data_path * @param[in] key Pairwise Master Key. Its length should be 32 */ -int wifi_aware_data_path_set_pmk(wifi_aware_data_path_h data_path, unsigned char *key); +int wifi_aware_data_path_set_pmk(wifi_aware_data_path_h data_path, const unsigned char *key); // only for responder /** @@ -645,7 +645,7 @@ int wifi_aware_data_path_set_pmk(wifi_aware_data_path_h data_path, unsigned char * @param[in] service_specific_info * @param[in] service_specific_info_len */ -int wifi_aware_data_path_set_service_specific_info(wifi_aware_data_path_h data_path, unsigned char *service_specific_info, size_t service_specific_info_len); +int wifi_aware_data_path_set_service_specific_info(wifi_aware_data_path_h data_path, const unsigned char *service_specific_info, size_t service_specific_info_len); // TODO: // We are considering // removing wifi_aware_data_path_set_service_specific_info() and @@ -670,7 +670,7 @@ int wifi_aware_data_path_destroy(wifi_aware_data_path_h data_path); * @param[in] user_data */ typedef void(*wifi_aware_data_path_open_cb)(wifi_aware_data_path_h data_path, wifi_aware_error_e error, - unsigned char *mac, unsigned char *service_specific_info, size_t service_specific_info_len, void *user_data); + const unsigned char *mac, const unsigned char *service_specific_info, size_t service_specific_info_len, void *user_data); /** * @brief Start to open a Wi-Fi Aware Data Path. diff --git a/src/include/wifi-aware-data-path.h b/src/include/wifi-aware-data-path.h index b22d772..61b9d46 100644 --- a/src/include/wifi-aware-data-path.h +++ b/src/include/wifi-aware-data-path.h @@ -37,9 +37,9 @@ int _wifi_aware_data_path_set_security(wifi_aware_data_path_h data_path, wifi_aware_security_type_e security_type); int _wifi_aware_data_path_set_psk(wifi_aware_data_path_h data_path, const char *key); int _wifi_aware_data_path_set_pmk(wifi_aware_data_path_h data_path, - unsigned char *key); + const unsigned char *key); int _wifi_aware_data_path_set_service_specific_info(wifi_aware_data_path_h data_path, - unsigned char *service_specific_info, size_t service_specific_info_len); + const unsigned char *service_specific_info, size_t service_specific_info_len); int _wifi_aware_data_path_destroy(wifi_aware_data_path_h data_path); int _wifi_aware_data_path_open(wifi_aware_data_path_h data_path, wifi_aware_data_path_open_cb callback, void *user_data); diff --git a/src/include/wifi-aware-gdbus.h b/src/include/wifi-aware-gdbus.h index fe7de45..13cd42b 100644 --- a/src/include/wifi-aware-gdbus.h +++ b/src/include/wifi-aware-gdbus.h @@ -83,12 +83,11 @@ int wifi_aware_gdbus_ndp_close(wifi_aware_data_path_h data_path, unsigned int ndp_id, uint16_t pub_sub_id, unsigned int peer_id); int wifi_aware_gdbus_ndp_psk(wifi_aware_data_path_h data_path, uint16_t pub_sub_id, unsigned int peer_id, wifi_aware_data_path_role_e role, - unsigned char *specific_info, size_t specific_info_len, - const char *psk, - GAsyncReadyCallback cb); + const unsigned char *specific_info, size_t specific_info_len, + const char *psk, GAsyncReadyCallback cb); int wifi_aware_gdbus_ndp_pmk(wifi_aware_data_path_h data_path, uint16_t pub_sub_id, unsigned int peer_id, wifi_aware_data_path_role_e role, - unsigned char *specific_info, size_t specific_info_len, + const unsigned char *specific_info, size_t specific_info_len, const unsigned char *pmk, size_t pmk_len, GAsyncReadyCallback cb); #ifdef __cplusplus diff --git a/src/include/wifi-aware-private.h b/src/include/wifi-aware-private.h index 3a85dd4..6a1823d 100644 --- a/src/include/wifi-aware-private.h +++ b/src/include/wifi-aware-private.h @@ -50,9 +50,9 @@ void _wifi_aware_publish_set_type(wifi_aware_publish_h publish, wifi_aware_publish_type_e publish_type); void _wifi_aware_publish_set_service_name(wifi_aware_publish_h publish, const char *service_name); void _wifi_aware_publish_set_service_specific_info(wifi_aware_publish_h publish, - unsigned char *service_specific_info, size_t len); + const unsigned char *service_specific_info, size_t len); void _wifi_aware_publish_set_match_filter(wifi_aware_publish_h publish, - unsigned char *match_filter, size_t len); + const unsigned char *match_filter, size_t len); void _wifi_aware_publish_set_enable_termination_event(wifi_aware_publish_h publish, bool enable); void _wifi_aware_publish_set_enable_ranging(wifi_aware_publish_h publish, bool enable); wifi_aware_publish_request_s *_wifi_aware_publish_get_request(wifi_aware_publish_h publish_handle); @@ -65,9 +65,9 @@ void _wifi_aware_subscribe_set_type(wifi_aware_subscribe_h subscribe, wifi_aware_subscribe_type_e subscribe_type); void _wifi_aware_subscribe_set_service_name(wifi_aware_subscribe_h subscribe, const char *service_name); void _wifi_aware_subscribe_set_service_specific_info(wifi_aware_subscribe_h subscribe, - unsigned char *service_specific_info, size_t len); + const unsigned char *service_specific_info, size_t len); void _wifi_aware_subscribe_set_match_filter(wifi_aware_subscribe_h subscribe, - unsigned char *match_filter, size_t len); + const unsigned char *match_filter, size_t len); void _wifi_aware_subscribe_set_enable_termination_event(wifi_aware_subscribe_h subscribe, bool enable); wifi_aware_subscribe_request_s *_wifi_aware_subscribe_get_request(wifi_aware_subscribe_h subscribe_handle); uint16_t _wifi_aware_session_get_subscribe_id(wifi_aware_session_h session); @@ -90,7 +90,7 @@ void _wifi_aware_set_message_received_cb(wifi_aware_session_h session, void _wifi_aware_unset_message_received_cb(wifi_aware_session_h session); int _wifi_aware_send_message(wifi_aware_session_h session, wifi_aware_peer_h peer, - unsigned char *message, size_t len, + const unsigned char *message, size_t len, wifi_aware_send_message_result_cb callback, void *user_data); //void _mac_address_changed(GDBusConnection *connection, diff --git a/src/wifi-aware-data-path.c b/src/wifi-aware-data-path.c index f3bf9cf..1368aac 100644 --- a/src/wifi-aware-data-path.c +++ b/src/wifi-aware-data-path.c @@ -158,7 +158,7 @@ int _wifi_aware_data_path_set_psk(wifi_aware_data_path_h data_path, const char * return WIFI_AWARE_ERROR_NONE; } -int _wifi_aware_data_path_set_pmk(wifi_aware_data_path_h data_path, unsigned char *key) +int _wifi_aware_data_path_set_pmk(wifi_aware_data_path_h data_path, const unsigned char *key) { __WIFI_AWARE_FUNC_ENTER__; @@ -172,7 +172,7 @@ int _wifi_aware_data_path_set_pmk(wifi_aware_data_path_h data_path, unsigned cha } int _wifi_aware_data_path_set_service_specific_info(wifi_aware_data_path_h data_path, - unsigned char *service_specific_info, size_t service_specific_info_len) + const unsigned char *service_specific_info, size_t service_specific_info_len) { __WIFI_AWARE_FUNC_ENTER__; @@ -207,7 +207,7 @@ static void __data_path_set_open_cb(wifi_aware_data_path_h data_path, } static void __data_path_invoke_callback(wifi_aware_data_path_h data_path, wifi_aware_error_e error, - unsigned char *mac, unsigned char *specific_info, size_t specific_info_len) + const unsigned char *mac, const unsigned char *specific_info, size_t specific_info_len) { RET_IF(data_path == NULL, "data path handle is NULL"); wifi_aware_data_path_s *ndp = (wifi_aware_data_path_s *)data_path; diff --git a/src/wifi-aware-gdbus.c b/src/wifi-aware-gdbus.c index ebdd2e2..97637df 100644 --- a/src/wifi-aware-gdbus.c +++ b/src/wifi-aware-gdbus.c @@ -643,7 +643,7 @@ int wifi_aware_gdbus_ndp_close(wifi_aware_data_path_h data_path, int wifi_aware_gdbus_ndp_psk(wifi_aware_data_path_h data_path, uint16_t pub_sub_id, unsigned int peer_id, wifi_aware_data_path_role_e role, - unsigned char *specific_info, size_t specific_info_len, + const unsigned char *specific_info, size_t specific_info_len, const char *psk, GAsyncReadyCallback cb) { @@ -652,7 +652,7 @@ int wifi_aware_gdbus_ndp_psk(wifi_aware_data_path_h data_path, int wifi_aware_gdbus_ndp_pmk(wifi_aware_data_path_h data_path, uint16_t pub_sub_id, unsigned int peer_id, wifi_aware_data_path_role_e role, - unsigned char *specific_info, size_t specific_info_len, + const unsigned char *specific_info, size_t specific_info_len, const unsigned char *pmk, size_t pmk_len, GAsyncReadyCallback cb) { diff --git a/src/wifi-aware-private.c b/src/wifi-aware-private.c index e6e4193..8225fa6 100644 --- a/src/wifi-aware-private.c +++ b/src/wifi-aware-private.c @@ -269,7 +269,7 @@ static void __wifi_aware_publish_invoke_callback(wifi_aware_session_h session, } static void __wifi_aware_discovered_cb(wifi_aware_session_h session, wifi_aware_peer_h peer, - unsigned char *specific_info, size_t specific_info_len) + const unsigned char *specific_info, size_t specific_info_len) { RET_IF(session == NULL, "Session is NULL"); wifi_aware_session_s *handle = (wifi_aware_session_s *)session; @@ -281,7 +281,7 @@ static void __wifi_aware_discovered_cb(wifi_aware_session_h session, wifi_aware_ } static void __wifi_aware_received_cb(wifi_aware_session_h session, wifi_aware_peer_h peer, - unsigned char *specific_info, size_t specific_info_len) + const unsigned char *specific_info, size_t specific_info_len) { RET_IF(session == NULL, "Session is NULL"); wifi_aware_session_s *handle = (wifi_aware_session_s *)session; @@ -556,7 +556,7 @@ void _wifi_aware_publish_set_service_name(wifi_aware_publish_h publish, const ch } void _wifi_aware_publish_set_service_specific_info(wifi_aware_publish_h publish, - unsigned char *service_specific_info, size_t len) + const unsigned char *service_specific_info, size_t len) { wifi_aware_publish_request_s *req = (wifi_aware_publish_request_s *)publish; memcpy(req->specific_info, service_specific_info, len); @@ -564,7 +564,7 @@ void _wifi_aware_publish_set_service_specific_info(wifi_aware_publish_h publish, } void _wifi_aware_publish_set_match_filter(wifi_aware_publish_h publish, - unsigned char *match_filter, size_t len) + const unsigned char *match_filter, size_t len) { wifi_aware_publish_request_s *req = (wifi_aware_publish_request_s *)publish; memcpy(req->match_filter, match_filter, len); @@ -696,7 +696,7 @@ void _wifi_aware_subscribe_set_service_name(wifi_aware_subscribe_h subscribe, co } void _wifi_aware_subscribe_set_service_specific_info(wifi_aware_subscribe_h subscribe, - unsigned char *service_specific_info, size_t len) + const unsigned char *service_specific_info, size_t len) { wifi_aware_subscribe_request_s *req = (wifi_aware_subscribe_request_s *)subscribe; memcpy(req->specific_info, service_specific_info, len); @@ -705,7 +705,7 @@ void _wifi_aware_subscribe_set_service_specific_info(wifi_aware_subscribe_h subs } void _wifi_aware_subscribe_set_match_filter(wifi_aware_subscribe_h subscribe, - unsigned char *match_filter, size_t len) + const unsigned char *match_filter, size_t len) { wifi_aware_subscribe_request_s *req = (wifi_aware_subscribe_request_s *)subscribe; memcpy(req->match_filter, match_filter, len); @@ -1047,7 +1047,7 @@ static void __send_message_reply(GObject *src, GAsyncResult *res, gpointer user_ int _wifi_aware_send_message(wifi_aware_session_h session, wifi_aware_peer_h peer, - unsigned char *message, size_t len, + const unsigned char *message, size_t len, wifi_aware_send_message_result_cb callback, void *user_data) { __WIFI_AWARE_FUNC_ENTER__; diff --git a/src/wifi-aware.c b/src/wifi-aware.c index 65f071e..23fd110 100644 --- a/src/wifi-aware.c +++ b/src/wifi-aware.c @@ -204,7 +204,7 @@ API int wifi_aware_publish_set_service_name(wifi_aware_publish_h publish, } API int wifi_aware_publish_set_service_specific_info(wifi_aware_publish_h publish, - unsigned char *service_specific_info, size_t len) + const unsigned char *service_specific_info, size_t len) { __WIFI_AWARE_FUNC_ENTER__; CHECK_FEATURE_SUPPORTED(TIZEN_FEATURE_WIFI_AWARE); @@ -223,7 +223,7 @@ API int wifi_aware_publish_set_service_specific_info(wifi_aware_publish_h publis } API int wifi_aware_publish_set_match_filter(wifi_aware_publish_h publish, - unsigned char *match_filter, size_t len) + const unsigned char *match_filter, size_t len) { __WIFI_AWARE_FUNC_ENTER__; CHECK_FEATURE_SUPPORTED(TIZEN_FEATURE_WIFI_AWARE); @@ -387,7 +387,7 @@ API int wifi_aware_subscribe_set_service_name( API int wifi_aware_subscribe_set_service_specific_info( wifi_aware_subscribe_h subscribe, - unsigned char *service_specific_info, size_t len) + const unsigned char *service_specific_info, size_t len) { __WIFI_AWARE_FUNC_ENTER__; CHECK_FEATURE_SUPPORTED(TIZEN_FEATURE_WIFI_AWARE); @@ -407,7 +407,7 @@ API int wifi_aware_subscribe_set_service_specific_info( API int wifi_aware_subscribe_set_match_filter( wifi_aware_subscribe_h subscribe, - unsigned char *match_filter, size_t len) + const unsigned char *match_filter, size_t len) { __WIFI_AWARE_FUNC_ENTER__; CHECK_FEATURE_SUPPORTED(TIZEN_FEATURE_WIFI_AWARE); @@ -522,7 +522,7 @@ API int wifi_aware_unset_service_discovered_cb(wifi_aware_session_h session, API int wifi_aware_send_message(wifi_aware_session_h session, wifi_aware_peer_h peer, - unsigned char *message, size_t len, + const unsigned char *message, size_t len, wifi_aware_send_message_result_cb callback, void *user_data) { __WIFI_AWARE_FUNC_ENTER__; @@ -597,7 +597,7 @@ API int wifi_aware_data_path_set_security(wifi_aware_data_path_h data_path, wifi return ret; } -API int wifi_aware_data_path_set_psk(wifi_aware_data_path_h data_path, char *key) +API int wifi_aware_data_path_set_psk(wifi_aware_data_path_h data_path, const char *key) { int ret = WIFI_AWARE_ERROR_NONE; @@ -612,7 +612,7 @@ API int wifi_aware_data_path_set_psk(wifi_aware_data_path_h data_path, char *key return ret; } -API int wifi_aware_data_path_set_pmk(wifi_aware_data_path_h data_path, unsigned char *key) +API int wifi_aware_data_path_set_pmk(wifi_aware_data_path_h data_path, const unsigned char *key) { int ret = WIFI_AWARE_ERROR_NONE; @@ -627,7 +627,7 @@ API int wifi_aware_data_path_set_pmk(wifi_aware_data_path_h data_path, unsigned return ret; } -API int wifi_aware_data_path_set_service_specific_info(wifi_aware_data_path_h data_path, unsigned char *service_specific_info, size_t service_specific_info_len) +API int wifi_aware_data_path_set_service_specific_info(wifi_aware_data_path_h data_path, const unsigned char *service_specific_info, size_t service_specific_info_len) { int ret = WIFI_AWARE_ERROR_NONE;