lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Fri, 27 Dec 2019 14:08:11 +0100
From:   SeongJae Park <sjpark@...zon.com>
To:     Bernd Petrovitsch <bernd@...rovitsch.priv.at>
CC:     SeongJae Park <sjpark@...zon.com>, <joe@...ches.com>,
        <brendanhiggins@...gle.com>, <linux-kselftest@...r.kernel.org>,
        <kunit-dev@...glegroups.com>, <linux-kernel@...r.kernel.org>,
        SeongJae Park <sj38.park@...il.com>
Subject: Re: Re: What is the best way to compare an unsigned and a constant?

On Fri, 27 Dec 2019 13:52:27 +0100 Bernd Petrovitsch <bernd@...rovitsch.priv.at> wrote:

> --------------D98A0A31D62B0BC2939BAEE9
> Content-Type: text/plain; charset="utf-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 ku=
> nit
> > test for the function, as below.
> >=20
> >     unsigned long foo(void)
> >     {
> >     	return 42;
> >     }
> >=20
> >     static void foo_test(struct kunit *test)
> >     {
> >         KUNIT_EXPECT_EQ(test, 42, foo());
> >     }
> 
> For this case: shouldn't=20
> ----  snip  ----
> static void foo_test(struct kunit *test)
> {
>      KUNIT_EXPECT_EQ(test, 42ul, foo());
> }
> ----  snip  ----
> do the trick?

Thank you for quick answer :)
That makes 'checkpatch.pl' be silent, but unfortunately, not kunit.

    [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 ‘damon_test_foo’:
    /.../linux/include/linux/kernel.h:842:29: warning: comparison of distinct pointer types lacks a cast
       (!!(sizeof((typeof(x) *)1 == (typeof(y) *)1)))
                                 ^
    /.../linux/include/kunit/test.h:493:9: note: in expansion of macro ‘__typecheck’
      ((void)__typecheck(__left, __right));           \
             ^~~~~~~~~~~
    /.../linux/include/kunit/test.h:517:2: note: in expansion of macro ‘KUNIT_BASE_BINARY_ASSERTION’
      KUNIT_BASE_BINARY_ASSERTION(test,           \
      ^~~~~~~~~~~~~~~~~~~~~~~~~~~
    /.../linux/include/kunit/test.h:606:2: note: in expansion of macro ‘KUNIT_BASE_EQ_MSG_ASSERTION’
      KUNIT_BASE_EQ_MSG_ASSERTION(test,           \
      ^~~~~~~~~~~~~~~~~~~~~~~~~~~
    /.../linux/include/kunit/test.h:616:2: note: in expansion of macro ‘KUNIT_BINARY_EQ_MSG_ASSERTION’
      KUNIT_BINARY_EQ_MSG_ASSERTION(test,           \
      ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    /.../linux/include/kunit/test.h:979:2: note: in expansion of macro ‘KUNIT_BINARY_EQ_ASSERTION’
      KUNIT_BINARY_EQ_ASSERTION(test, KUNIT_EXPECTATION, left, right)
      ^~~~~~~~~~~~~~~~~~~~~~~~~
    /.../linux/mm/damon-test.h:565:2: note: in expansion of macro ‘KUNIT_EXPECT_EQ’
      KUNIT_EXPECT_EQ(test, 42ul, (int)foo());
      ^~~~~~~~~~~~~~~

Thanks,
SeongJae Park

> 
> MfG,
> 	Bernd
> --=20
> "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
> 

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ