[PATCH 3/3] futex: make the encoded_op decoding readable

From: Jiri Slaby
Date: Fri Mar 03 2017 - 13:25:06 EST


Decoding of encoded_op is a bit unreadable. It contains shifts to the
left and to the right by some constants. Make it clearly visible what
part of the bit mask is taken and shift the values only to the right
appropriatelly.

Signed-off-by: Jiri Slaby <jslaby@xxxxxxx>
---
kernel/futex.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/kernel/futex.c b/kernel/futex.c
index c09424406560..5834df248f09 100644
--- a/kernel/futex.c
+++ b/kernel/futex.c
@@ -1459,10 +1459,10 @@ futex_wake(u32 __user *uaddr, unsigned int flags, int nr_wake, u32 bitset)

static int futex_atomic_op_inuser(unsigned int encoded_op, u32 __user *uaddr)
{
- int op = (encoded_op >> 28) & 7;
- int cmp = (encoded_op >> 24) & 15;
- int oparg = (encoded_op << 8) >> 20;
- int cmparg = (encoded_op << 20) >> 20;
+ int op = (encoded_op & 0x70000000) >> 28;
+ int cmp = (encoded_op & 0x0f000000) >> 24;
+ int oparg = (encoded_op & 0x00fff000) >> 12;
+ int cmparg = encoded_op & 0x00000fff;
int oldval, ret;

if (encoded_op & (FUTEX_OP_OPARG_SHIFT << 28)) {
--
2.12.0