netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Amin Azez <azez@ufomechanic.net>
To: "David S. Miller" <davem@davemloft.net>
Cc: laforge@netfilter.org, netdev@vger.kernel.org,
	netfilter-devel@lists.netfilter.org, wensong@linux-vs.org
Subject: Re: [PATCH] reduce netfilte sk_buff enlargement
Date: Fri, 22 Jul 2005 09:34:49 +0100	[thread overview]
Message-ID: <42E0AFA9.6090308@ufomechanic.net> (raw)
In-Reply-To: <20050721.152941.56567834.davem@davemloft.net>

David S. Miller wrote:
> This probably has nothing to do with why the patch doesn't
> work for you, but the transformation of "incoming" to a "u8"
> from an "int" is not fully correct, because hci_sock.c
> does this:
> 
> 	put_cmsg(msg, SOL_HCI, HCI_CMSG_DIR, sizeof(int), &bt_cb(skb)->incoming);
> 

These things always scare me, why do folk litter code with sly knowledge
of the size of struct members that may and do change?

Why don't people do:

put_cmsg(msg, SOL_HCI, HCI_CMSG_DIR, sizeof(bt_cb(skb)->incoming),
&bt_cb(skb)->incoming);

Or even better, use a macro to capture the semantics

#define put_struct_msg(msg, S, H, ITEM) \
 put_cmsg((msg),(S),(H),sizeof(ITEM),&(ITEM))

then do:
put_struct_cmsg(msg, SOL_HCI, HCI_CMSG_DIR, bt_cb(skb)->incoming);


It is true that macros can be over-used to create a meta-language and
uber-api, but this case saves no end of trouble, surely it is what
macros are for?

Sam

      parent reply	other threads:[~2005-07-22  8:34 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-07-16 21:40 [PATCH] reduce netfilte sk_buff enlargement Harald Welte
2005-07-19  3:31 ` David S. Miller
2005-07-19  7:18   ` Jan Engelhardt
2005-07-19  7:23     ` David S. Miller
2005-07-20 13:23   ` Harald Welte
2005-07-20 15:43     ` Wensong Zhang
2005-07-20 21:35       ` Patrick McHardy
2005-07-20 18:43     ` David S. Miller
2005-07-21 18:20     ` Marcel Holtmann
2005-07-21 20:12       ` David S. Miller
2005-07-21 21:42         ` Marcel Holtmann
2005-07-21 22:10           ` David S. Miller
2005-07-21 22:29           ` David S. Miller
2005-07-21 23:49             ` Marcel Holtmann
2005-07-21 23:52               ` David S. Miller
2005-07-22  0:26                 ` Marcel Holtmann
2005-07-22 22:54                   ` David S. Miller
2005-07-23  1:36                     ` Marcel Holtmann
2005-07-25  2:18                       ` David S. Miller
2005-07-22  8:34             ` Amin Azez [this message]

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=42E0AFA9.6090308@ufomechanic.net \
    --to=azez@ufomechanic.net \
    --cc=davem@davemloft.net \
    --cc=laforge@netfilter.org \
    --cc=netdev@vger.kernel.org \
    --cc=netfilter-devel@lists.netfilter.org \
    --cc=wensong@linux-vs.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).