Skip to content

Commit

Permalink
Fix C++ ODR Violations
Browse files Browse the repository at this point in the history
**Issue:**
aws/aws-sdk-cpp#2137

**Description of Changes:**
Rename `imds_user_data` -> `imds_provider_user_data` in `credentia_provider_imds.c`, to avoid collision with same-named struct in `aws_imds_client.c`.
  • Loading branch information
graebm committed Nov 8, 2022
1 parent d56e18d commit 0d82084
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions source/credentials_provider_imds.c
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ struct aws_credentials_provider *aws_credentials_provider_new_imds(
/*
* Tracking structure for each outstanding async query to an imds provider
*/
struct imds_user_data {
struct imds_provider_user_data {
/* immutable post-creation */
struct aws_allocator *allocator;
struct aws_credentials_provider *imds_provider;
Expand All @@ -116,7 +116,7 @@ struct imds_user_data {
void *original_user_data;
};

static void s_imds_user_data_destroy(struct imds_user_data *user_data) {
static void s_imds_provider_user_data_destroy(struct imds_provider_user_data *user_data) {
if (user_data == NULL) {
return;
}
Expand All @@ -125,13 +125,13 @@ static void s_imds_user_data_destroy(struct imds_user_data *user_data) {
aws_mem_release(user_data->allocator, user_data);
}

static struct imds_user_data *s_imds_user_data_new(
static struct imds_provider_user_data *s_imds_provider_user_data_new(
struct aws_credentials_provider *imds_provider,
aws_on_get_credentials_callback_fn callback,
void *user_data) {

struct imds_user_data *wrapped_user_data =
aws_mem_calloc(imds_provider->allocator, 1, sizeof(struct imds_user_data));
struct imds_provider_user_data *wrapped_user_data =
aws_mem_calloc(imds_provider->allocator, 1, sizeof(struct imds_provider_user_data));
if (wrapped_user_data == NULL) {
goto on_error;
}
Expand All @@ -147,20 +147,20 @@ static struct imds_user_data *s_imds_user_data_new(
return wrapped_user_data;

on_error:
s_imds_user_data_destroy(wrapped_user_data);
s_imds_provider_user_data_destroy(wrapped_user_data);
return NULL;
}

static void s_on_get_credentials(const struct aws_credentials *credentials, int error_code, void *user_data) {
(void)error_code;
struct imds_user_data *wrapped_user_data = user_data;
struct imds_provider_user_data *wrapped_user_data = user_data;
wrapped_user_data->original_callback(
(struct aws_credentials *)credentials, error_code, wrapped_user_data->original_user_data);
s_imds_user_data_destroy(wrapped_user_data);
s_imds_provider_user_data_destroy(wrapped_user_data);
}

static void s_on_get_role(const struct aws_byte_buf *role, int error_code, void *user_data) {
struct imds_user_data *wrapped_user_data = user_data;
struct imds_provider_user_data *wrapped_user_data = user_data;
if (!role || error_code || role->len == 0) {
goto on_error;
}
Expand All @@ -181,7 +181,7 @@ static void s_on_get_role(const struct aws_byte_buf *role, int error_code, void
on_error:
wrapped_user_data->original_callback(
NULL, AWS_AUTH_CREDENTIALS_PROVIDER_IMDS_SOURCE_FAILURE, wrapped_user_data->original_user_data);
s_imds_user_data_destroy(wrapped_user_data);
s_imds_provider_user_data_destroy(wrapped_user_data);
}

static int s_credentials_provider_imds_get_credentials_async(
Expand All @@ -191,7 +191,7 @@ static int s_credentials_provider_imds_get_credentials_async(

struct aws_credentials_provider_imds_impl *impl = provider->impl;

struct imds_user_data *wrapped_user_data = s_imds_user_data_new(provider, callback, user_data);
struct imds_provider_user_data *wrapped_user_data = s_imds_provider_user_data_new(provider, callback, user_data);
if (wrapped_user_data == NULL) {
goto error;
}
Expand All @@ -203,6 +203,6 @@ static int s_credentials_provider_imds_get_credentials_async(
return AWS_OP_SUCCESS;

error:
s_imds_user_data_destroy(wrapped_user_data);
s_imds_provider_user_data_destroy(wrapped_user_data);
return AWS_OP_ERR;
}

0 comments on commit 0d82084

Please sign in to comment.