lkml.org 
[lkml]   [2017]   [Mar]   [6]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: [PATCH 1/3] futex: remove duplicated code
From
Date
On 03/06/17 00:46, Jiri Slaby wrote:
>
> static int futex_atomic_op_inuser(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 = sign_extend32((encoded_op & 0x00fff000) >> 12, 12);
> + int cmparg = sign_extend32(encoded_op & 0x00000fff, 12);
> int oldval, ret;
>

At least in the sign-extend case the mask is unnecessary.

This is why it would be nice to have both sign and zero extend for symmetry.

-hpa


\
 
 \ /
  Last update: 2017-03-06 10:16    [W:0.074 / U:0.360 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site