[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAFd5g47NR_OKQfxDxc_PnXKCbkKNUeUH49Q6k6m=70C4uhQ0xQ@mail.gmail.com>
Date: Fri, 7 May 2021 13:07:29 -0700
From: Brendan Higgins <brendanhiggins@...gle.com>
To: David Gow <davidgow@...gle.com>
Cc: Daniel Latypov <dlatypov@...gle.com>,
Shuah Khan <skhan@...uxfoundation.org>,
kunit-dev@...glegroups.com, linux-kselftest@...r.kernel.org,
linux-kernel@...r.kernel.org
Subject: Re: [PATCH 2/2] kunit: Assign strings to 'const char*' in STREQ assertions
On Thu, May 6, 2021 at 10:09 PM David Gow <davidgow@...gle.com> wrote:
>
> Currently, the KUNIT_EXPECT_STREQ() and related macros assign both
> string arguments to variables of their own type (via typeof()). This
> seems to be to prevent the macro argument from being evaluated multiple
> times.
>
> However, yhis doesn't work if one of these is a fixed-length character
> array, rather than a character pointer, as (for example) char[16] will
> always allocate a new string.
>
> By always using 'const char*' (the type strcmp expects), we're always
> just taking a pointer to the string, which works even with character
> arrays.
>
> Signed-off-by: David Gow <davidgow@...gle.com>
Aside from the nit that Daniel pointed out, this looks good to me.
Reviewed-by: Brendan Higgins <brendanhiggins@...gle.com>
Powered by blists - more mailing lists