]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
selftests/userfaultfd: fix compiler warnings on 32-bit
authorGeert Uytterhoeven <geert@linux-m68k.org>
Tue, 8 Sep 2015 21:58:25 +0000 (14:58 -0700)
committerDhaval Giani <dhaval.giani@oracle.com>
Fri, 20 Jan 2017 18:53:16 +0000 (13:53 -0500)
Orabug: 21685254

On 32-bit:

    userfaultfd.c: In function 'locking_thread':
    userfaultfd.c:152: warning: left shift count >= width of type
    userfaultfd.c: In function 'uffd_poll_thread':
    userfaultfd.c:295: warning: cast to pointer from integer of different size
    userfaultfd.c: In function 'uffd_read_thread':
    userfaultfd.c:332: warning: cast to pointer from integer of different size

Fix the shift warning by splitting the shift in two parts, and the
integer/pointer warnigns by adding intermediate casts to "unsigned long".

Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org>
Cc: Andrea Arcangeli <aarcange@redhat.com>
Cc: Shuah Khan <shuahkh@osg.samsung.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
(cherry picked from commit af8713b701a74c3784ce6683f64f474a94b1b643)
Signed-off-by: Mike Kravetz <mike.kravetz@oracle.com>
Reviewed-by: Dhaval Giani <dhaval.giani@oracle.com>
Signed-off-by: Dhaval Giani <dhaval.giani@oracle.com>
tools/testing/selftests/vm/userfaultfd.c

index 76071b14cb93857a01a3e4e97324702e4227633d..2c7cca6f26a45c215b43b44a7f5c9dddceee301c 100644 (file)
@@ -147,7 +147,8 @@ static void *locking_thread(void *arg)
                        if (sizeof(page_nr) > sizeof(rand_nr)) {
                                if (random_r(&rand, &rand_nr))
                                        fprintf(stderr, "random_r 2 error\n"), exit(1);
-                               page_nr |= ((unsigned long) rand_nr) << 32;
+                               page_nr |= (((unsigned long) rand_nr) << 16) <<
+                                          16;
                        }
                } else
                        page_nr += 1;
@@ -290,7 +291,8 @@ static void *uffd_poll_thread(void *arg)
                                msg.event), exit(1);
                if (msg.arg.pagefault.flags & UFFD_PAGEFAULT_FLAG_WRITE)
                        fprintf(stderr, "unexpected write fault\n"), exit(1);
-               offset = (char *)msg.arg.pagefault.address - area_dst;
+               offset = (char *)(unsigned long)msg.arg.pagefault.address -
+                        area_dst;
                offset &= ~(page_size-1);
                if (copy_page(offset))
                        userfaults++;
@@ -327,7 +329,8 @@ static void *uffd_read_thread(void *arg)
                if (bounces & BOUNCE_VERIFY &&
                    msg.arg.pagefault.flags & UFFD_PAGEFAULT_FLAG_WRITE)
                        fprintf(stderr, "unexpected write fault\n"), exit(1);
-               offset = (char *)msg.arg.pagefault.address - area_dst;
+               offset = (char *)(unsigned long)msg.arg.pagefault.address -
+                        area_dst;
                offset &= ~(page_size-1);
                if (copy_page(offset))
                        (*this_cpu_userfaults)++;