diff mbox series

[v1] net: mctp: remove redundant RTN_UNICAST check

Message ID 20230615152240.1749428-1-linma@zju.edu.cn (mailing list archive)
State Accepted
Commit f60ce8a48b97eb970bfbec1f26c914b9017c4a46
Delegated to: Netdev Maintainers
Headers show
Series [v1] net: mctp: remove redundant RTN_UNICAST check | expand

Checks

Context Check Description
netdev/series_format warning Single patches do not need cover letters; Target tree name not specified in the subject
netdev/tree_selection success Guessed tree name to be net-next
netdev/fixes_present success Fixes tag not required for -next series
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 12 this patch: 12
netdev/cc_maintainers warning 1 maintainers not CCed: pabeni@redhat.com
netdev/build_clang success Errors and warnings before: 8 this patch: 8
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/deprecated_api success None detected
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success Fixes tag looks correct
netdev/build_allmodconfig_warn success Errors and warnings before: 12 this patch: 12
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 9 lines checked
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0

Commit Message

Lin Ma June 15, 2023, 3:22 p.m. UTC
Current mctp_newroute() contains two exactly same check against
rtm->rtm_type

static int mctp_newroute(...)
{
...
    if (rtm->rtm_type != RTN_UNICAST) { // (1)
        NL_SET_ERR_MSG(extack, "rtm_type must be RTN_UNICAST");
        return -EINVAL;
    }
...
    if (rtm->rtm_type != RTN_UNICAST) // (2)
        return -EINVAL;
...
}

This commits removes the (2) check as it is redundant.

Fixes: 83f0a0b7285b ("mctp: Specify route types, require rtm_type in RTM_*ROUTE messages")
Signed-off-by: Lin Ma <linma@zju.edu.cn>
---
 net/mctp/route.c | 3 ---
 1 file changed, 3 deletions(-)

Comments

Pavan Chebbi June 16, 2023, 10:13 a.m. UTC | #1
On Thu, Jun 15, 2023 at 8:53 PM Lin Ma <linma@zju.edu.cn> wrote:
>
> Current mctp_newroute() contains two exactly same check against
> rtm->rtm_type
>
> static int mctp_newroute(...)
> {
> ...
>     if (rtm->rtm_type != RTN_UNICAST) { // (1)
>         NL_SET_ERR_MSG(extack, "rtm_type must be RTN_UNICAST");
>         return -EINVAL;
>     }
> ...
>     if (rtm->rtm_type != RTN_UNICAST) // (2)
>         return -EINVAL;
> ...
> }
>
> This commits removes the (2) check as it is redundant.
>
> Fixes: 83f0a0b7285b ("mctp: Specify route types, require rtm_type in RTM_*ROUTE messages")
> Signed-off-by: Lin Ma <linma@zju.edu.cn>
> ---

Reviewed-by: Pavan Chebbi <pavan.chebbi@broadcom.com>

>  net/mctp/route.c | 3 ---
>  1 file changed, 3 deletions(-)
>
> diff --git a/net/mctp/route.c b/net/mctp/route.c
> index f51a05ec7162..ab62fe447038 100644
> --- a/net/mctp/route.c
> +++ b/net/mctp/route.c
> @@ -1249,9 +1249,6 @@ static int mctp_newroute(struct sk_buff *skb, struct nlmsghdr *nlh,
>                         mtu = nla_get_u32(tbx[RTAX_MTU]);
>         }
>
> -       if (rtm->rtm_type != RTN_UNICAST)
> -               return -EINVAL;
> -
>         rc = mctp_route_add(mdev, daddr_start, rtm->rtm_dst_len, mtu,
>                             rtm->rtm_type);
>         return rc;
> --
> 2.17.1
>
>
Jeremy Kerr June 17, 2023, 2:49 a.m. UTC | #2
Hi Lin,

> Current mctp_newroute() contains two exactly same check against
> rtm->rtm_type
> 
> static int mctp_newroute(...)
> {
> ...
>     if (rtm->rtm_type != RTN_UNICAST) { // (1)
>         NL_SET_ERR_MSG(extack, "rtm_type must be RTN_UNICAST");
>         return -EINVAL;
>     }
> ...
>     if (rtm->rtm_type != RTN_UNICAST) // (2)
>         return -EINVAL;
> ...
> }
> 
> This commits removes the (2) check as it is redundant.

Looks good, thanks!

Acked-by: Jeremy Kerr <jk@codeconstruct.com.au>

(but this probably doesn't need to go into the net fixes tree; net-next
would be fine.)

Cheers,


Jeremy
patchwork-bot+netdevbpf@kernel.org June 17, 2023, 7:30 a.m. UTC | #3
Hello:

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

On Thu, 15 Jun 2023 23:22:40 +0800 you wrote:
> Current mctp_newroute() contains two exactly same check against
> rtm->rtm_type
> 
> static int mctp_newroute(...)
> {
> ...
>     if (rtm->rtm_type != RTN_UNICAST) { // (1)
>         NL_SET_ERR_MSG(extack, "rtm_type must be RTN_UNICAST");
>         return -EINVAL;
>     }
> ...
>     if (rtm->rtm_type != RTN_UNICAST) // (2)
>         return -EINVAL;
> ...
> }
> 
> [...]

Here is the summary with links:
  - [v1] net: mctp: remove redundant RTN_UNICAST check
    https://git.kernel.org/netdev/net-next/c/f60ce8a48b97

You are awesome, thank you!
diff mbox series

Patch

diff --git a/net/mctp/route.c b/net/mctp/route.c
index f51a05ec7162..ab62fe447038 100644
--- a/net/mctp/route.c
+++ b/net/mctp/route.c
@@ -1249,9 +1249,6 @@  static int mctp_newroute(struct sk_buff *skb, struct nlmsghdr *nlh,
 			mtu = nla_get_u32(tbx[RTAX_MTU]);
 	}
 
-	if (rtm->rtm_type != RTN_UNICAST)
-		return -EINVAL;
-
 	rc = mctp_route_add(mdev, daddr_start, rtm->rtm_dst_len, mtu,
 			    rtm->rtm_type);
 	return rc;