From: "Gix, Brian" <brian.gix@intel.com>
To: "linux-bluetooth@vger.kernel.org"
	<linux-bluetooth@vger.kernel.org>,
	"Stotland, Inga" <inga.stotland@intel.com>
Cc: "sbrown@ewol.com" <sbrown@ewol.com>
Subject: Re: [PATCH BlueZ v2] mesh: Fix check for mkdir return value in keyring.c
Date: Fri, 4 Dec 2020 18:12:07 +0000	[thread overview]
Message-ID: <809803bcf078ad9ba9fd196a805515a9b7539fab.camel@intel.com> (raw)
In-Reply-To: <20201129062202.91034-1-inga.stotland@intel.com>
Applied
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_idx);
> @@ -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_idx);
> @@ -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,
     prev parent reply	other threads:[~2020-12-04 18:13 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 ` [PATCH BlueZ v2] " Steve Brown
2020-12-04 18:12 ` Gix, Brian [this message]
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=809803bcf078ad9ba9fd196a805515a9b7539fab.camel@intel.com \
    --to=brian.gix@intel.com \
    --cc=inga.stotland@intel.com \
    --cc=linux-bluetooth@vger.kernel.org \
    --cc=sbrown@ewol.com \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).