[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

Re: [virt-tools-list] [libosinfo v2 2/3] install_script: add get_config_param function



On Thu, Oct 4, 2012 at 8:06 AM, Fabiano Fidêncio <fabiano fidencio org> wrote:
> Return, if exists, the sought OsinfoInstallConfigParam from an
> OsinfoInstallScript. Otherwise, NULL is returned.
> ---
>  osinfo/libosinfo.syms          |  1 +
>  osinfo/osinfo_install_script.c | 33 +++++++++++++++++++++++++++++++++
>  osinfo/osinfo_install_script.h |  2 ++
>  3 files changed, 36 insertions(+)
>
> diff --git a/osinfo/libosinfo.syms b/osinfo/libosinfo.syms
> index 772e89c..df76108 100644
> --- a/osinfo/libosinfo.syms
> +++ b/osinfo/libosinfo.syms
> @@ -309,6 +309,7 @@ LIBOSINFO_0.2.1 {
>         osinfo_entity_get_param_value_int64_with_default;
>         osinfo_entity_set_param_int64;
>         osinfo_install_script_get_expected_filename;
> +       osinfo_install_script_get_config_param;
>  } LIBOSINFO_0.2.0;
>
>  /* Symbols in next release...
> diff --git a/osinfo/osinfo_install_script.c b/osinfo/osinfo_install_script.c
> index c9e2024..aaef08c 100644
> --- a/osinfo/osinfo_install_script.c
> +++ b/osinfo/osinfo_install_script.c
> @@ -264,6 +264,39 @@ GList *osinfo_install_script_get_config_param_list(const OsinfoInstallScript *sc
>      return g_list_copy(script->priv->config_param_list);
>  }
>
> +/**
> + * osinfo_install_script_get_config_param:
> + *
> + * Get a config param from the config param's list
> + *
> + * Returns: (transfer full): the sought config param, if exists.
> + *                           NULL otherwise.
> + */
> +OsinfoInstallConfigParam *osinfo_install_script_get_config_param(const OsinfoInstallScript *script, const gchar *name)

coding-style: Does this line fit in 80 chars?

> +{
> +    GList *l;
> +
> +    for (l = script->priv->config_param_list; l != NULL; l = l->next)
> +    {

Another one: '{' on the previous line.

> +        OsinfoInstallConfigParam *tmp = l->data;
> +        const gchar *param_name = osinfo_install_config_param_get_name(tmp);
> +
> +        if (g_strcmp0(param_name, name) == 0) {
> +            const gchar *param_policy;
> +            OsinfoInstallConfigParamPolicy policy =
> +                osinfo_install_config_param_get_policy(tmp);
> +
> +            if (policy == OSINFO_INSTALL_CONFIG_PARAM_POLICY_REQUIRED)
> +                param_policy = "required";
> +            else if (policy == OSINFO_INSTALL_CONFIG_PARAM_POLICY_OPTIONAL)
> +                param_policy = "optional";
> +
> +            return osinfo_install_config_param_new(param_name, param_policy);

there is no need to create another instance, just return a new ref
(using g_object_ref).


-- 
Regards,

Zeeshan Ali (Khattak)
FSF member#5124


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]