kunit: remove format func from struct kunit_assert, get it to 0 bytes
authorDaniel Latypov <dlatypov@google.com>
Sat, 1 Oct 2022 00:26:35 +0000 (17:26 -0700)
committerShuah Khan <skhan@linuxfoundation.org>
Fri, 7 Oct 2022 16:16:38 +0000 (10:16 -0600)
commita8495ad8e973cb6aabbe855d3dfb66ec4c9b281a
tree01df61328151879a83ecef8445c4dd4f0be0413a
parent3c4fc7bf4c9e66fe71abcbf93f62f4ddb89b7f15
kunit: remove format func from struct kunit_assert, get it to 0 bytes

Each calll to a KUNIT_EXPECT_*() macro creates a local variable which
contains a struct kunit_assert.

Normally, we'd hope the compiler would be able to optimize this away,
but we've seen cases where it hasn't, see
https://groups.google.com/g/kunit-dev/c/i3fZXgvBrfA/m/GbrMNej2BAAJ.

In changes like commit 21957f90b28f ("kunit: split out part of
kunit_assert into a static const"), we've moved more and more parts out
of struct kunit_assert and its children types (kunit_binary_assert).

This patch removes the final field and gets us to:
  sizeof(struct kunit_assert) == 0
  sizeof(struct kunit_binary_assert) == 24 (on UML x86_64).

This also reduces the amount of macro plumbing going on at the cost of
passing in one more arg to the base KUNIT_ASSERTION macro and
kunit_do_failed_assertion().

Signed-off-by: Daniel Latypov <dlatypov@google.com>
Reviewed-by: David Gow <davidgow@google.com>
Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>
include/kunit/assert.h
include/kunit/test.h
lib/kunit/test.c