public inbox for linux-scsi@vger.kernel.org
 help / color / mirror / Atom feed
From: Robert Love <robert.w.love@intel.com>
To: James.Bottomley@suse.de, linux-scsi@vger.kernel.org
Cc: Joe Eykholt <jeykholt@cisco.com>, Robert Love <robert.w.love@intel.com>
Subject: [PATCH 05/12] libfc: fix hton24 macro to take expressions as args
Date: Fri, 09 Apr 2010 14:22:39 -0700	[thread overview]
Message-ID: <20100409212238.1968.68620.stgit@localhost.localdomain> (raw)
In-Reply-To: <20100409212212.1968.59251.stgit@localhost.localdomain>

From: Joe Eykholt <jeykholt@cisco.com>

hton24(p + 3, value) would fail to compile because
p + 3[0] is not a valid expression.

Went ahead and converted hton24 and ntoh24 to inline
functions, which is better because the parameters
are evalutated only once.

Signed-off-by: Joe Eykholt <jeykholt@cisco.com>
Signed-off-by: Robert Love <robert.w.love@intel.com>
---

 include/scsi/libfc.h |   17 +++++++++++------
 1 files changed, 11 insertions(+), 6 deletions(-)

diff --git a/include/scsi/libfc.h b/include/scsi/libfc.h
index 8d0d1b2..a26bb50 100644
--- a/include/scsi/libfc.h
+++ b/include/scsi/libfc.h
@@ -47,13 +47,18 @@
 #define ntohll(x) be64_to_cpu(x)
 #define htonll(x) cpu_to_be64(x)
 
-#define ntoh24(p) (((p)[0] << 16) | ((p)[1] << 8) | ((p)[2]))
 
-#define hton24(p, v)	do {			\
-		p[0] = (((v) >> 16) & 0xFF);	\
-		p[1] = (((v) >> 8) & 0xFF);	\
-		p[2] = ((v) & 0xFF);		\
-	} while (0)
+static inline u32 ntoh24(const u8 *p)
+{
+	return (p[0] << 16) | (p[1] << 8) | p[2];
+}
+
+static inline void hton24(u8 *p, u32 v)
+{
+	p[0] = (v >> 16) & 0xff;
+	p[1] = (v >> 8) & 0xff;
+	p[2] = v & 0xff;
+}
 
 /**
  * enum fc_lport_state - Local port states


  parent reply	other threads:[~2010-04-09 21:22 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-04-09 21:22 [PATCH 00/12] Updates to libfc, libfcoe, fcoe and fnic Robert Love
2010-04-09 21:22 ` [PATCH 01/12] libfcoe: Don't fill MAC desc in FLOGI if FIP negotiated FPMA Robert Love
2010-04-09 21:22 ` [PATCH 02/12] fcoe: reset FIP ctlr link state on disable/enable Robert Love
2010-04-09 21:22 ` [PATCH 03/12] fcoe: check netif operstate instead of IFF_UP & link state Robert Love
2010-04-09 21:22 ` [PATCH 04/12] libfc: remove unneeded variables in fc_exch_recv_req() Robert Love
2010-04-09 21:22 ` Robert Love [this message]
2010-04-09 21:22 ` [PATCH 06/12] fnic: Update version to 1.4.0.145 Robert Love
2010-04-09 21:22 ` [PATCH 07/12] fnic: Change fnic_flush_tx() to flush tx instead of rx queue Robert Love
2010-04-09 21:22 ` [PATCH 08/12] fcoe: removes unused shost in fcoe_shost_config Robert Love
2010-04-09 21:22 ` [PATCH 09/12] fcoe, fnic, libfc: increased CDB size to 16 bytes for fcoe Robert Love
2010-04-09 21:23 ` [PATCH 10/12] libfc: bug in erroring out upon FCP_RSP_LEN_VAL in fc_fcp_resp Robert Love
2010-04-09 21:23 ` [PATCH 11/12] libfc: set both precision and field with when printing FC IDs Robert Love
2010-04-09 21:23 ` [PATCH 12/12] libfc, fcoe: normalize format specifies for world wide names Robert Love

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=20100409212238.1968.68620.stgit@localhost.localdomain \
    --to=robert.w.love@intel.com \
    --cc=James.Bottomley@suse.de \
    --cc=jeykholt@cisco.com \
    --cc=linux-scsi@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