mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Edward Cree <ecree@solarflare.com>
To: Nicholas Mc Guire <hofrat@osadl.org>,
	Jamal Hadi Salim <jhs@mojatatu.com>
Cc: Cong Wang <xiyou.wangcong@gmail.com>,
	Jiri Pirko <jiri@resnulli.us>,
	"David S. Miller" <davem@davemloft.net>, <netdev@vger.kernel.org>,
	<linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] net_sched: force endianness annotation
Date: Mon, 29 Apr 2019 11:11:20 +0100	[thread overview]
Message-ID: <07d36e94-aad4-a263-bf09-705ee1dd59ed@solarflare.com> (raw)
In-Reply-To: <1556430899-11018-1-git-send-email-hofrat@osadl.org>

On 28/04/2019 06:54, Nicholas Mc Guire wrote:
> While the endiannes is being handled correctly sparse was unhappy with
> the missing annotation as be16_to_cpu()/be32_to_cpu() expects a __be16
> respectively __be32.
[...]
> diff --git a/net/sched/em_cmp.c b/net/sched/em_cmp.c
> index 1c8360a..3045ee1 100644
> --- a/net/sched/em_cmp.c
> +++ b/net/sched/em_cmp.c
> @@ -41,7 +41,7 @@ static int em_cmp_match(struct sk_buff *skb, struct tcf_ematch *em,
>  		val = get_unaligned_be16(ptr);
>  
>  		if (cmp_needs_transformation(cmp))
> -			val = be16_to_cpu(val);
> +			val = be16_to_cpu((__force __be16)val);
>  		break;
There should probably be a comment here to explain what's going on.  TBH
 it's probably a good general rule that any use of __force should have a
 comment explaining why it's needed.
AFAICT, get_unaligned_be16(ptr) is (barring alignment) equivalent to
 be16_to_cpu(*(__be16 *)ptr).  But then calling be16_to_cpu() again on
 val is bogus; it's already CPU endian.  There's a distinct lack of
 documentation around as to the intended semantics of TCF_EM_CMP_TRANS,
 but it would seem either (__force u16)cpu_to_be16(val); (which preserves
 the existing semantics, that trans is a no-op on BE) or swab16(val);
 would make more sense.

-Ed

  parent reply	other threads:[~2019-04-29 10:11 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-04-28  5:54 Nicholas Mc Guire
2019-04-28 18:17 ` Cong Wang
2019-04-29 10:11 ` Edward Cree [this message]
2019-04-29 10:44   ` Nicholas Mc Guire
2019-04-29 11:11     ` Edward Cree
2019-04-29 11:29       ` Nicholas Mc Guire
2019-04-29 12:09 ` Christoph Hellwig

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=07d36e94-aad4-a263-bf09-705ee1dd59ed@solarflare.com \
    --to=ecree@solarflare.com \
    --cc=davem@davemloft.net \
    --cc=hofrat@osadl.org \
    --cc=jhs@mojatatu.com \
    --cc=jiri@resnulli.us \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=xiyou.wangcong@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®