Received: by 2002:a25:683:0:0:0:0:0 with SMTP id 125csp1239185ybg; Thu, 4 Jun 2020 04:53:50 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxIUfz0G1XV7CNV1fZpWsJC8XURVhLVHWEWLXYJoGlba35UyXl9yz5Aeinn6KAg8NvPKovg X-Received: by 2002:a17:906:1c94:: with SMTP id g20mr3443723ejh.319.1591271630192; Thu, 04 Jun 2020 04:53:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1591271630; cv=none; d=google.com; s=arc-20160816; b=CFv1BbNFtcAfUUtxw+f6a6e1QCv/b2wLGqUoC6yDFfdzBxS/53YGTJgJoZGem61/gA A8QCWqN7Yeu+SZABV4hVcPPT+TsyEmudXek6eAj5ES1Rfv4CsF7ijzWVU37AJ8eo96KA cRig6W8JS9vOMHjFoQPz8ilOAfgRRATqzu4qjsiAPGVU9ooqG69dvy/GN7keQHsS0rDO uiLi+eDNHHzcGTpGxIscPr4fK/R3Iu+4eAUgWps5sZ/PWbvdYSwGwp5YPi5Z1rWzLLwy GvdR/w8vv0NW/Nh1aWbJshuQIkXx5pKBMs4e7ctlEX2//2+XxH0DXvsAaFRYe+Du64U4 CUlQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version; bh=Tn4ciUEqYDRuzKpYldMo242AzTN0dml31bWeRYNSHM0=; b=BHRd/6PGaqLon2w0WMSH7PjD+3Ykgcsu9zkb32zaBSYGdVXHzW2QtAHgYN7VE5QzTN 6fH7daeuezWH0hMVROz8eeSRZVSaYYByRWxC9lgnGi2B7r7nW+qZDFXPlaSRS0hmwsNZ IxTitH2UgV9jnfuf0ibKjF0p97r3wZDX6iBH6TZTXHnFu1mitmd1bmjZO/l1VI1EkMza MwCs5R2pjOToxYpLsyWf/Y6qOhrhKXgXA8uteWcON7tp3t1GVfvcUhvpF4ecYW7mn/W+ v0NtFYBtigmiywzA2hA5QjXywCyGziPN+FZH8JLcmSbynN3Yr6qGASK2P25cGRNjV9Cf rxqw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id cb14si1529229edb.161.2020.06.04.04.53.26; Thu, 04 Jun 2020 04:53:50 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728005AbgFDLu0 (ORCPT + 99 others); Thu, 4 Jun 2020 07:50:26 -0400 Received: from mail-oi1-f196.google.com ([209.85.167.196]:37376 "EHLO mail-oi1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726175AbgFDLu0 (ORCPT ); Thu, 4 Jun 2020 07:50:26 -0400 Received: by mail-oi1-f196.google.com with SMTP id m67so4798950oif.4 for ; Thu, 04 Jun 2020 04:50:25 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=Tn4ciUEqYDRuzKpYldMo242AzTN0dml31bWeRYNSHM0=; b=KJnrLSn0kiIjQoqS0lpyyT9rrb1jl/I56RqF9qBRdrQaxTzJy87ExvjIEzi00U3zu9 FqlN4mWk+rvpzlprQTGagqowEQDFMzRJ0sD7Y1scwSH6tSOBuf//0CtssTc0Gpk5VP91 Kg6Z6tmS7O1fpd/MTo7ItZzxAH6jhv4cJlG8U6OGdUnB7/rbY9k89PvhE5686kKle3fO 40ucxS4jK0ZSrZcjT7q+Dbxf+QF8OnPalS8wwT4y/4GsUkSy23ygxoXKhKnxswv2wkzD 7RRD+sTeAwFkkJMp7Eh12KHKMJ8AsvfitYW/08oO4U5Ozqth8RJnX105EP/SXgzGLfX4 pLvA== X-Gm-Message-State: AOAM533gZJcXjNHlLPcRswlMm3Vmmj7BfycnqforC/KVvx0bQ0oOLUn0 kcGKLA5evL3+TWLeN+fFUC5P77pkteG2hKSjWXw= X-Received: by 2002:aca:1a19:: with SMTP id a25mr2821601oia.54.1591271425314; Thu, 04 Jun 2020 04:50:25 -0700 (PDT) MIME-Version: 1.0 References: <20200602223728.32722-1-richard.weiyang@gmail.com> In-Reply-To: <20200602223728.32722-1-richard.weiyang@gmail.com> From: Geert Uytterhoeven Date: Thu, 4 Jun 2020 13:50:13 +0200 Message-ID: Subject: Re: [Patch v2] lib: test get_count_order/long in test_bitops.c To: Wei Yang Cc: Andrew Morton , Andy Shevchenko , Christian Brauner , Linux Kernel Mailing List Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Wei, On Wed, Jun 3, 2020 at 1:11 AM Wei Yang wrote: > Add some test for get_count_order/long in test_bitops.c. > > Signed-off-by: Wei Yang 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. > 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? 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