Re: [PATCH 2/2] kunit: Assign strings to 'const char*' in STREQ assertions

From: Brendan Higgins
Date: Fri May 07 2021 - 16:07:44 EST


On Thu, May 6, 2021 at 10:09 PM David Gow <davidgow@xxxxxxxxxx> 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@xxxxxxxxxx>

Aside from the nit that Daniel pointed out, this looks good to me.

Reviewed-by: Brendan Higgins <brendanhiggins@xxxxxxxxxx>