Skip to content

Commit

Permalink
remove capacity size check (Azure#480)
Browse files Browse the repository at this point in the history
  • Loading branch information
danewalton authored Mar 17, 2020
1 parent f7027fa commit 44dd134
Showing 1 changed file with 0 additions and 29 deletions.
29 changes: 0 additions & 29 deletions sdk/iot/core/src/az_iot_telemetry.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,35 +30,6 @@ AZ_NODISCARD az_result az_iot_hub_client_telemetry_publish_topic_get(
const az_span* const user_agent = &(client->_internal.options.user_agent);
const az_span* const module_id = &(client->_internal.options.module_id);

// Required topic parts
int32_t required_size = az_span_length(telemetry_topic_prefix)
+ az_span_length(client->_internal.device_id) + az_span_length(telemetry_topic_suffix);

// Optional parts
if (az_span_ptr(*module_id) != NULL)
{
required_size += az_span_length(telemetry_topic_modules_mid);
required_size += az_span_length(*module_id);
}

if (properties != NULL)
{
required_size
+= az_span_length(properties->_internal.properties) + sizeof(telemetry_prop_delim);
}

if (az_span_ptr(*user_agent) != NULL)
{
required_size += az_span_length(*user_agent) + sizeof(telemetry_prop_delim);
}

// Only build topic if the span has the capacity
if (az_span_capacity(mqtt_topic) < required_size)
{
return AZ_ERROR_INSUFFICIENT_SPAN_CAPACITY;
}

// Build topic string
AZ_RETURN_IF_FAILED(az_span_append(mqtt_topic, telemetry_topic_prefix, out_mqtt_topic));
AZ_RETURN_IF_FAILED(az_span_append(*out_mqtt_topic, client->_internal.device_id, out_mqtt_topic));

Expand Down

0 comments on commit 44dd134

Please sign in to comment.