netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Allan Stephens <allan.stephens@windriver.com>
To: David Miller <davem@davemloft.net>
Cc: netdev@vger.kernel.org, allan.stephens@windriver.com
Subject: [PATCH 6/7 net-2.6.26] [TIPC]: Enhancements to message header writing
Date: Thu,  6 Mar 2008 16:34:28 -0500	[thread overview]
Message-ID: <1204839269-30593-7-git-send-email-allan.stephens@windriver.com> (raw)
In-Reply-To: <1204839269-30593-1-git-send-email-allan.stephens@windriver.com>

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>
---
 net/tipc/msg.h |    6 ++++--
 1 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/net/tipc/msg.h b/net/tipc/msg.h
index 88a2ee0..6ad070d 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,
 				u32 pos, u32 mask, u32 val)
 {
 	val = (val & mask) << pos;
-	m->hdr[w] &= ~htonl(mask << pos);
-	m->hdr[w] |= htonl(val);
+	val = htonl(val);
+	mask = htonl(mask << pos);
+	m->hdr[w] &= ~mask;
+	m->hdr[w] |= val;
 }
 
 /*
-- 
1.5.3.2


  parent reply	other threads:[~2008-03-06 21:50 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-03-06 21:34 [PATCH 0/7 net-2.6.26] [TIPC]: Initial patch set for TIPC 1.6.3 Allan Stephens
2008-03-06 21:34 ` [PATCH 1/7 net-2.6.26] [TIPC]: Removal of message header option code Allan Stephens
2008-03-06 23:05   ` David Miller
2008-03-06 21:34 ` [PATCH 2/7 net-2.6.26] [TIPC]: Add argument validation for shutdown() Allan Stephens
2008-03-06 23:05   ` David Miller
2008-03-06 21:34 ` [PATCH 3/7 net-2.6.26] [TIPC]: Eliminate "sparse" symbol warnings Allan Stephens
2008-03-06 23:06   ` David Miller
2008-03-06 21:34 ` [PATCH 4/7 net-2.6.26] [TIPC]: Minor cleanup of message header code Allan Stephens
2008-03-06 23:07   ` David Miller
2008-03-06 21:34 ` [PATCH 5/7 net-2.6.26] [TIPC]: Use correct bitmask when setting version Allan Stephens
2008-03-06 23:07   ` David Miller
2008-03-06 21:34 ` Allan Stephens [this message]
2008-03-06 23:08   ` [PATCH 6/7 net-2.6.26] [TIPC]: Enhancements to message header writing David Miller
2008-03-06 21:34 ` [PATCH 7/7 net-2.6.26] [TIPC]: Update version to 1.6.3 Allan Stephens
2008-03-06 23:08 ` [PATCH 0/7 net-2.6.26] [TIPC]: Initial patch set for TIPC 1.6.3 David Miller
  -- strict thread matches above, loose matches on Subject: below --
2008-03-04 21:20 Allan Stephens
2008-03-04 21:20 ` [PATCH 6/7 net-2.6.26] [TIPC]: Enhancements to message header writing Allan Stephens

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=1204839269-30593-7-git-send-email-allan.stephens@windriver.com \
    --to=allan.stephens@windriver.com \
    --cc=davem@davemloft.net \
    --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).