netlabel: remove redundant assignment to pointer iter
Subsystems (5)
PATCH 1/1 netlabel: remove redundant assignment to pointer iter
From: Colin Ian King <[email protected]>
Pointer iter is being initialized with a value that is never read and is being re-assigned a little later on. The assignment is redundant and hence can be removed.
Addresses-Coverity: ("Unused value")
--- net/netlabel/netlabel_kapi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/netlabel/netlabel_kapi.c +1 -1
@@ -607,7 +607,7 @@ static struct netlbl_lsm_catmap *_netlbl_catmap_getnode(*/ int netlbl_catmap_walk (struct netlbl_lsm_catmap *catmap,u32 offset) { -struct netlbl_lsm_catmap *iter = catmap; +struct netlbl_lsm_catmap *iter;u32 idx;u32 bit;NETLBL_CATMAP_MAPTYPE bitmap;
Signature · 1 line
2.20.1
Paul Moore
maintainerQuoted 11 lines · Colin King
From: Colin Ian King <[email protected]>
Pointer iter is being initialized with a value that is never read and is being re-assigned a little later on. The assignment is redundant and hence can be removed.
Addresses-Coverity: ("Unused value")
Signed-off-by Colin Ian King <[email protected]>--- net/netlabel/netlabel_kapi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
This patch doesn't seem correct to me, at least not in current form. At the top of _netlbl_catmap_getnode() is a check to see if iter is NULL (as well as a few other checks on iter after that); this patch would break that code.
Perhaps we can get rid of the iter/catmap assignment when we define iter, but I don't think this patch is the right way to do it.
Quoted 15 lines
net/netlabel/netlabel_kapi.c +1
-2@@ -607,7 +607,7 @@ static struct netlbl_lsm_catmap *_netlbl_catmap_getnode(*/ int netlbl_catmap_walk (struct netlbl_lsm_catmap *catmap,u32 offset) { -struct netlbl_lsm_catmap *iter = catmap; +struct netlbl_lsm_catmap *iter;u32 idx;u32 bit;NETLBL_CATMAP_MAPTYPE bitmap; --2.20.1
Signature · 2 lines
paul moore www.paul-moore.com
Le 01/09/2019 à 18:04, Paul Moore a écrit :
Quoted 20 lines · Colin King
Quoted 11 lines
From: Colin Ian King <[email protected]>
Pointer iter is being initialized with a value that is never read and is being re-assigned a little later on. The assignment is redundant and hence can be removed.
Addresses-Coverity: ("Unused value")
Signed-off-by Colin Ian King <[email protected]>--- net/netlabel/netlabel_kapi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)This patch doesn't seem correct to me, at least not in current form. At the top of
_netlbl_catmap_getnode()is a check to see if iter is NULL (as well as a few other checks on iter after that); this patch would break that code.Perhaps we can get rid of the iter/catmap assignment when we define iter, but I don't think this patch is the right way to do it.
Quoted 16 lines
Quoted 14 lines
net/netlabel/netlabel_kapi.c +1
-2@@ -607,7 +607,7 @@ static struct netlbl_lsm_catmap *_netlbl_catmap_getnode(*/ int netlbl_catmap_walk (struct netlbl_lsm_catmap *catmap,u32 offset) { -struct netlbl_lsm_catmap *iter = catmap; +struct netlbl_lsm_catmap *iter;u32 idx;u32 bit;NETLBL_CATMAP_MAPTYPE bitmap; --Quoted 1 line
2.20.1
Hi,
'iter' is reassigned a value between the declaration and the NULL test, so removing the first initialization looks good to me. int netlbl_catmap_walk(struct netlbl_lsm_catmap *catmap, u32 offset)
{
|
struct netlbl_lsm_catmap *iter = catmap;
u32 idx;
u32 bit;
NETLBL_CATMAP_MAPTYPE bitmap;
iter = _netlbl_catmap_getnode(&catmap, offset, _CM_F_WALK, 0); <-- Here
if (iter = NULL)
return -ENOENT; This is dead code since commit d960a6184a92 ("netlabel: fix the catmap walking functions") where the call to _netlbl_catmap_getnode has been introduced.Just my 2c,
CJ|
A message that is not in the archive (sent off-list or not yet received): [email protected]
Paul Moore
maintainerQuoted 40 lines · Christophe JAILLET
Le 01/09/2019 à 18:04, Paul Moore a écrit :
On Sun, Sep 1, 2019 at 11:52 AM Colin King <[email protected]> wrote:
From: Colin Ian King <[email protected]>
Pointer iter is being initialized with a value that is never read and is being re-assigned a little later on. The assignment is redundant and hence can be removed.
Addresses-Coverity: ("Unused value")
Signed-off-by Colin Ian King <[email protected]>--- net/netlabel/netlabel_kapi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)This patch doesn't seem correct to me, at least not in current form. At the top of
_netlbl_catmap_getnode()is a check to see if iter is NULL (as well as a few other checks on iter after that); this patch would break that code.Perhaps we can get rid of the iter/catmap assignment when we define iter, but I don't think this patch is the right way to do it.
net/netlabel/netlabel_kapi.c +1
-2@@ -607,7 +607,7 @@ static struct netlbl_lsm_catmap *_netlbl_catmap_getnode(*/ int netlbl_catmap_walk (struct netlbl_lsm_catmap *catmap,u32 offset) { -struct netlbl_lsm_catmap *iter = catmap; +struct netlbl_lsm_catmap *iter;u32 idx;u32 bit;NETLBL_CATMAP_MAPTYPE bitmap; --2.20.1
Quoted 1 line
'iter' is reassigned a value between the declaration and the NULL test, so removing the fist initialisation looks good to me.
This is what I get when I try to review patches quickly while doing other things on the weekend <sigh> ... yes, you are correct, I was looking at _netlbl_catmap_getnode() and not netlbl_catmap_walk(); my apologies.
Signature · 2 lines
paul moore www.paul-moore.com
Quoted 11 lines · Colin King
From: Colin Ian King <[email protected]>
Pointer iter is being initialized with a value that is never read and is being re-assigned a little later on. The assignment is redundant and hence can be removed.
Addresses-Coverity: ("Unused value")
Signed-off-by Colin Ian King <[email protected]>--- net/netlabel/netlabel_kapi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
Quoted 15 lines
net/netlabel/netlabel_kapi.c +1
-2@@ -607,7 +607,7 @@ static struct netlbl_lsm_catmap *_netlbl_catmap_getnode(*/ int netlbl_catmap_walk (struct netlbl_lsm_catmap *catmap,u32 offset) { -struct netlbl_lsm_catmap *iter = catmap; +struct netlbl_lsm_catmap *iter;u32 idx;u32 bit;NETLBL_CATMAP_MAPTYPE bitmap; --2.20.1
Signature · 2 lines
paul moore www.paul-moore.com
From: Colin King <[email protected]>
Date: Sun, 1 Sep 2019 16:52:05 +0100
Quoted 8 lines
From: Colin Ian King <[email protected]>
Pointer iter is being initialized with a value that is never read and is being re-assigned a little later on. The assignment is redundant and hence can be removed.
Addresses-Coverity: ("Unused value")
Signed-off-by Colin Ian King <[email protected]>
Applied to net-next.