Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1592704
| From | Jiri Slaby <jslaby@suse.cz> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | Re: [PATCH 3/3] futex: make the encoded_op decoding readable |
| Date | 2017-03-05 09:00 +0100 |
| Message-ID | <thzfb-5fI-1@gated-at.bofh.it> (permalink) |
| References | <tgUF4-1cK-7@gated-at.bofh.it> <th07L-556-17@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
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
Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
[PATCH 1/3] futex: remove duplicated code Jiri Slaby <jslaby@suse.cz> - 2017-03-03 13:40 +0100
[PATCH 2/3] futex: fix decoding of operation Jiri Slaby <jslaby@suse.cz> - 2017-03-03 19:30 +0100
[PATCH 3/3] futex: make the encoded_op decoding readable Jiri Slaby <jslaby@suse.cz> - 2017-03-03 19:30 +0100
Re: [PATCH 3/3] futex: make the encoded_op decoding readable Jiri Slaby <jslaby@suse.cz> - 2017-03-05 09:00 +0100
Re: [PATCH 1/3] futex: remove duplicated code Heiko Carstens <heiko.carstens@de.ibm.com> - 2017-03-03 21:10 +0100
Re: [PATCH 1/3] futex: remove duplicated code Michael Ellerman <mpe@ellerman.id.au> - 2017-03-04 14:00 +0100
Re: [PATCH 1/3] futex: remove duplicated code Russell King - ARM Linux <linux@armlinux.org.uk> - 2017-03-04 14:20 +0100
Re: [PATCH 1/3] futex: remove duplicated code "H. Peter Anvin" <hpa@zytor.com> - 2017-03-04 20:30 +0100
Re: [PATCH 1/3] futex: remove duplicated code Stafford Horne <shorne@gmail.com> - 2017-03-04 22:40 +0100
Re: [PATCH 1/3] futex: remove duplicated code "H. Peter Anvin" <hpa@zytor.com> - 2017-03-05 00:20 +0100
Re: [PATCH 1/3] futex: remove duplicated code Stafford Horne <shorne@gmail.com> - 2017-03-05 00:40 +0100
Re: [PATCH 1/3] futex: remove duplicated code Jiri Slaby <jslaby@suse.cz> - 2017-03-06 09:50 +0100
Re: [PATCH 1/3] futex: remove duplicated code "H. Peter Anvin" <hpa@zytor.com> - 2017-03-06 10:20 +0100
Re: [PATCH 1/3] futex: remove duplicated code Geert Uytterhoeven <geert@linux-m68k.org> - 2017-03-06 15:20 +0100
Re: [PATCH 1/3] futex: remove duplicated code "H. Peter Anvin" <hpa@zytor.com> - 2017-03-05 00:20 +0100
Re: [PATCH 1/3] futex: remove duplicated code Rob Landley <rob@landley.net> - 2017-03-09 05:20 +0100
Re: [PATCH 1/3] futex: remove duplicated code "H. Peter Anvin" <hpa@zytor.com> - 2017-03-09 06:10 +0100
Re: [PATCH 1/3] futex: remove duplicated code Rich Felker <dalias@libc.org> - 2017-03-09 23:50 +0100
Re: [PATCH 1/3] futex: remove duplicated code Rich Felker <dalias@libc.org> - 2017-03-06 03:20 +0100
Re: [PATCH 1/3] futex: remove duplicated code Vineet Gupta <Vineet.Gupta1@synopsys.com> - 2017-03-09 23:50 +0100
csiph-web