[PATCH v2] qmicli, wds: only need to initialize enum member fields in struct
Dan Williams
dcbw at redhat.com
Tue Mar 21 20:40:05 UTC 2017
On Tue, 2017-03-21 at 20:57 +0100, Aleksander Morgado wrote:
> When doing member initializations when the struct variable is
> declared, only initialize the enum fields to valid enum values, the
> remaining fields will be initialized to zero.
>
> This is a different approach to the fix done in 4c678418.
>
LGTM.
Dan
> ---
>
> Hey Dan,
>
> Cleaner this way? In git master we also have
> QMI_WDS_IP_FAMILY_UNKNOWN (value 0), not sure if that would matter
> much as long as we use enums consistently.
>
> ---
> src/qmicli/qmicli-wds.c | 11 +++--------
> 1 file changed, 3 insertions(+), 8 deletions(-)
>
> diff --git a/src/qmicli/qmicli-wds.c b/src/qmicli/qmicli-wds.c
> index 75d7992..fcc5b49 100644
> --- a/src/qmicli/qmicli-wds.c
> +++ b/src/qmicli/qmicli-wds.c
> @@ -439,7 +439,7 @@ start_network_properties_handle (const
> gchar *key,
> return TRUE;
> }
>
> - if (g_ascii_strcasecmp (key, "ip-type") == 0 && props->ip_type
> == 0) {
> + if (g_ascii_strcasecmp (key, "ip-type") == 0 && props->ip_type
> == QMI_WDS_IP_FAMILY_UNSPECIFIED) {
> switch (atoi (value)) {
> case 4:
> props->ip_type = QMI_WDS_IP_FAMILY_IPV4;
> @@ -474,13 +474,8 @@ start_network_input_create (const gchar *str)
> gchar **split = NULL;
> QmiMessageWdsStartNetworkInput *input = NULL;
> StartNetworkProperties props = {
> - .apn = NULL,
> - .profile_index_3gpp = 0,
> - .profile_index_3gpp2 = 0,
> - .auth = QMI_WDS_AUTHENTICATION_NONE,
> - .auth_set = FALSE,
> - .username = NULL,
> - .password = NULL,
> + .auth = QMI_WDS_AUTHENTICATION_NONE,
> + .ip_type = QMI_WDS_IP_FAMILY_UNSPECIFIED,
> };
>
> /* An empty string is totally valid (i.e. no TLVs) */
> --
> 2.12.0
> _______________________________________________
> libqmi-devel mailing list
> libqmi-devel at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/libqmi-devel
More information about the libqmi-devel
mailing list