Message ID | 20200806142108.32664-1-michal.lowas-rzechonek@silvair.com (mailing list archive) |
---|---|
State | Accepted |
Headers | show |
Series | [BlueZ] mesh: Allow deleting non-existing net key | expand |
Applied On Thu, 2020-08-06 at 16:21 +0200, Michał Lowas-Rzechonek wrote: > When deleting a non-existing key, first check that it doesn't exist (and > return success), then verify it's not the last key we have. > --- > mesh/net.c | 8 ++++---- > 1 file changed, 4 insertions(+), 4 deletions(-) > > diff --git a/mesh/net.c b/mesh/net.c > index 7cc75ce42..b044d7fe0 100644 > --- a/mesh/net.c > +++ b/mesh/net.c > @@ -789,15 +789,15 @@ int mesh_net_del_key(struct mesh_net *net, uint16_t idx) > if (!net) > return MESH_STATUS_UNSPECIFIED_ERROR; > > - /* Cannot remove primary key */ > - if (l_queue_length(net->subnets) <= 1) > - return MESH_STATUS_CANNOT_REMOVE; > - > subnet = l_queue_find(net->subnets, match_key_index, > L_UINT_TO_PTR(idx)); > if (!subnet) > return MESH_STATUS_SUCCESS; > > + /* Cannot remove primary key */ > + if (l_queue_length(net->subnets) <= 1) > + return MESH_STATUS_CANNOT_REMOVE; > + > /* Delete associated app keys */ > appkey_delete_bound_keys(net, idx); >
diff --git a/mesh/net.c b/mesh/net.c index 7cc75ce42..b044d7fe0 100644 --- a/mesh/net.c +++ b/mesh/net.c @@ -789,15 +789,15 @@ int mesh_net_del_key(struct mesh_net *net, uint16_t idx) if (!net) return MESH_STATUS_UNSPECIFIED_ERROR; - /* Cannot remove primary key */ - if (l_queue_length(net->subnets) <= 1) - return MESH_STATUS_CANNOT_REMOVE; - subnet = l_queue_find(net->subnets, match_key_index, L_UINT_TO_PTR(idx)); if (!subnet) return MESH_STATUS_SUCCESS; + /* Cannot remove primary key */ + if (l_queue_length(net->subnets) <= 1) + return MESH_STATUS_CANNOT_REMOVE; + /* Delete associated app keys */ appkey_delete_bound_keys(net, idx);