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:   Mon, 2 May 2022 14:43:59 -0500
From:   Daniel Latypov <dlatypov@...gle.com>
To:     Miguel Ojeda <ojeda@...nel.org>
Cc:     Brendan Higgins <brendanhiggins@...gle.com>,
        linux-kselftest@...r.kernel.org, kunit-dev@...glegroups.com,
        linux-kernel@...r.kernel.org
Subject: Re: [PATCH] kunit: take `kunit_assert` as `const`

On Mon, May 2, 2022 at 4:36 AM Miguel Ojeda <ojeda@...nel.org> wrote:
>
> The `kunit_do_failed_assertion` function passes its
> `struct kunit_assert` argument to `kunit_fail`. This one,
> in turn, calls its `format` field passing the assert again
> as a `const` pointer.
>
> Therefore, the whole chain may be made `const`.
>
> Signed-off-by: Miguel Ojeda <ojeda@...nel.org>

Reviewed-by: Daniel Latypov <dlatypov@...gle.com>

Thanks for this, the code definitely should have been this way from the start.

I had wanted to make this change but mistakenly thought the format
func took it via non-const for some reason.
I must have misread it once and got it into my head that we were
leaving the door open for mutable child structs (which sounds like a
bad idea).

> ---
>  include/kunit/test.h | 2 +-
>  lib/kunit/test.c     | 4 ++--
>  2 files changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/include/kunit/test.h b/include/kunit/test.h
> index 00b9ff7783ab..2eff4f1beb42 100644
> --- a/include/kunit/test.h
> +++ b/include/kunit/test.h
> @@ -774,7 +774,7 @@ void __printf(2, 3) kunit_log_append(char *log, const char *fmt, ...);
>  void kunit_do_failed_assertion(struct kunit *test,
>                                const struct kunit_loc *loc,
>                                enum kunit_assert_type type,
> -                              struct kunit_assert *assert,
> +                              const struct kunit_assert *assert,
>                                const char *fmt, ...);
>
>  #define KUNIT_ASSERTION(test, assert_type, pass, assert_class, INITIALIZER, fmt, ...) do { \
> diff --git a/lib/kunit/test.c b/lib/kunit/test.c
> index 3bca3bf5c15b..b84aed09a009 100644
> --- a/lib/kunit/test.c
> +++ b/lib/kunit/test.c
> @@ -241,7 +241,7 @@ static void kunit_print_string_stream(struct kunit *test,
>  }
>
>  static void kunit_fail(struct kunit *test, const struct kunit_loc *loc,
> -                      enum kunit_assert_type type, struct kunit_assert *assert,
> +                      enum kunit_assert_type type, const struct kunit_assert *assert,
>                        const struct va_format *message)
>  {
>         struct string_stream *stream;
> @@ -281,7 +281,7 @@ static void __noreturn kunit_abort(struct kunit *test)
>  void kunit_do_failed_assertion(struct kunit *test,
>                                const struct kunit_loc *loc,
>                                enum kunit_assert_type type,
> -                              struct kunit_assert *assert,
> +                              const struct kunit_assert *assert,
>                                const char *fmt, ...)
>  {
>         va_list args;
> --
> 2.35.3
>
> --
> You received this message because you are subscribed to the Google Groups "KUnit Development" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to kunit-dev+unsubscribe@...glegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/kunit-dev/20220502093625.GA23225%40kernel.org.

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ