Skip to content

Commit 13149b4

Browse files
committed
wiseconnect: Use native Posix functions
sl_strlen() and sl_strnlen() can be safely replaced by Posix equivalents. Signed-off-by: Rahul Gurram <[email protected]>
1 parent 67c1739 commit 13149b4

File tree

3 files changed

+12
-12
lines changed

3 files changed

+12
-12
lines changed

wiseconnect/components/service/http_client/si91x_socket/sl_http_client.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -545,14 +545,14 @@ static sl_status_t sli_si91x_send_http_client_request(sl_http_client_method_type
545545
if (request->host_name != NULL && request->ip_address != request->host_name) {
546546

547547
sl_si91x_socket_type_length_value_t *tls_sni = (sl_si91x_socket_type_length_value_t *)malloc(
548-
sizeof(sl_si91x_socket_type_length_value_t) + sl_strlen((char *)request->host_name));
548+
sizeof(sl_si91x_socket_type_length_value_t) + strlen((char *)request->host_name));
549549
if (tls_sni == NULL) {
550550
free(http_client_request);
551551
return SL_STATUS_ALLOCATION_FAILED;
552552
}
553553
tls_sni->type = SL_SI91X_TLS_EXTENSION_SNI_TYPE;
554554

555-
tls_sni->length = sl_strlen((char *)(request->host_name));
555+
tls_sni->length = strlen((char *)(request->host_name));
556556
memcpy(tls_sni->value, request->host_name, tls_sni->length);
557557
status = sli_si91x_set_sni_for_embedded_socket(tls_sni);
558558
free(tls_sni);
@@ -590,7 +590,7 @@ static sl_status_t sli_si91x_send_http_client_request(sl_http_client_method_type
590590

591591
// Check for HTTP_V_1.1 and Empty host name and fill IP address
592592
if (client_internal->configuration.http_version == SL_HTTP_V_1_1
593-
&& (request->host_name == NULL || sl_strlen((char *)request->host_name) == 0)) {
593+
&& (request->host_name == NULL || strlen((char *)request->host_name) == 0)) {
594594
http_buffer_offset += snprintf((char *)(http_client_request->buffer + http_buffer_offset),
595595
SLI_SI91X_HTTP_BUFFER_LEN - http_buffer_offset,
596596
"%s",
@@ -640,7 +640,7 @@ static sl_status_t sli_si91x_send_http_client_request(sl_http_client_method_type
640640
// Copy total data length into buffer
641641
uint8_t temp_str[TEMP_STR_SIZE] = { 0 };
642642
convert_itoa(request->body_length, temp_str);
643-
size_t temp_str_len = sl_strnlen((char *)temp_str, TEMP_STR_SIZE + 1);
643+
size_t temp_str_len = strnlen((char *)temp_str, TEMP_STR_SIZE + 1);
644644
memcpy(http_client_request->buffer + http_buffer_offset, temp_str, temp_str_len);
645645
http_buffer_offset += temp_str_len;
646646
} else {
@@ -652,7 +652,7 @@ static sl_status_t sli_si91x_send_http_client_request(sl_http_client_method_type
652652

653653
// Check if request buffer is overflowed or resource length is overflowed
654654
if (http_buffer_offset > SLI_SI91X_HTTP_BUFFER_LEN
655-
|| sl_strnlen((char *)request->resource, SLI_SI91X_MAX_HTTP_URL_SIZE + 1) > SLI_SI91X_MAX_HTTP_URL_SIZE) {
655+
|| strnlen((char *)request->resource, SLI_SI91X_MAX_HTTP_URL_SIZE + 1) > SLI_SI91X_MAX_HTTP_URL_SIZE) {
656656
free(http_client_request);
657657
return SL_STATUS_HAS_OVERFLOWED;
658658
}
@@ -1034,7 +1034,7 @@ sl_status_t sl_http_client_write_chunked_data(const sl_http_client_t *client,
10341034
}
10351035

10361036
// Check for invalid data length
1037-
if ((data_length == 0) && (sl_strlen((char *)data) == 0)) {
1037+
if ((data_length == 0) && (strlen((char *)data) == 0)) {
10381038
return SL_STATUS_INVALID_PARAMETER;
10391039
}
10401040

wiseconnect/components/service/mdns/si91x/sl_mdns.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ sl_status_t sl_mdns_init(sl_mdns_t *mdns, const sl_mdns_configuration_t *config,
141141
return SL_STATUS_INVALID_TYPE;
142142
}
143143

144-
length_host_name = sl_strnlen((char *)config->host_name, 32) + 1; // +1 for null terminator
144+
length_host_name = strnlen((char *)config->host_name, 32) + 1; // +1 for null terminator
145145
memcpy(req.buffer, config->host_name, length_host_name);
146146
length = sizeof(sl_si91x_mdns_req_t) - MDNSD_BUFFER_SIZE + length_host_name;
147147

@@ -237,9 +237,9 @@ sl_status_t sl_mdns_register_service(sl_mdns_t *mdns, sl_net_interface_t interfa
237237
return SL_STATUS_INVALID_PARAMETER;
238238
}
239239

240-
length_service_type = sl_strnlen((char *)service->service_type, MDNSD_BUFFER_SIZE) + 1;
241-
length_instance_name = sl_strnlen((char *)service->instance_name, MDNSD_BUFFER_SIZE) + 1;
242-
length_service_message = sl_strnlen((char *)service->service_message, MDNSD_BUFFER_SIZE) + 1;
240+
length_service_type = strnlen((char *)service->service_type, MDNSD_BUFFER_SIZE) + 1;
241+
length_instance_name = strnlen((char *)service->instance_name, MDNSD_BUFFER_SIZE) + 1;
242+
length_service_message = strnlen((char *)service->service_message, MDNSD_BUFFER_SIZE) + 1;
243243

244244
if ((length_service_type + length_instance_name + length_service_message) > MDNSD_BUFFER_SIZE) {
245245
return SL_STATUS_INVALID_PARAMETER;

wiseconnect/components/service/mqtt/si91x/sl_mqtt_client.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ static void sli_si91x_get_subscription(const sl_mqtt_client_t *client,
154154

155155
while (subscribed_topic_token != NULL && received_topic_token != NULL) {
156156
uint8_t subscribe_topic_length =
157-
(uint8_t)(sl_strnlen(subscribed_topic_token, SI91X_MQTT_CLIENT_TOPIC_MAXIMUM_LENGTH));
157+
(uint8_t)(strnlen(subscribed_topic_token, SI91X_MQTT_CLIENT_TOPIC_MAXIMUM_LENGTH));
158158

159159
// This boolean stores whether the subscribed_topic_token is wildcard or not by checking the length of the token and character stored in it.
160160
uint8_t is_wild_card =
@@ -168,7 +168,7 @@ static void sli_si91x_get_subscription(const sl_mqtt_client_t *client,
168168
// if subscribed_topic_token isn't wildcard and tokens does not match, break the loop and continue searching with other subscriptions.
169169
if (!is_wild_card
170170
&& ((subscribe_topic_length
171-
!= sl_strnlen((char *)received_topic_token, SI91X_MQTT_CLIENT_TOPIC_MAXIMUM_LENGTH))
171+
!= strnlen((char *)received_topic_token, SI91X_MQTT_CLIENT_TOPIC_MAXIMUM_LENGTH))
172172
|| memcmp(subscribed_topic_token, received_topic_token, subscribe_topic_length) != 0)) {
173173
break;
174174
} else if (is_multi_level_wild_card) {

0 commit comments

Comments
 (0)