Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1593033

Re: [PATCH 1/3] futex: remove duplicated code

From "H. Peter Anvin" <hpa@zytor.com>
Newsgroups linux.kernel
Subject Re: [PATCH 1/3] futex: remove duplicated code
Date 2017-03-06 10:20 +0100
Message-ID <thWYb-64J-63@gated-at.bofh.it> (permalink)
References (2 earlier) <thnxn-5re-7@gated-at.bofh.it> <thpzb-6Um-13@gated-at.bofh.it> <thr7X-81G-1@gated-at.bofh.it> <thrrj-89Z-5@gated-at.bofh.it> <thWv7-5E6-1@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


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

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


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