]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
selftests: harness: remove unneeded __constructor_order_last()
authorMasahiro Yamada <masahiroy@kernel.org>
Sat, 27 Jul 2024 14:37:36 +0000 (23:37 +0900)
committerShuah Khan <skhan@linuxfoundation.org>
Tue, 6 Aug 2024 19:40:20 +0000 (13:40 -0600)
__constructor_order_last() is unneeded.

If __constructor_order_last() is not called on backward-order systems,
__constructor_order will remain 0 instead of being set to
_CONSTRUCTOR_ORDER_BACKWARD (= -1).

__LIST_APPEND() will still take the 'else' branch, so there is no
difference in the behavior.

Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>
tools/testing/selftests/drivers/s390x/uvdevice/test_uvdevice.c
tools/testing/selftests/hid/hid_bpf.c
tools/testing/selftests/kselftest_harness.h
tools/testing/selftests/rtc/rtctest.c

index ea0cdc37b44fa27797500a4dc253663eb800ec93..7ee7492138c675d7b7a038182d3fec631cc36a02 100644 (file)
@@ -257,12 +257,6 @@ TEST_F(attest_fixture, att_inval_addr)
        att_inval_addr_test(&self->uvio_attest.meas_addr, _metadata, self);
 }
 
-static void __attribute__((constructor)) __constructor_order_last(void)
-{
-       if (!__constructor_order)
-               __constructor_order = _CONSTRUCTOR_ORDER_BACKWARD;
-}
-
 int main(int argc, char **argv)
 {
        int fd = open(UV_PATH, O_ACCMODE);
index dc0408a831d07c7296ba9c0ff1ede75ff07c3481..f2bd20ca88bb7b9a3442ae3cdc053bc26534820c 100644 (file)
@@ -1331,12 +1331,6 @@ static int libbpf_print_fn(enum libbpf_print_level level,
        return 0;
 }
 
-static void __attribute__((constructor)) __constructor_order_last(void)
-{
-       if (!__constructor_order)
-               __constructor_order = _CONSTRUCTOR_ORDER_BACKWARD;
-}
-
 int main(int argc, char **argv)
 {
        /* Use libbpf 1.0 API mode */
index 40723a6a083f4223e47fbc617e353cc12662d415..71648d2102cbf9fa337426a7b8fa83c45dd3079a 100644 (file)
  * Use once to append a main() to the test file.
  */
 #define TEST_HARNESS_MAIN \
-       static void __attribute__((constructor)) \
-       __constructor_order_last(void) \
-       { \
-               if (!__constructor_order) \
-                       __constructor_order = _CONSTRUCTOR_ORDER_BACKWARD; \
-       } \
        int main(int argc, char **argv) { \
                return test_harness_run(argc, argv); \
        }
@@ -891,7 +885,6 @@ static struct __fixture_metadata *__fixture_list = &_fixture_global;
 static int __constructor_order;
 
 #define _CONSTRUCTOR_ORDER_FORWARD   1
-#define _CONSTRUCTOR_ORDER_BACKWARD -1
 
 static inline void __register_fixture(struct __fixture_metadata *f)
 {
@@ -1337,8 +1330,7 @@ static int test_harness_run(int argc, char **argv)
 
 static void __attribute__((constructor)) __constructor_order_first(void)
 {
-       if (!__constructor_order)
-               __constructor_order = _CONSTRUCTOR_ORDER_FORWARD;
+       __constructor_order = _CONSTRUCTOR_ORDER_FORWARD;
 }
 
 #endif  /* __KSELFTEST_HARNESS_H */
index 63ce02d1d5ccfafd43bcb5136f4041f77cdae8e6..9647b14b47c59e5d0ac603de9b7fb9b18072db29 100644 (file)
@@ -410,13 +410,6 @@ TEST_F_TIMEOUT(rtc, alarm_wkalm_set_minute, 65) {
        ASSERT_EQ(new, secs);
 }
 
-static void __attribute__((constructor))
-__constructor_order_last(void)
-{
-       if (!__constructor_order)
-               __constructor_order = _CONSTRUCTOR_ORDER_BACKWARD;
-}
-
 int main(int argc, char **argv)
 {
        switch (argc) {