Commit 0b2f74a4 authored by Joe Eykholt's avatar Joe Eykholt Committed by James Bottomley

[SCSI] libfc: fix hton24 macro to take expressions as args

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: default avatarJoe Eykholt <jeykholt@cisco.com>
Signed-off-by: default avatarRobert Love <robert.w.love@intel.com>
Signed-off-by: default avatarJames Bottomley <James.Bottomley@suse.de>
parent 3b719d01
...@@ -47,13 +47,18 @@ ...@@ -47,13 +47,18 @@
#define ntohll(x) be64_to_cpu(x) #define ntohll(x) be64_to_cpu(x)
#define htonll(x) cpu_to_be64(x) #define htonll(x) cpu_to_be64(x)
#define ntoh24(p) (((p)[0] << 16) | ((p)[1] << 8) | ((p)[2]))
#define hton24(p, v) do { \ static inline u32 ntoh24(const u8 *p)
p[0] = (((v) >> 16) & 0xFF); \ {
p[1] = (((v) >> 8) & 0xFF); \ return (p[0] << 16) | (p[1] << 8) | p[2];
p[2] = ((v) & 0xFF); \ }
} while (0)
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 * enum fc_lport_state - Local port states
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment