Skip to content

add initializer for device props #2392

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

Merged

Conversation

danewalton-msft
Copy link
Member

No description provided.

adu_device_properties.manufacturer = AZ_SPAN_FROM_STR(TEST_ADU_DEVICE_MANUFACTURER);
adu_device_properties.model = AZ_SPAN_FROM_STR(TEST_ADU_DEVICE_MODEL);
adu_device_properties.adu_version = AZ_SPAN_FROM_STR(TEST_AZ_IOT_ADU_CLIENT_AGENT_VERSION);
adu_device_properties.delivery_optimization_agent_version = AZ_SPAN_EMPTY;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be AZ_SPAN_LITERAL_EMPTY? Looks like that's what it used to be and what we set it to in the device_properties_default

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The _LITERAL variants of span initializers are used for setting values in struct literals. So anything with some

my_struct = { .myvalue = blah };

kind of initialization.

For assigning individual values of a struct, we can set using the non-literal version which adds a cast to that value.

*
* @return #az_iot_adu_client_device_properties.
*/
AZ_NODISCARD az_iot_adu_client_device_properties az_iot_adu_client_device_properties_default();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit - since this is not an "options" it should be named az_iot_adu_client_device_properties_init similar to az_iot_message_properties_init.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think here it should be _default(). The _init() is used to initialize a struct with parameters/values which from then on become private fields of the initialized struct. The interactions on that initialized struct are more or less as though it were an object.

Here, we're giving people a preconfigured default struct which they then directly act on. Thoughts?

@danewalton-msft danewalton-msft merged commit ad98ddf into Azure:feature/iot-adu Nov 4, 2022
@danewalton-msft danewalton-msft deleted the dane/initprops branch November 4, 2022 00:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants