Thread (20 messages) 20 messages, 7 authors, 2005-07-25

Re: [PATCH] reduce netfilte sk_buff enlargement

From: Amin Azez <hidden>
Date: 2005-07-22 08:34:49
Also in: netfilter-devel

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
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help