Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp264462ybl; Tue, 7 Jan 2020 05:51:19 -0800 (PST) X-Google-Smtp-Source: APXvYqyjPJHGt+ojMDQpZtCfKSy3hF7qARP0I42p09ztowz47MI7dkSSgqWMFJV1FJMQNBGmcRQZ X-Received: by 2002:a05:6808:4c7:: with SMTP id a7mr7118536oie.83.1578405079675; Tue, 07 Jan 2020 05:51:19 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1578405079; cv=none; d=google.com; s=arc-20160816; b=K4CmwoqOtUG0vLKWCA86xMGGEqXwCkh6BHi9mbp6nZjMvmL39YDuKIxEGREv7GfIIH 2jn5M7q4Lo9tcFzod8fCsBpebWwLDtNtKQQhD16kYdYSPz6vRN3pIOw/nmVMJYSGUufN nZ/GJPGQeCWcy49mTB04NLp74EQldc/1MYZsayzb6RubByfZFtmc0nLpIo/oEmo+jeTq 1l6h3xP+W1LlscihTdYpS7oj+95h/1trUhkf2+nP5Hh0VpxCCvDG0Wu/Rkxq3Rg8TAZe TlOgHuen92suR1wdarNTbEpYuJbwiAPnV4Tx1z84BzluRnVkL0nJ8IP4EPz52ncVNs/M Q/Qg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:in-reply-to:message-id:date :subject:cc:to:from:ironport-sdr:dkim-signature; bh=b7YvakxQUDhIYxvaIP9AWgD21Q+/Dpc5za+Ll0cvmyA=; b=SzBs0R6Wre6re9ou7Q/3xnPWFfaD3KEi/jpsSgxDlXLlGmdemFz6GDbq3XEYwtsknV 08wbDRYJd0vEiwigi8bqbn2yKbphuP2SByXHsYEtpzZ1oj8dyVEMU8Aw2eCL6uxBN25P OeuhpJMgik+9cGjiSgVXJ3S0jXlR4m/HylOmZiZ50Ke0ylA0BBP9dCPh8rdm6LKdNB/P qha/hlwVCSULgugj51l/6lTQcsASAEq60SYuoMdNh6TfNsngvyAZsZCsn70Gnm6grn0h QD3wqucrJBCZdPpkqzCrt6CbmIWg++NSX2WzDYMqbh437ylexCtU5KRZI6syvlMt6Ev6 VkhA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amazon.com header.s=amazon201209 header.b=dT99APbD; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amazon.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d3si18974737oia.236.2020.01.07.05.51.06; Tue, 07 Jan 2020 05:51:19 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@amazon.com header.s=amazon201209 header.b=dT99APbD; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amazon.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728037AbgAGNto (ORCPT + 99 others); Tue, 7 Jan 2020 08:49:44 -0500 Received: from smtp-fw-9102.amazon.com ([207.171.184.29]:17623 "EHLO smtp-fw-9102.amazon.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727944AbgAGNtn (ORCPT ); Tue, 7 Jan 2020 08:49:43 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.com; i=@amazon.com; q=dns/txt; s=amazon201209; t=1578404984; x=1609940984; h=from:to:cc:subject:date:message-id:in-reply-to: mime-version; bh=b7YvakxQUDhIYxvaIP9AWgD21Q+/Dpc5za+Ll0cvmyA=; b=dT99APbDX8WMAzafx3B8f95/9xO4fvleBjqyIk6v96dvO6PO52gjVvPk fRhhuA4cKDye1YfFrj70R5lTw62V0W6T3TvwxpNWrMoeCizEDVxphcWgS U8ExARa4Bcw1TrbvWmprHDJ0MxIO30zr65nVPg+SkIo+Ujg/CSGh+PQvo 8=; IronPort-SDR: +Orc/lmc0ipZQOdDDcYTpgvJiEqgvHzto1KG0KJliFle6CUe+TAtUYAMMz6jQWJnzCEk4rpOsE ncanrSeUR9wg== X-IronPort-AV: E=Sophos;i="5.69,406,1571702400"; d="scan'208";a="17221127" Received: from sea32-co-svc-lb4-vlan3.sea.corp.amazon.com (HELO email-inbound-relay-1e-57e1d233.us-east-1.amazon.com) ([10.47.23.38]) by smtp-border-fw-out-9102.sea19.amazon.com with ESMTP; 07 Jan 2020 13:49:32 +0000 Received: from EX13MTAUEA002.ant.amazon.com (iad55-ws-svc-p15-lb9-vlan3.iad.amazon.com [10.40.159.166]) by email-inbound-relay-1e-57e1d233.us-east-1.amazon.com (Postfix) with ESMTPS id B2780141623; Tue, 7 Jan 2020 13:49:27 +0000 (UTC) Received: from EX13D31EUA001.ant.amazon.com (10.43.165.15) by EX13MTAUEA002.ant.amazon.com (10.43.61.77) with Microsoft SMTP Server (TLS) id 15.0.1236.3; Tue, 7 Jan 2020 13:49:27 +0000 Received: from u886c93fd17d25d.ant.amazon.com (10.43.161.244) by EX13D31EUA001.ant.amazon.com (10.43.165.15) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Tue, 7 Jan 2020 13:49:23 +0000 From: SeongJae Park To: Brendan Higgins CC: SeongJae Park , Bernd Petrovitsch , "open list:KERNEL SELFTEST FRAMEWORK" , KUnit Development , Linux Kernel Mailing List , SeongJae Park Subject: Re: Re: Re: What is the best way to compare an unsigned and a constant? Date: Tue, 7 Jan 2020 14:49:10 +0100 Message-ID: <20200107134910.20347-1-sjpark@amazon.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.43.161.244] X-ClientProxiedBy: EX13D06UWC004.ant.amazon.com (10.43.162.97) To EX13D31EUA001.ant.amazon.com (10.43.165.15) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, 7 Jan 2020 05:35:21 -0800 Brendan Higgins wrote: > Sorry for the delay, I was on vacation. (I still am, but I was too ;-).) Happy new year, Brendan :) > > On Tue, Jan 7, 2020 at 3:52 AM SeongJae Park wrote: > > > > On Fri, 27 Dec 2019 13:52:27 +0100 Bernd Petrovitsch ch.priv.at> wrote: > > > > > This is a multi-part message in MIME format. > > > --------------D98A0A31D62B0BC2939BAEE9 > > > Content-Type: text/plain; charset=3Dutf-8 > > > Content-Transfer-Encoding: quoted-printable > > > > > > Hi all! > > > > > > On 27/12/2019 13:39, SeongJae Park wrote: > > > [...] > > > > I have a function returning 'unsigned long', and would like to write = > a =3D > > > kunit > > > > test for the function, as below. > > > >=3D20 > > > > unsigned long foo(void) > > > > { > > > > return 42; > > > > } > > > >=3D20 > > > > static void foo_test(struct kunit *test) > > > > { > > > > KUNIT_EXPECT_EQ(test, 42, foo()); > > > > } > > > > > > For this case: shouldn't=3D20 > > > ---- snip ---- > > > static void foo_test(struct kunit *test) > > > { > > > KUNIT_EXPECT_EQ(test, 42ul, foo()); > > > } > > > ---- snip ---- > > > do the trick? > > > > Unfortunately, it doesn't works. > > > > [13:04:58] Building KUnit Kernel ... > > In file included from /.../linux/include/linux/list.h:9:0, > > from /.../linux/include/linux/wait.h:7, > > from /.../linux/include/linux/wait_bit.h:8, > > from /.../linux/include/linux/fs.h:6, > > from /.../linux/include/linux/debugfs.h:15, > > from /.../linux/mm/damon.c:12: > > /.../linux/mm/damon-test.h: In function =E2=80=98damon_test_foo=E2=80= > =99: > > /.../linux/include/linux/kernel.h:842:29: warning: comparison of dist= > inct pointer types lacks a cast > > (!!(sizeof((typeof(x) *)1 =3D=3D (typeof(y) *)1))) > > ^ > > /.../linux/include/kunit/test.h:493:9: note: in expansion of macro = > =E2=80=98__typecheck=E2=80=99 > > ((void)__typecheck(__left, __right)); \ > > ^~~~~~~~~~~ > > /.../linux/include/kunit/test.h:517:2: note: in expansion of macro = > =E2=80=98KUNIT_BASE_BINARY_ASSERTION=E2=80=99 > > KUNIT_BASE_BINARY_ASSERTION(test, \ > > ^~~~~~~~~~~~~~~~~~~~~~~~~~~ > > /.../linux/include/kunit/test.h:606:2: note: in expansion of macro = > =E2=80=98KUNIT_BASE_EQ_MSG_ASSERTION=E2=80=99 > > KUNIT_BASE_EQ_MSG_ASSERTION(test, \ > > ^~~~~~~~~~~~~~~~~~~~~~~~~~~ > > /.../linux/include/kunit/test.h:616:2: note: in expansion of macro = > =E2=80=98KUNIT_BINARY_EQ_MSG_ASSERTION=E2=80=99 > > KUNIT_BINARY_EQ_MSG_ASSERTION(test, \ > > ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > > /.../linux/include/kunit/test.h:979:2: note: in expansion of macro = > =E2=80=98KUNIT_BINARY_EQ_ASSERTION=E2=80=99 > > KUNIT_BINARY_EQ_ASSERTION(test, KUNIT_EXPECTATION, left, right) > > ^~~~~~~~~~~~~~~~~~~~~~~~~ > > /.../linux/mm/damon-test.h:565:2: note: in expansion of macro =E2=80= > =98KUNIT_EXPECT_EQ=E2=80=99 > > KUNIT_EXPECT_EQ(test, 42ul, (int)foo()); > > ^~~~~~~~~~~~~~~ > > Isn't the issue here that you fixed the 42, but are now casting the > result of foo() to an int? Oh, right... Removing the non-sense casting fixed the problem. Thanks, Brendan! Thanks, SeongJae Park > > Or have you fixed that now too? > > Worst case (gross) scenario, you could just cast 42 to whatever type > foo() returns. > > > Some other thoughts? > > > > > > Thanks, > > SeongJae Park > > > > > > > > > > MfG, > > > Bernd > > > --=3D20 > > > "I dislike type abstraction if it has no real reason. And saving > > > on typing is not a good reason - if your typing speed is the main > > > issue when you're coding, you're doing something seriously wrong." > > > - Linus Torvalds >