All of lore.kernel.org
 help / color / mirror / Atom feed
From: Steve Brown <sbrown@ewol.com>
To: Inga Stotland <inga.stotland@intel.com>, linux-bluetooth@vger.kernel.org
Cc: brian.gix@intel.com
Subject: Re: [PATCH BlueZ v2] mesh: Fix check for mkdir return value in keyring.c
Date: Sun, 29 Nov 2020 04:44:14 -0500	[thread overview]
Message-ID: <e0c8edbb7b44aaea6d2779eac526c9a7b977f958.camel@ewol.com> (raw)
In-Reply-To: <20201129062202.91034-1-inga.stotland@intel.com>

Hi Inga,

Patch works for me.

Thanks,

Steve

On Sat, 2020-11-28 at 22:22 -0800, Inga Stotland wrote:
> Remove check for mkdir() return value, since checking for zero does
> not
> cover "already exists" condition and adding extra check for errno
> value
> unnecessarily complicates the code. If mkdir() fails due to any
> reason
> than "already exists", the subsequent call to open() fails and the
> error is detected and corectly processed by the code.
> ---
>  mesh/keyring.c | 9 +++------
>  1 file changed, 3 insertions(+), 6 deletions(-)
> 
> diff --git a/mesh/keyring.c b/mesh/keyring.c
> index 1ef4fc3ef..0b74ee914 100644
> --- a/mesh/keyring.c
> +++ b/mesh/keyring.c
> @@ -51,8 +51,7 @@ bool keyring_put_net_key(struct mesh_node *node,
> uint16_t net_idx,
>  
>         snprintf(key_file, PATH_MAX, "%s%s", node_path, net_key_dir);
>  
> -       if (!mkdir(key_file, 0755))
> -               return false;
> +       mkdir(key_file, 0755);
>  
>         snprintf(key_file, PATH_MAX, "%s%s/%3.3x", node_path,
> net_key_dir,
>                                                                 net_i
> dx);
> @@ -88,8 +87,7 @@ bool keyring_put_app_key(struct mesh_node *node,
> uint16_t app_idx,
>  
>         snprintf(key_file, PATH_MAX, "%s%s", node_path, app_key_dir);
>  
> -       if (!mkdir(key_file, 0755))
> -               return false;
> +       mkdir(key_file, 0755);
>  
>         snprintf(key_file, PATH_MAX, "%s%s/%3.3x", node_path,
> app_key_dir,
>                                                                 app_i
> dx);
> @@ -207,8 +205,7 @@ bool keyring_put_remote_dev_key(struct mesh_node
> *node, uint16_t unicast,
>  
>         snprintf(key_file, PATH_MAX, "%s%s", node_path, dev_key_dir);
>  
> -       if (!mkdir(key_file, 0755))
> -               return false;
> +       mkdir(key_file, 0755);
>  
>         for (i = 0; i < count; i++) {
>                 snprintf(key_file, PATH_MAX, "%s%s/%4.4x", node_path,



  parent reply	other threads:[~2020-11-29  9:46 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-11-29  6:22 [PATCH BlueZ v2] mesh: Fix check for mkdir return value in keyring.c Inga Stotland
2020-11-29  6:32 ` [BlueZ,v2] " bluez.test.bot
2020-11-29  9:44 ` Steve Brown [this message]
2020-12-04 18:12 ` [PATCH BlueZ v2] " Gix, Brian

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=e0c8edbb7b44aaea6d2779eac526c9a7b977f958.camel@ewol.com \
    --to=sbrown@ewol.com \
    --cc=brian.gix@intel.com \
    --cc=inga.stotland@intel.com \
    --cc=linux-bluetooth@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.