diff mbox series

[1/1] endian_switch01.c: Remove useless TST_NO_DEFAULT_MAIN

Message ID 20230309103346.5574-1-pvorel@suse.cz
State Accepted
Headers show
Series [1/1] endian_switch01.c: Remove useless TST_NO_DEFAULT_MAIN | expand

Commit Message

Petr Vorel March 9, 2023, 10:33 a.m. UTC
TST_NO_DEFAULT_MAIN must be defined before including tst_test.h.
Therefore test could have been compiled although there was no main() defined.

Fixes: 68fb61225 ("endian_switch01: rewrite to newlib")
Signed-off-by: Petr Vorel <pvorel@suse.cz>
---
 testcases/kernel/syscalls/switch/endian_switch01.c | 2 --
 1 file changed, 2 deletions(-)

Comments

Petr Vorel March 9, 2023, 10:44 a.m. UTC | #1
Hi Jan,

out of curiosity, what is main4() used for?

Kind regards,
Petr
Jan Stancek March 9, 2023, 11:17 a.m. UTC | #2
On Thu, Mar 9, 2023 at 11:44 AM Petr Vorel <pvorel@suse.cz> wrote:
>
> Hi Jan,
>
> out of curiosity, what is main4() used for?

It's from 086c14f7a465 ("The following hack fixes the
"endian_switch01.c:115: warning: ‘main’ takes only zero or two
arguments" warning. Signed-off-by: CAI Qian <caiqian@cclom.cn>.")
but I'm not sure it is still used these days.

As you found my misplaced TST_NO_DEFAULT_MAIN, that seems to confirm
we can do without it. I'll have a look on a ppc system.

>
> Kind regards,
> Petr
>
Jan Stancek March 9, 2023, 12:09 p.m. UTC | #3
On Thu, Mar 9, 2023 at 12:17 PM Jan Stancek <jstancek@redhat.com> wrote:
>
> On Thu, Mar 9, 2023 at 11:44 AM Petr Vorel <pvorel@suse.cz> wrote:
> >
> > Hi Jan,
> >
> > out of curiosity, what is main4() used for?
>
> It's from 086c14f7a465 ("The following hack fixes the
> "endian_switch01.c:115: warning: ‘main’ takes only zero or two
> arguments" warning. Signed-off-by: CAI Qian <caiqian@cclom.cn>.")
> but I'm not sure it is still used these days.
>
> As you found my misplaced TST_NO_DEFAULT_MAIN, that seems to confirm
> we can do without it. I'll have a look on a ppc system.

So I agree with your patch here. And then I'd suggest we follow it
with one that replaces main4 with

@@ -42,6 +42,9 @@ void check_le_switch_supported(void)
                exit(errno);
        }

+       if (!(getauxval(AT_HWCAP) & PPC_FEATURE_TRUE_LE))
+               tst_brk(TCONF, "Processor does not support little-endian mode");
+

What do you think?
Petr Vorel March 9, 2023, 9:02 p.m. UTC | #4
> On Thu, Mar 9, 2023 at 12:17 PM Jan Stancek <jstancek@redhat.com> wrote:

> > On Thu, Mar 9, 2023 at 11:44 AM Petr Vorel <pvorel@suse.cz> wrote:

> > > Hi Jan,

> > > out of curiosity, what is main4() used for?

> > It's from 086c14f7a465 ("The following hack fixes the
> > "endian_switch01.c:115: warning: ‘main’ takes only zero or two
> > arguments" warning. Signed-off-by: CAI Qian <caiqian@cclom.cn>.")
> > but I'm not sure it is still used these days.
+1

> > As you found my misplaced TST_NO_DEFAULT_MAIN, that seems to confirm
> > we can do without it. I'll have a look on a ppc system.

> So I agree with your patch here. And then I'd suggest we follow it
Thank you, I merged this patch.


> with one that replaces main4 with

> @@ -42,6 +42,9 @@ void check_le_switch_supported(void)
>                 exit(errno);
>         }

> +       if (!(getauxval(AT_HWCAP) & PPC_FEATURE_TRUE_LE))
> +               tst_brk(TCONF, "Processor does not support little-endian mode");
> +

> What do you think?

Indeed, that's looks to me better. You can add my ack to the patch.
But please test it.

Kind regards,
Petr
diff mbox series

Patch

diff --git a/testcases/kernel/syscalls/switch/endian_switch01.c b/testcases/kernel/syscalls/switch/endian_switch01.c
index bee35184a..eae193fc1 100644
--- a/testcases/kernel/syscalls/switch/endian_switch01.c
+++ b/testcases/kernel/syscalls/switch/endian_switch01.c
@@ -24,8 +24,6 @@ 
 # define PPC_FEATURE_TRUE_LE              0x00000002
 # endif
 
-# define TST_NO_DEFAULT_MAIN
-
 /*
  * Make minimal call to 0x1ebe. If we get ENOSYS then syscall is not
  * available, likely because of: