Thread (22 messages) flat view 22 messages, 7 authors, 2016-08-23

Re: [PATCH net-next 1/3] net/ip_tunnels: Introduce tunnel_id_to_key32() and key32_to_tunnel_id()

From: Amir Vadai <hidden>
Date: 2016-08-23 06:39:53

On Mon, Aug 22, 2016 at 07:00:27PM +0200, Jiri Benc wrote:
While cleaning this up, you may as well take the best of both
implementations.

On Mon, 22 Aug 2016 17:38:32 +0300, Amir Vadai wrote:
quoted
+static inline __be64 key32_to_tunnel_id(__be32 key)
+{
+#ifdef __BIG_ENDIAN
+	return (__force __be64)((__force u32)key);
The inner cast seems to be superfluous?
seems so. will check.
quoted
+#else
+	return (__force __be64)((__force u64)key << 32);
+#endif
+}
+
+/* Returns the least-significant 32 bits of a __be64. */
+static inline __be32 tunnel_id_to_key32(__be64 x)
Please use a more descriptive name than "x". "tunnel_id" or "tun_id"
seems to be more appropriate.
ack
quoted
+{
+#ifdef __BIG_ENDIAN
+	return (__force __be32)x;
+#else
+	return (__force __be32)((__force u64)x >> 32);
+#endif
+}
Looks good otherwise.

Thanks,

 Jiri
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help