netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Antonio Quartulli <ordex@autistici.org>
To: Ben Hutchings <bhutchings@solarflare.com>
Cc: David Miller <davem@davemloft.net>,
	amwang@redhat.com, netdev@vger.kernel.org, horms@verge.net.au
Subject: Re: [Patch net-next] net: clean up skb headers code
Date: Thu, 30 May 2013 10:59:04 +0200	[thread overview]
Message-ID: <20130530085904.GA2475@ritirata.org> (raw)
In-Reply-To: <1369861326.1971.43.camel@bwh-desktop.uk.level5networks.com>

[-- Attachment #1: Type: text/plain, Size: 1803 bytes --]

On Wed, May 29, 2013 at 10:02:06PM +0100, Ben Hutchings wrote:
> On Wed, 2013-05-29 at 21:44 +0200, Antonio Quartulli wrote:
> > On Wed, May 29, 2013 at 08:34:33PM +0100, Ben Hutchings wrote:
> > > On Tue, 2013-05-28 at 23:36 -0700, David Miller wrote:
> > > > From: Cong Wang <amwang@redhat.com>
> > > > Date: Wed, 29 May 2013 14:09:00 +0800
> > > > 
> > > > > commit 1a37e412a0225fcba5587 (net: Use 16bits for *_headers
> > > > > fields of struct skbuff) converts skb->*_header to u16,
> > > > > therefore 1) we could just use 0xFFFFF instead of (__u16) ~0U
> > > > > 2) some #if NET_SKBUFF_DATA_USES_OFFSET is useless now.
> > > > > 
> > > > > 
> > > > > Cc: David S. Miller <davem@davemloft.net>
> > > > > Cc: Simon Horman <horms@verge.net.au>
> > > > > Signed-off-by: Cong Wang <amwang@redhat.com>
> > > > 
> > > > I want to use something that will either break the build or
> > > > automatically work if the type changes again.
> > > > 
> > > > So something like "X = (typeof(X)) ~0U;".
> > > 
> > > I think you mean ~(typeof(X))0.
> > 
> > Am I wrong or you should cast the value once again, like this:
> > 
> > ((typeof(X))~(typeof(X))0)
> > 
> > because the ~ operator will implicitly cast the argument to int (if I remember
> > correctly).
> 
> It will promote to at least int, but that still results in the right
> value and doesn't provoke a warning.  Try this test (with -Wall
> -Wextra):

thanks for the test code Ben.

Yeah it gives the results you expected. Then I don't know why somebody suggested
us to do this double cast in batman-adv when we wanted to obtain the same.

At this point I'll remove the double cast in our code too.

Thanks.

Cheers,

-- 
Antonio Quartulli

..each of us alone is worth nothing..
Ernesto "Che" Guevara

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

  reply	other threads:[~2013-05-30  9:01 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-05-29  6:09 [Patch net-next] net: clean up skb headers code Cong Wang
2013-05-29  6:36 ` David Miller
2013-05-29  6:48   ` Cong Wang
2013-05-29  6:49     ` David Miller
2013-05-29 19:34   ` Ben Hutchings
2013-05-29 19:44     ` Antonio Quartulli
2013-05-29 21:02       ` Ben Hutchings
2013-05-30  8:59         ` Antonio Quartulli [this message]
2013-05-30 11:41         ` David Laight
2013-05-30 11:45           ` Antonio Quartulli
2013-05-30 12:12             ` David Laight
2013-05-30 12:22               ` David Laight
2013-05-30 12:24                 ` Antonio Quartulli
2013-05-30 12:40                   ` David Laight
2013-05-30 12:23               ` Antonio Quartulli
2013-05-30  1:59     ` Cong Wang
2013-05-30 12:30       ` Sergei Shtylyov
2013-05-30 10:40     ` David Miller
2013-05-30 14:11       ` Ben Hutchings

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=20130530085904.GA2475@ritirata.org \
    --to=ordex@autistici.org \
    --cc=amwang@redhat.com \
    --cc=bhutchings@solarflare.com \
    --cc=davem@davemloft.net \
    --cc=horms@verge.net.au \
    --cc=netdev@vger.kernel.org \
    /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;
as well as URLs for NNTP newsgroup(s).