diff mbox series

net: sched: Fix restricted __be16 degrades to integer

Message ID 20231117101815.1867175-1-chentao@kylinos.cn (mailing list archive)
State Changes Requested
Delegated to: Netdev Maintainers
Headers show
Series net: sched: Fix restricted __be16 degrades to integer | 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: 1136 this patch: 1134
netdev/cc_maintainers success CCed 7 of 7 maintainers
netdev/build_clang success Errors and warnings before: 1155 this patch: 1155
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 No Fixes tag
netdev/build_allmodconfig_warn success Errors and warnings before: 1163 this patch: 1161
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 16 lines checked
netdev/build_clang_rust success No Rust files in patch. Skipping build
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0

Commit Message

Kunwu Nov. 17, 2023, 10:18 a.m. UTC
net/sched/cls_api.c:2010:25: warning: restricted __be16 degrades to integer
net/sched/cls_api.c:2695:50: warning: restricted __be16 degrades to integer

Signed-off-by: Kunwu Chan <chentao@kylinos.cn>
---
 net/sched/cls_api.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Pedro Tammela Nov. 17, 2023, 12:06 p.m. UTC | #1
On 17/11/2023 07:18, Kunwu Chan wrote:
> net/sched/cls_api.c:2010:25: warning: restricted __be16 degrades to integer
> net/sched/cls_api.c:2695:50: warning: restricted __be16 degrades to integer
> 
> Signed-off-by: Kunwu Chan <chentao@kylinos.cn>
> ---
>   net/sched/cls_api.c | 4 ++--
>   1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/net/sched/cls_api.c b/net/sched/cls_api.c
> index f73f39f61f66..4c47490eb0c1 100644
> --- a/net/sched/cls_api.c
> +++ b/net/sched/cls_api.c
> @@ -2007,7 +2007,7 @@ static int tcf_fill_node(struct net *net, struct sk_buff *skb,
>   		tcm->tcm_ifindex = TCM_IFINDEX_MAGIC_BLOCK;
>   		tcm->tcm_block_index = block->index;
>   	}
> -	tcm->tcm_info = TC_H_MAKE(tp->prio, tp->protocol);
> +	tcm->tcm_info = TC_H_MAKE(tp->prio, be16_to_cpu(tp->protocol));
>   	if (nla_put_string(skb, TCA_KIND, tp->ops->kind))
>   		goto nla_put_failure;
>   	if (nla_put_u32(skb, TCA_CHAIN, tp->chain->index))
> @@ -2692,7 +2692,7 @@ static bool tcf_chain_dump(struct tcf_chain *chain, struct Qdisc *q, u32 parent,
>   		    TC_H_MAJ(tcm->tcm_info) != tp->prio)
>   			continue;
>   		if (TC_H_MIN(tcm->tcm_info) &&
> -		    TC_H_MIN(tcm->tcm_info) != tp->protocol)
> +		    TC_H_MIN(tcm->tcm_info) != be16_to_cpu(tp->protocol))
>   			continue;
>   		if (*p_index > index_start)
>   			memset(&cb->args[1], 0,

I don't believe there's something to fix here
Simon Horman Nov. 20, 2023, 10:07 a.m. UTC | #2
On Fri, Nov 17, 2023 at 09:06:11AM -0300, Pedro Tammela wrote:
> On 17/11/2023 07:18, Kunwu Chan wrote:
> > net/sched/cls_api.c:2010:25: warning: restricted __be16 degrades to integer
> > net/sched/cls_api.c:2695:50: warning: restricted __be16 degrades to integer
> > 
> > Signed-off-by: Kunwu Chan <chentao@kylinos.cn>
> > ---
> >   net/sched/cls_api.c | 4 ++--
> >   1 file changed, 2 insertions(+), 2 deletions(-)
> > 
> > diff --git a/net/sched/cls_api.c b/net/sched/cls_api.c
> > index f73f39f61f66..4c47490eb0c1 100644
> > --- a/net/sched/cls_api.c
> > +++ b/net/sched/cls_api.c
> > @@ -2007,7 +2007,7 @@ static int tcf_fill_node(struct net *net, struct sk_buff *skb,
> >   		tcm->tcm_ifindex = TCM_IFINDEX_MAGIC_BLOCK;
> >   		tcm->tcm_block_index = block->index;
> >   	}
> > -	tcm->tcm_info = TC_H_MAKE(tp->prio, tp->protocol);
> > +	tcm->tcm_info = TC_H_MAKE(tp->prio, be16_to_cpu(tp->protocol));
> >   	if (nla_put_string(skb, TCA_KIND, tp->ops->kind))
> >   		goto nla_put_failure;
> >   	if (nla_put_u32(skb, TCA_CHAIN, tp->chain->index))
> > @@ -2692,7 +2692,7 @@ static bool tcf_chain_dump(struct tcf_chain *chain, struct Qdisc *q, u32 parent,
> >   		    TC_H_MAJ(tcm->tcm_info) != tp->prio)
> >   			continue;
> >   		if (TC_H_MIN(tcm->tcm_info) &&
> > -		    TC_H_MIN(tcm->tcm_info) != tp->protocol)
> > +		    TC_H_MIN(tcm->tcm_info) != be16_to_cpu(tp->protocol))
> >   			continue;
> >   		if (*p_index > index_start)
> >   			memset(&cb->args[1], 0,
> 
> I don't believe there's something to fix here

Hi,

as there are two patches addressing similar problems let's discuss
an appropriate approach (or not) in one place. I'd like to suggest here:

Link: https://lore.kernel.org/netdev/20231120100417.GM186930@vergenet.net/
diff mbox series

Patch

diff --git a/net/sched/cls_api.c b/net/sched/cls_api.c
index f73f39f61f66..4c47490eb0c1 100644
--- a/net/sched/cls_api.c
+++ b/net/sched/cls_api.c
@@ -2007,7 +2007,7 @@  static int tcf_fill_node(struct net *net, struct sk_buff *skb,
 		tcm->tcm_ifindex = TCM_IFINDEX_MAGIC_BLOCK;
 		tcm->tcm_block_index = block->index;
 	}
-	tcm->tcm_info = TC_H_MAKE(tp->prio, tp->protocol);
+	tcm->tcm_info = TC_H_MAKE(tp->prio, be16_to_cpu(tp->protocol));
 	if (nla_put_string(skb, TCA_KIND, tp->ops->kind))
 		goto nla_put_failure;
 	if (nla_put_u32(skb, TCA_CHAIN, tp->chain->index))
@@ -2692,7 +2692,7 @@  static bool tcf_chain_dump(struct tcf_chain *chain, struct Qdisc *q, u32 parent,
 		    TC_H_MAJ(tcm->tcm_info) != tp->prio)
 			continue;
 		if (TC_H_MIN(tcm->tcm_info) &&
-		    TC_H_MIN(tcm->tcm_info) != tp->protocol)
+		    TC_H_MIN(tcm->tcm_info) != be16_to_cpu(tp->protocol))
 			continue;
 		if (*p_index > index_start)
 			memset(&cb->args[1], 0,