* [PATCH BlueZ v2] mesh: Fix check for mkdir return value in keyring.c
@ 2020-11-29 6:22 Inga Stotland
2020-11-29 6:32 ` [BlueZ,v2] " bluez.test.bot
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Inga Stotland @ 2020-11-29 6:22 UTC (permalink / raw)
To: linux-bluetooth; +Cc: brian.gix, sbrown, Inga Stotland
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,
--
2.26.2
^ permalink raw reply related [flat|nested] 4+ messages in thread
* RE: [BlueZ,v2] mesh: Fix check for mkdir return value in keyring.c
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.test.bot
2020-11-29 9:44 ` [PATCH BlueZ v2] " Steve Brown
2020-12-04 18:12 ` Gix, Brian
2 siblings, 0 replies; 4+ messages in thread
From: bluez.test.bot @ 2020-11-29 6:32 UTC (permalink / raw)
To: linux-bluetooth, inga.stotland
[-- Attachment #1: Type: text/plain, Size: 557 bytes --]
This is automated email and please do not reply to this email!
Dear submitter,
Thank you for submitting the patches to the linux bluetooth mailing list.
This is a CI test results with your patch series:
PW Link:https://patchwork.kernel.org/project/bluetooth/list/?series=392799
---Test result---
##############################
Test: CheckPatch - PASS
##############################
Test: CheckGitLint - PASS
##############################
Test: CheckBuild - PASS
##############################
Test: MakeCheck - PASS
---
Regards,
Linux Bluetooth
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH BlueZ v2] mesh: Fix check for mkdir return value in keyring.c
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
2020-12-04 18:12 ` Gix, Brian
2 siblings, 0 replies; 4+ messages in thread
From: Steve Brown @ 2020-11-29 9:44 UTC (permalink / raw)
To: Inga Stotland, linux-bluetooth; +Cc: brian.gix
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,
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH BlueZ v2] mesh: Fix check for mkdir return value in keyring.c
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
2 siblings, 0 replies; 4+ messages in thread
From: Gix, Brian @ 2020-12-04 18:12 UTC (permalink / raw)
To: linux-bluetooth, Stotland, Inga; +Cc: sbrown
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,
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2020-12-04 18:13 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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 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.