Messages in this thread | | | Subject | Re: [PATCH 1/3] futex: remove duplicated code | From | "H. Peter Anvin" <> | Date | Mon, 6 Mar 2017 01:13:52 -0800 |
| |
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
| |