Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Places where we have const* arguments in source, optionally mark the value as const as well. #1261

Merged
4 commits merged into from
Sep 24, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions sdk/src/azure/core/az_context.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ AZ_NODISCARD int64_t az_context_get_expiration(az_context const* context)
// and return the corresponding value. Returns AZ_ERROR_ITEM_NOT_FOUND is there are no nodes
ahsonkhan marked this conversation as resolved.
Show resolved Hide resolved
// matching the specified key.
AZ_NODISCARD az_result
az_context_get_value(az_context const* context, void const* key, void const** out_value)
az_context_get_value(az_context const* context, void const* const key, void const** out_value)
ahsonkhan marked this conversation as resolved.
Show resolved Hide resolved
{
_az_PRECONDITION_NOT_NULL(context);
_az_PRECONDITION_NOT_NULL(out_value);
Expand All @@ -53,7 +53,7 @@ az_context_get_value(az_context const* context, void const* key, void const** ou
}

AZ_NODISCARD az_context
az_context_create_with_expiration(az_context const* parent, int64_t expiration)
az_context_create_with_expiration(az_context const* const parent, int64_t expiration)
{
_az_PRECONDITION_NOT_NULL(parent);
_az_PRECONDITION(expiration >= 0);
Expand All @@ -62,7 +62,7 @@ az_context_create_with_expiration(az_context const* parent, int64_t expiration)
}

AZ_NODISCARD az_context
az_context_create_with_value(az_context const* parent, void const* key, void const* value)
az_context_create_with_value(az_context const* const parent, void const* const key, void const* const value)
{
_az_PRECONDITION_NOT_NULL(parent);
_az_PRECONDITION_NOT_NULL(key);
Expand All @@ -80,7 +80,7 @@ void az_context_cancel(az_context* ref_context)
ref_context->_internal.expiration = 0; // The beginning of time
}

AZ_NODISCARD bool az_context_has_expired(az_context const* context, int64_t current_time)
AZ_NODISCARD bool az_context_has_expired(az_context const* const context, int64_t current_time)
{
_az_PRECONDITION_NOT_NULL(context);
_az_PRECONDITION(current_time >= 0);
Expand Down
10 changes: 5 additions & 5 deletions sdk/src/azure/core/az_http_policy_logging.c
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ static az_span _az_http_policy_logging_copy_lengthy_value(az_span ref_log_msg, a
}

static az_result _az_http_policy_logging_append_http_request_msg(
az_http_request const* request,
az_http_request const* const request,
az_span* ref_log_msg)
{
static az_span const auth_header_name = AZ_SPAN_LITERAL_FROM_STR("authorization");
Expand Down Expand Up @@ -125,7 +125,7 @@ static az_result _az_http_policy_logging_append_http_request_msg(
static az_result _az_http_policy_logging_append_http_response_msg(
az_http_response* ref_response,
int64_t duration_msec,
az_http_request const* request,
az_http_request const* const request,
az_span* ref_log_msg)
{
az_span http_response_string = AZ_SPAN_FROM_STR("HTTP Response (");
Expand Down Expand Up @@ -208,7 +208,7 @@ static az_result _az_http_policy_logging_append_http_response_msg(
return AZ_OK;
}

void _az_http_policy_logging_log_http_request(az_http_request const* request)
void _az_http_policy_logging_log_http_request(az_http_request const* const request)
{
uint8_t log_msg_buf[AZ_LOG_MESSAGE_BUFFER_SIZE] = { 0 };
az_span log_msg = AZ_SPAN_FROM_BUFFER(log_msg_buf);
Expand All @@ -219,9 +219,9 @@ void _az_http_policy_logging_log_http_request(az_http_request const* request)
}

void _az_http_policy_logging_log_http_response(
az_http_response const* response,
az_http_response const* const response,
int64_t duration_msec,
az_http_request const* request)
az_http_request const* const request)
{
uint8_t log_msg_buf[AZ_LOG_MESSAGE_BUFFER_SIZE] = { 0 };
az_span log_msg = AZ_SPAN_FROM_BUFFER(log_msg_buf);
ahsonkhan marked this conversation as resolved.
Show resolved Hide resolved
Expand Down
10 changes: 5 additions & 5 deletions sdk/src/azure/core/az_http_request.c
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ az_http_request_append_header(az_http_request* ref_request, az_span name, az_spa
}

AZ_NODISCARD az_result az_http_request_get_header(
az_http_request const* request,
az_http_request const* const request,
int32_t index,
az_span* out_name,
az_span* out_value)
Expand All @@ -173,7 +173,7 @@ AZ_NODISCARD az_result az_http_request_get_header(
}

AZ_NODISCARD az_result
az_http_request_get_method(az_http_request const* request, az_http_method* out_method)
az_http_request_get_method(az_http_request const* const request, az_http_method* out_method)
{
_az_PRECONDITION_NOT_NULL(request);
_az_PRECONDITION_NOT_NULL(out_method);
Expand All @@ -183,7 +183,7 @@ az_http_request_get_method(az_http_request const* request, az_http_method* out_m
return AZ_OK;
}

AZ_NODISCARD az_result az_http_request_get_url(az_http_request const* request, az_span* out_url)
AZ_NODISCARD az_result az_http_request_get_url(az_http_request const* const request, az_span* out_url)
{
_az_PRECONDITION_NOT_NULL(request);
_az_PRECONDITION_NOT_NULL(out_url);
Expand All @@ -193,7 +193,7 @@ AZ_NODISCARD az_result az_http_request_get_url(az_http_request const* request, a
return AZ_OK;
}

AZ_NODISCARD az_result az_http_request_get_body(az_http_request const* request, az_span* out_body)
AZ_NODISCARD az_result az_http_request_get_body(az_http_request const* const request, az_span* out_body)
{
_az_PRECONDITION_NOT_NULL(request);
_az_PRECONDITION_NOT_NULL(out_body);
Expand All @@ -202,7 +202,7 @@ AZ_NODISCARD az_result az_http_request_get_body(az_http_request const* request,
return AZ_OK;
}

AZ_NODISCARD int32_t az_http_request_headers_count(az_http_request const* request)
AZ_NODISCARD int32_t az_http_request_headers_count(az_http_request const* const request)
{
return request->_internal.headers_length;
}
2 changes: 1 addition & 1 deletion sdk/src/azure/core/az_http_response.c
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,7 @@ void _az_http_response_reset(az_http_response* ref_response)
}

// internal function to get az_http_response remainder
static az_span _az_http_response_get_remaining(az_http_response const* response)
static az_span _az_http_response_get_remaining(az_http_response const* const response)
{
return az_span_slice_to_end(response->_internal.http_response, response->_internal.written);
}
Expand Down
4 changes: 2 additions & 2 deletions sdk/src/azure/core/az_json_reader.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
AZ_NODISCARD az_result az_json_reader_init(
az_json_reader* out_json_reader,
az_span json_buffer,
az_json_reader_options const* options)
az_json_reader_options const* const options)
{
_az_PRECONDITION(az_span_size(json_buffer) >= 1);

Expand Down Expand Up @@ -52,7 +52,7 @@ AZ_NODISCARD az_result az_json_reader_chunked_init(
az_json_reader* out_json_reader,
az_span json_buffers[],
int32_t number_of_buffers,
az_json_reader_options const* options)
az_json_reader_options const* const options)
{
_az_PRECONDITION(number_of_buffers >= 1);
_az_PRECONDITION(az_span_size(json_buffers[0]) >= 1);
Expand Down
20 changes: 10 additions & 10 deletions sdk/src/azure/core/az_json_token.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
#include <azure/core/_az_cfg.h>

static az_span _az_json_token_copy_into_span_helper(
az_json_token const* json_token,
az_json_token const* const json_token,
az_span destination)
{
_az_PRECONDITION(json_token->_internal.is_multisegment);
Expand Down Expand Up @@ -40,7 +40,7 @@ static az_span _az_json_token_copy_into_span_helper(
return destination;
}

az_span az_json_token_copy_into_span(az_json_token const* json_token, az_span destination)
az_span az_json_token_copy_into_span(az_json_token const* const json_token, az_span destination)
{
_az_PRECONDITION_VALID_SPAN(destination, json_token->size, false);

Expand Down Expand Up @@ -149,7 +149,7 @@ AZ_NODISCARD static bool _az_json_token_is_text_equal_helper(
}

AZ_NODISCARD bool az_json_token_is_text_equal(
az_json_token const* json_token,
az_json_token const* const json_token,
az_span expected_text)
{
_az_PRECONDITION_NOT_NULL(json_token);
Expand Down Expand Up @@ -243,7 +243,7 @@ AZ_NODISCARD bool az_json_token_is_text_equal(
return az_span_size(expected_text) == 0;
}

AZ_NODISCARD az_result az_json_token_get_boolean(az_json_token const* json_token, bool* out_value)
AZ_NODISCARD az_result az_json_token_get_boolean(az_json_token const* const json_token, bool* out_value)
{
_az_PRECONDITION_NOT_NULL(json_token);
_az_PRECONDITION_NOT_NULL(out_value);
Expand Down Expand Up @@ -326,7 +326,7 @@ AZ_NODISCARD static az_result _az_json_token_get_string_helper(
}

AZ_NODISCARD az_result az_json_token_get_string(
az_json_token const* json_token,
az_json_token const* const json_token,
char* destination,
int32_t destination_max_size,
int32_t* out_string_length)
Expand Down Expand Up @@ -429,7 +429,7 @@ AZ_NODISCARD az_result az_json_token_get_string(
}

AZ_NODISCARD az_result
az_json_token_get_uint64(az_json_token const* json_token, uint64_t* out_value)
az_json_token_get_uint64(az_json_token const* const json_token, uint64_t* out_value)
{
_az_PRECONDITION_NOT_NULL(json_token);
_az_PRECONDITION_NOT_NULL(out_value);
Expand Down Expand Up @@ -464,7 +464,7 @@ az_json_token_get_uint64(az_json_token const* json_token, uint64_t* out_value)
}

AZ_NODISCARD az_result
az_json_token_get_uint32(az_json_token const* json_token, uint32_t* out_value)
az_json_token_get_uint32(az_json_token const* const json_token, uint32_t* out_value)
{
_az_PRECONDITION_NOT_NULL(json_token);
_az_PRECONDITION_NOT_NULL(out_value);
Expand Down Expand Up @@ -498,7 +498,7 @@ az_json_token_get_uint32(az_json_token const* json_token, uint32_t* out_value)
return az_span_atou32(az_span_slice(scratch, 0, _az_span_diff(remainder, scratch)), out_value);
}

AZ_NODISCARD az_result az_json_token_get_int64(az_json_token const* json_token, int64_t* out_value)
AZ_NODISCARD az_result az_json_token_get_int64(az_json_token const* const json_token, int64_t* out_value)
{
_az_PRECONDITION_NOT_NULL(json_token);
_az_PRECONDITION_NOT_NULL(out_value);
Expand Down Expand Up @@ -532,7 +532,7 @@ AZ_NODISCARD az_result az_json_token_get_int64(az_json_token const* json_token,
return az_span_atoi64(az_span_slice(scratch, 0, _az_span_diff(remainder, scratch)), out_value);
}

AZ_NODISCARD az_result az_json_token_get_int32(az_json_token const* json_token, int32_t* out_value)
AZ_NODISCARD az_result az_json_token_get_int32(az_json_token const* const json_token, int32_t* out_value)
{
_az_PRECONDITION_NOT_NULL(json_token);
_az_PRECONDITION_NOT_NULL(out_value);
Expand Down Expand Up @@ -566,7 +566,7 @@ AZ_NODISCARD az_result az_json_token_get_int32(az_json_token const* json_token,
return az_span_atoi32(az_span_slice(scratch, 0, _az_span_diff(remainder, scratch)), out_value);
}

AZ_NODISCARD az_result az_json_token_get_double(az_json_token const* json_token, double* out_value)
AZ_NODISCARD az_result az_json_token_get_double(az_json_token const* const json_token, double* out_value)
{
_az_PRECONDITION_NOT_NULL(json_token);
_az_PRECONDITION_NOT_NULL(out_value);
Expand Down
10 changes: 5 additions & 5 deletions sdk/src/azure/core/az_json_writer.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
AZ_NODISCARD az_result az_json_writer_init(
az_json_writer* out_json_writer,
az_span destination_buffer,
az_json_writer_options const* options)
az_json_writer_options const* const options)
{
_az_PRECONDITION_NOT_NULL(out_json_writer);

Expand All @@ -40,7 +40,7 @@ AZ_NODISCARD az_result az_json_writer_chunked_init(
az_span first_destination_buffer,
az_span_allocator_fn allocator_callback,
void* user_context,
az_json_writer_options const* options)
az_json_writer_options const* const options)
{
_az_PRECONDITION_NOT_NULL(out_json_writer);
_az_PRECONDITION_NOT_NULL(allocator_callback);
Expand Down Expand Up @@ -93,7 +93,7 @@ _get_remaining_span(az_json_writer* ref_json_writer, int32_t required_size)

// This validation method is used outside of just preconditions, within
// az_json_writer_append_json_text.
static AZ_NODISCARD bool _az_is_appending_value_valid(az_json_writer const* json_writer)
static AZ_NODISCARD bool _az_is_appending_value_valid(az_json_writer const* const json_writer)
{
_az_PRECONDITION_NOT_NULL(json_writer);

Expand Down Expand Up @@ -136,7 +136,7 @@ static AZ_NODISCARD bool _az_is_appending_value_valid(az_json_writer const* json
}

#ifndef AZ_NO_PRECONDITION_CHECKING
static AZ_NODISCARD bool _az_is_appending_property_name_valid(az_json_writer const* json_writer)
static AZ_NODISCARD bool _az_is_appending_property_name_valid(az_json_writer const* const json_writer)
{
_az_PRECONDITION_NOT_NULL(json_writer);

Expand All @@ -156,7 +156,7 @@ static AZ_NODISCARD bool _az_is_appending_property_name_valid(az_json_writer con
}

static AZ_NODISCARD bool _az_is_appending_container_end_valid(
az_json_writer const* json_writer,
az_json_writer const* const json_writer,
uint8_t byte)
{
_az_PRECONDITION_NOT_NULL(json_writer);
Expand Down
2 changes: 1 addition & 1 deletion sdk/src/azure/core/az_log.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ static az_log_message_fn volatile _az_log_message_callback = NULL;
// guards against looping past the end of the classification array.
// Make sure to update the switch statement whenever new classifications are added.
#ifndef AZ_NO_PRECONDITION_CHECKING
AZ_INLINE bool _az_log_classifications_are_valid(az_log_classification const* classifications)
AZ_INLINE bool _az_log_classifications_are_valid(az_log_classification const* const classifications)
ahsonkhan marked this conversation as resolved.
Show resolved Hide resolved
{
if (classifications == NULL)
{
Expand Down
6 changes: 3 additions & 3 deletions sdk/src/azure/iot/az_iot_hub_client.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ AZ_NODISCARD az_result az_iot_hub_client_init(
az_iot_hub_client* client,
az_span iot_hub_hostname,
az_span device_id,
az_iot_hub_client_options const* options)
az_iot_hub_client_options const* const options)
{
_az_PRECONDITION_NOT_NULL(client);
_az_PRECONDITION_VALID_SPAN(iot_hub_hostname, 1, false);
Expand All @@ -51,7 +51,7 @@ AZ_NODISCARD az_result az_iot_hub_client_init(
}

AZ_NODISCARD az_result az_iot_hub_client_get_user_name(
az_iot_hub_client const* client,
az_iot_hub_client const* const client,
char* mqtt_user_name,
size_t mqtt_user_name_size,
size_t* out_mqtt_user_name_length)
Expand Down Expand Up @@ -142,7 +142,7 @@ AZ_NODISCARD az_result az_iot_hub_client_get_user_name(
}

AZ_NODISCARD az_result az_iot_hub_client_get_client_id(
az_iot_hub_client const* client,
az_iot_hub_client const* const client,
char* mqtt_client_id,
size_t mqtt_client_id_size,
size_t* out_mqtt_client_id_length)
Expand Down
2 changes: 1 addition & 1 deletion sdk/src/azure/iot/az_iot_hub_client_c2d.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
static const az_span c2d_topic_suffix = AZ_SPAN_LITERAL_FROM_STR("/messages/devicebound/");

AZ_NODISCARD az_result az_iot_hub_client_c2d_parse_received_topic(
az_iot_hub_client const* client,
az_iot_hub_client const* const client,
az_span received_topic,
az_iot_hub_client_c2d_request* out_request)
{
Expand Down
4 changes: 2 additions & 2 deletions sdk/src/azure/iot/az_iot_hub_client_methods.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ static const az_span methods_response_topic_result = AZ_SPAN_LITERAL_FROM_STR("r
static const az_span methods_response_topic_properties = AZ_SPAN_LITERAL_FROM_STR("/?$rid=");

AZ_NODISCARD az_result az_iot_hub_client_methods_parse_received_topic(
az_iot_hub_client const* client,
az_iot_hub_client const* const client,
az_span received_topic,
az_iot_hub_client_method_request* out_request)
{
Expand Down Expand Up @@ -76,7 +76,7 @@ AZ_NODISCARD az_result az_iot_hub_client_methods_parse_received_topic(
}

AZ_NODISCARD az_result az_iot_hub_client_methods_response_get_publish_topic(
az_iot_hub_client const* client,
az_iot_hub_client const* const client,
az_span request_id,
uint16_t status,
char* mqtt_topic,
Expand Down
4 changes: 2 additions & 2 deletions sdk/src/azure/iot/az_iot_hub_client_sas.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ static const az_span sig_string = AZ_SPAN_LITERAL_FROM_STR(SAS_TOKEN_SIG);
static const az_span se_string = AZ_SPAN_LITERAL_FROM_STR(SAS_TOKEN_SE);

AZ_NODISCARD az_result az_iot_hub_client_sas_get_signature(
az_iot_hub_client const* client,
az_iot_hub_client const* const client,
uint64_t token_expiration_epoch_time,
az_span signature,
az_span* out_signature)
Expand Down Expand Up @@ -81,7 +81,7 @@ AZ_NODISCARD az_result az_iot_hub_client_sas_get_signature(
}

AZ_NODISCARD az_result az_iot_hub_client_sas_get_password(
az_iot_hub_client const* client,
az_iot_hub_client const* const client,
uint64_t token_expiration_epoch_time,
az_span base64_hmac_sha256_signature,
az_span key_name,
Expand Down
4 changes: 2 additions & 2 deletions sdk/src/azure/iot/az_iot_hub_client_telemetry.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ static const az_span telemetry_topic_modules_mid = AZ_SPAN_LITERAL_FROM_STR("/mo
static const az_span telemetry_topic_suffix = AZ_SPAN_LITERAL_FROM_STR("/messages/events/");

AZ_NODISCARD az_result az_iot_hub_client_telemetry_get_publish_topic(
az_iot_hub_client const* client,
az_iot_message_properties const* properties,
az_iot_hub_client const* const client,
az_iot_message_properties const* const properties,
char* mqtt_topic,
size_t mqtt_topic_size,
size_t* out_mqtt_topic_length)
Expand Down
Loading