Re: [PATCH BlueZ 1/4] shared/shell: Don't allocate any data if env value is NULL

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

 



Hi,

On Mon, Mar 26, 2018 at 4:33 PM, Luiz Augusto von Dentz
<luiz.dentz@xxxxxxxxx> wrote:
> From: Luiz Augusto von Dentz <luiz.von.dentz@xxxxxxxxx>
>
> If value is NULL there is no point in allocating any data if value is
> NULL since bt_shell_get_env would return NULL anyway, also this makes
> sure the existing value is freed which means passing NULL can remove
> an env like it was intended.
> ---
>  src/shared/shell.c | 6 ++++++
>  1 file changed, 6 insertions(+)
>
> diff --git a/src/shared/shell.c b/src/shared/shell.c
> index 33bc0d980..241878b30 100644
> --- a/src/shared/shell.c
> +++ b/src/shared/shell.c
> @@ -1142,6 +1142,8 @@ void bt_shell_set_env(const char *name, void *value)
>         struct bt_shell_env *env;
>
>         if (!data.envs) {
> +               if (!value)
> +                       return;
>                 data.envs = queue_new();
>                 goto done;
>         }
> @@ -1150,6 +1152,10 @@ void bt_shell_set_env(const char *name, void *value)
>         if (env)
>                 env_destroy(env);
>
> +       /* Don't create an env if value is not set */
> +       if (!value)
> +               return;
> +
>  done:
>         env = new0(struct bt_shell_env, 1);
>         env->name = strdup(name);
> --
> 2.14.3

Applied.


-- 
Luiz Augusto von Dentz
--
To unsubscribe from this list: send the line "unsubscribe linux-bluetooth" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Bluez Devel]     [Linux Wireless Networking]     [Linux Wireless Personal Area Networking]     [Linux ATH6KL]     [Linux USB Devel]     [Linux Media Drivers]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Big List of Linux Books]

  Powered by Linux