diff mbox series

[net-next] netlabel: remove impossible return value in netlbl_bitmap_walk

Message ID 20240227093604.3574241-1-shaozhengchao@huawei.com (mailing list archive)
State Handled Elsewhere
Delegated to: Paul Moore
Headers show
Series [net-next] netlabel: remove impossible return value in netlbl_bitmap_walk | expand

Commit Message

Zhengchao Shao Feb. 27, 2024, 9:36 a.m. UTC
Since commit 446fda4f2682 ("[NetLabel]: CIPSOv4 engine"), *bitmap_walk
function only returns -1. Nearly 18 years have passed, -2 scenes never
come up, so there's no need to consider it.

Signed-off-by: Zhengchao Shao <shaozhengchao@huawei.com>
---
 net/ipv4/cipso_ipv4.c        | 5 +----
 net/ipv6/calipso.c           | 5 +----
 net/netlabel/netlabel_kapi.c | 2 +-
 3 files changed, 3 insertions(+), 9 deletions(-)

Comments

Jiri Pirko Feb. 27, 2024, 12:35 p.m. UTC | #1
Tue, Feb 27, 2024 at 10:36:04AM CET, shaozhengchao@huawei.com wrote:
>Since commit 446fda4f2682 ("[NetLabel]: CIPSOv4 engine"), *bitmap_walk
>function only returns -1. Nearly 18 years have passed, -2 scenes never
>come up, so there's no need to consider it.
>
>Signed-off-by: Zhengchao Shao <shaozhengchao@huawei.com>

Reviewed-by: Jiri Pirko <jiri@nvidia.com>
Paul Moore Feb. 27, 2024, 3:54 p.m. UTC | #2
On Tue, Feb 27, 2024 at 4:28 AM Zhengchao Shao <shaozhengchao@huawei.com> wrote:
>
> Since commit 446fda4f2682 ("[NetLabel]: CIPSOv4 engine"), *bitmap_walk
> function only returns -1. Nearly 18 years have passed, -2 scenes never
> come up, so there's no need to consider it.
>
> Signed-off-by: Zhengchao Shao <shaozhengchao@huawei.com>
> ---
>  net/ipv4/cipso_ipv4.c        | 5 +----
>  net/ipv6/calipso.c           | 5 +----
>  net/netlabel/netlabel_kapi.c | 2 +-
>  3 files changed, 3 insertions(+), 9 deletions(-)

Looks good to me, thanks for the patch.

Acked-by: Paul Moore <paul@paul-moore.com>
patchwork-bot+netdevbpf@kernel.org Feb. 29, 2024, 3:50 a.m. UTC | #3
Hello:

This patch was applied to netdev/net-next.git (main)
by Jakub Kicinski <kuba@kernel.org>:

On Tue, 27 Feb 2024 17:36:04 +0800 you wrote:
> Since commit 446fda4f2682 ("[NetLabel]: CIPSOv4 engine"), *bitmap_walk
> function only returns -1. Nearly 18 years have passed, -2 scenes never
> come up, so there's no need to consider it.
> 
> Signed-off-by: Zhengchao Shao <shaozhengchao@huawei.com>
> ---
>  net/ipv4/cipso_ipv4.c        | 5 +----
>  net/ipv6/calipso.c           | 5 +----
>  net/netlabel/netlabel_kapi.c | 2 +-
>  3 files changed, 3 insertions(+), 9 deletions(-)

Here is the summary with links:
  - [net-next] netlabel: remove impossible return value in netlbl_bitmap_walk
    https://git.kernel.org/netdev/net-next/c/9ff74d77180a

You are awesome, thank you!
diff mbox series

Patch

diff --git a/net/ipv4/cipso_ipv4.c b/net/ipv4/cipso_ipv4.c
index d048aa833293..8b17d83e5fde 100644
--- a/net/ipv4/cipso_ipv4.c
+++ b/net/ipv4/cipso_ipv4.c
@@ -864,11 +864,8 @@  static int cipso_v4_map_cat_rbm_ntoh(const struct cipso_v4_doi *doi_def,
 					      net_clen_bits,
 					      net_spot + 1,
 					      1);
-		if (net_spot < 0) {
-			if (net_spot == -2)
-				return -EFAULT;
+		if (net_spot < 0)
 			return 0;
-		}
 
 		switch (doi_def->type) {
 		case CIPSO_V4_MAP_PASS:
diff --git a/net/ipv6/calipso.c b/net/ipv6/calipso.c
index 1578ed9e97d8..eb8ee1e9373a 100644
--- a/net/ipv6/calipso.c
+++ b/net/ipv6/calipso.c
@@ -657,11 +657,8 @@  static int calipso_map_cat_ntoh(const struct calipso_doi *doi_def,
 					  net_clen_bits,
 					  spot + 1,
 					  1);
-		if (spot < 0) {
-			if (spot == -2)
-				return -EFAULT;
+		if (spot < 0)
 			return 0;
-		}
 
 		ret_val = netlbl_catmap_setbit(&secattr->attr.mls.cat,
 					       spot,
diff --git a/net/netlabel/netlabel_kapi.c b/net/netlabel/netlabel_kapi.c
index 7b844581ebee..1ba4f58e1d35 100644
--- a/net/netlabel/netlabel_kapi.c
+++ b/net/netlabel/netlabel_kapi.c
@@ -876,7 +876,7 @@  int netlbl_catmap_setlong(struct netlbl_lsm_catmap **catmap,
  * Description:
  * Starting at @offset, walk the bitmap from left to right until either the
  * desired bit is found or we reach the end.  Return the bit offset, -1 if
- * not found, or -2 if error.
+ * not found.
  */
 int netlbl_bitmap_walk(const unsigned char *bitmap, u32 bitmap_len,
 		       u32 offset, u8 state)