The Linux Kernel Mailing List
 help / color / mirror / Atom feed
From: Wei Yang <richard.weiyang@gmail.com>
To: Geert Uytterhoeven <geert@linux-m68k.org>
Cc: Wei Yang <richard.weiyang@gmail.com>,
	Andrew Morton <akpm@linux-foundation.org>,
	Andy Shevchenko <andriy.shevchenko@linux.intel.com>,
	Christian Brauner <christian.brauner@ubuntu.com>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Subject: Re: [Patch v2] lib: test get_count_order/long in test_bitops.c
Date: Thu, 4 Jun 2020 12:28:05 +0000	[thread overview]
Message-ID: <20200604122805.d2ndjmkmti6wl3nz@master> (raw)
In-Reply-To: <CAMuHMdUfnmm4bXVRvFOmG5DFYR+LtcZ1UviDszr9bByiN=DO+Q@mail.gmail.com>

On Thu, Jun 04, 2020 at 01:50:13PM +0200, Geert Uytterhoeven wrote:
>Hi Wei,
>
>On Wed, Jun 3, 2020 at 1:11 AM Wei Yang <richard.weiyang@gmail.com> wrote:
>> Add some test for get_count_order/long in test_bitops.c.
>>
>> Signed-off-by: Wei Yang <richard.weiyang@gmail.com>
>
>Thanks for your patch, which is now commit 7851d6639caeea40 ("lib:
>test get_count_order/long in test_bitops.c") in linux-next.
>
>> --- a/lib/test_bitops.c
>> +++ b/lib/test_bitops.c
>
>> @@ -24,6 +28,26 @@ enum bitops_fun {
>>
>>  static DECLARE_BITMAP(g_bitmap, BITOPS_LENGTH);
>>
>> +unsigned int order_comb[][2] = {
>> +       {0x00000003,  2},
>> +       {0x00000004,  2},
>> +       {0x00001fff, 13},
>> +       {0x00002000, 13},
>> +       {0x50000000, 31},
>> +       {0x80000000, 31},
>> +       {0x80003000, 32},
>> +};
>> +
>> +unsigned long order_comb_long[][2] = {
>> +       {0x0000000300000000, 34},
>> +       {0x0000000400000000, 34},
>> +       {0x00001fff00000000, 45},
>> +       {0x0000200000000000, 45},
>> +       {0x5000000000000000, 63},
>> +       {0x8000000000000000, 63},
>> +       {0x8000300000000000, 64},
>> +};
>
>noreply@ellerman.id.au reported for m68k-allmodconfig:
>
>lib/test_bitops.c:42:3: error: unsigned conversion from 'long long
>int' to 'long unsigned int' changes value from '12884901888' to '0'
>[-Werror=overflow]
>lib/test_bitops.c:43:3: error: unsigned conversion from 'long long
>int' to 'long unsigned int' changes value from '17179869184' to '0'
>[-Werror=overflow]
>lib/test_bitops.c:44:3: error: unsigned conversion from 'long long
>int' to 'long unsigned int' changes value from '35180077121536' to '0'
>[-Werror=overflow]
>lib/test_bitops.c:45:3: error: unsigned conversion from 'long long
>int' to 'long unsigned int' changes value from '35184372088832' to '0'
>[-Werror=overflow]
>lib/test_bitops.c:46:3: error: unsigned conversion from 'long long
>int' to 'long unsigned int' changes value from '5764607523034234880'
>to '0' [-Werror=overflow]
>lib/test_bitops.c:47:3: error: conversion from 'long long unsigned
>int' to 'long unsigned int' changes value from '9223372036854775808'
>to '0' [-Werror=overflow]
>lib/test_bitops.c:48:3: error: conversion from 'long long unsigned
>int' to 'long unsigned int' changes value from '9223424813412909056'
>to '0' [-Werror=overflow]
>
>Indeed, on 32-bit, none of these values fit in unsigned long.
>

Hmm... I didn't test on 32bit platform. Sorry for that.

>>  static int __init test_bitops_startup(void)
>>  {
>>         pr_warn("Loaded test module\n");
>> @@ -32,6 +56,18 @@ static int __init test_bitops_startup(void)
>>         set_bit(BITOPS_11, g_bitmap);
>>         set_bit(BITOPS_31, g_bitmap);
>>         set_bit(BITOPS_88, g_bitmap);
>> +
>> +       for (i = 0; i < ARRAY_SIZE(order_comb); i++) {
>> +               if (order_comb[i][1] != get_count_order(order_comb[i][0]))
>> +                       pr_warn("get_count_order wrong for %x\n",
>> +                                      order_comb[i][0]); }
>> +
>> +       for (i = 0; i < ARRAY_SIZE(order_comb_long); i++) {
>> +               if (order_comb_long[i][1] !=
>> +                              get_count_order_long(order_comb_long[i][0]))
>> +                       pr_warn("get_count_order_long wrong for %lx\n",
>> +                                      order_comb_long[i][0]); }
>> +
>>         return 0;
>
>BTW, shouldn't get_count_order_long() be tested with the values in
>order_comb[], too?
>

You mean 

       {0x0000000000000003,  2},
       {0x0000000000000004,  2},
       {0x0000000000001fff, 13},
       {0x0000000000002000, 13},
       {0x0000000050000000, 31},
       {0x0000000080000000, 31},
       {0x0000000080003000, 32},

>Gr{oetje,eeting}s,
>
>                        Geert
>
>-- 
>Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org
>
>In personal conversations with technical people, I call myself a hacker. But
>when I'm talking to journalists I just say "programmer" or something like that.
>                                -- Linus Torvalds

-- 
Wei Yang
Help you, Help me

  reply	other threads:[~2020-06-04 12:28 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-06-02 22:37 [Patch v2] lib: test get_count_order/long in test_bitops.c Wei Yang
2020-06-03  9:18 ` Andy Shevchenko
2020-06-03 13:29   ` Wei Yang
2020-06-04 11:50 ` Geert Uytterhoeven
2020-06-04 12:28   ` Wei Yang [this message]
2020-06-04 12:51     ` Geert Uytterhoeven
2020-06-05 23:06       ` Wei Yang
2020-06-06  0:16         ` Andrew Morton
2020-06-08 22:31           ` Wei Yang
2020-06-09  9:16             ` Andy Shevchenko
2020-06-09 23:02               ` Wei Yang
2020-06-10 10:17                 ` Andy Shevchenko
2020-06-10 22:06                   ` Wei Yang
2020-06-11  7:25                     ` Andy Shevchenko
2020-06-12 14:28                       ` Wei Yang

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200604122805.d2ndjmkmti6wl3nz@master \
    --to=richard.weiyang@gmail.com \
    --cc=akpm@linux-foundation.org \
    --cc=andriy.shevchenko@linux.intel.com \
    --cc=christian.brauner@ubuntu.com \
    --cc=geert@linux-m68k.org \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox