Skip to content

Commit 0b2f74a

Browse files
Joe EykholtJames Bottomley
authored andcommitted
[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: Joe Eykholt <jeykholt@cisco.com> Signed-off-by: Robert Love <robert.w.love@intel.com> Signed-off-by: James Bottomley <James.Bottomley@suse.de>
1 parent 3b719d0 commit 0b2f74a

1 file changed

Lines changed: 11 additions & 6 deletions

File tree

‎include/scsi/libfc.h‎

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -47,13 +47,18 @@
4747
#define ntohll(x) be64_to_cpu(x)
4848
#define htonll(x) cpu_to_be64(x)
4949

50-
#define ntoh24(p) (((p)[0] << 16) | ((p)[1] << 8) | ((p)[2]))
5150

52-
#define hton24(p, v) do { \
53-
p[0] = (((v) >> 16) & 0xFF); \
54-
p[1] = (((v) >> 8) & 0xFF); \
55-
p[2] = ((v) & 0xFF); \
56-
} while (0)
51+
static inline u32 ntoh24(const u8 *p)
52+
{
53+
return (p[0] << 16) | (p[1] << 8) | p[2];
54+
}
55+
56+
static inline void hton24(u8 *p, u32 v)
57+
{
58+
p[0] = (v >> 16) & 0xff;
59+
p[1] = (v >> 8) & 0xff;
60+
p[2] = v & 0xff;
61+
}
5762

5863
/**
5964
* enum fc_lport_state - Local port states

0 commit comments

Comments
 (0)