aboutsummaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
authorAllan Stephens <allan.stephens@windriver.com>2008-03-06 18:08:10 -0500
committerDavid S. Miller <davem@davemloft.net>2008-03-06 18:08:10 -0500
commitc0cb7ef08667374f0cbe8c94c819f74a6c935135 (patch)
tree9f609c48c03f8cf03002f1b00e6708ee79808de4 /net
parent37695420a233aa8aef40c68cb338ad09e0241ec3 (diff)
[TIPC]: Enhancements to message header writing
This patch makes two enhancements to the routine used to set bit fields within a TIPC message header: 1) It now ignores any bits of the new field value that are not covered by the mask being used. (Previously, if the new value exceeded the size of the mask the extra bits could corrupt other fields in the message header word being updated.) 2) The code has been optimized to minimize the number of run-time endianness conversion operations by leveraging the fact that the mask (and, in some cases, the value as well) is constant and the necessary conversion can be performed by the compiler. Signed-off-by: Allan Stephens <allan.stephens@windriver.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net')
-rw-r--r--net/tipc/msg.h6
1 files changed, 4 insertions, 2 deletions
diff --git a/net/tipc/msg.h b/net/tipc/msg.h
index 88a2ee03bb2a..6ad070d87702 100644
--- a/net/tipc/msg.h
+++ b/net/tipc/msg.h
@@ -70,8 +70,10 @@ static inline void msg_set_bits(struct tipc_msg *m, u32 w,
70 u32 pos, u32 mask, u32 val) 70 u32 pos, u32 mask, u32 val)
71{ 71{
72 val = (val & mask) << pos; 72 val = (val & mask) << pos;
73 m->hdr[w] &= ~htonl(mask << pos); 73 val = htonl(val);
74 m->hdr[w] |= htonl(val); 74 mask = htonl(mask << pos);
75 m->hdr[w] &= ~mask;
76 m->hdr[w] |= val;
75} 77}
76 78
77/* 79/*