lkml.org 
[lkml]   [2017]   [Mar]   [5]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: [PATCH 3/3] futex: make the encoded_op decoding readable
From
Date
On 03/03/2017, 01:27 PM, Jiri Slaby wrote:
> 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@suse.cz>
> ---
> 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;

And it turned out that this one is actually invalid as it doesn't
preserve signedness on oparg and cmdarg. So please avoid applying this one.

thanks,
--
js
suse labs

\
 
 \ /
  Last update: 2017-03-05 08:56    [W:0.148 / U:0.296 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site