public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH][rfc] Use int as return type of main in arch/x86/boot/main.c
@ 2011-03-13 22:00 Jesper Juhl
  2011-03-14 11:32 ` Harry Wei
                   ` (2 more replies)
  0 siblings, 3 replies; 9+ messages in thread
From: Jesper Juhl @ 2011-03-13 22:00 UTC (permalink / raw)
  To: x86; +Cc: linux-kernel, Ingo Molnar, Thomas Gleixner, H. Peter Anvin

I believe the return type of main should always be 'int'.

Signed-off-by: Jesper Juhl <jj@chaosbits.net>
---
 main.c |    4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/arch/x86/boot/main.c b/arch/x86/boot/main.c
index 40358c8..4b80da8 100644
--- a/arch/x86/boot/main.c
+++ b/arch/x86/boot/main.c
@@ -125,7 +125,7 @@ static void init_heap(void)
 	}
 }
 
-void main(void)
+int main(void)
 {
 	/* First, copy the boot header into the "zeropage" */
 	copy_boot_params();
@@ -175,4 +175,6 @@ void main(void)
 
 	/* Do the last things and invoke protected mode */
 	go_to_protected_mode();
+
+	return 0;
 }


-- 
Jesper Juhl <jj@chaosbits.net>            http://www.chaosbits.net/
Plain text mails only, please.
Don't top-post http://www.catb.org/~esr/jargon/html/T/top-post.html


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* Re: [PATCH][rfc] Use int as return type of main in arch/x86/boot/main.c
  2011-03-13 22:00 [PATCH][rfc] Use int as return type of main in arch/x86/boot/main.c Jesper Juhl
@ 2011-03-14 11:32 ` Harry Wei
  2011-03-14 16:49   ` H. Peter Anvin
  2011-03-14 19:03 ` Steven Rostedt
  2011-03-15 13:55 ` WANG Cong
  2 siblings, 1 reply; 9+ messages in thread
From: Harry Wei @ 2011-03-14 11:32 UTC (permalink / raw)
  To: Jesper Juhl
  Cc: linux-kernel, Ingo Molnar, Thomas Gleixner, H. Peter Anvin, greg,
	joe, akpm

On Sun, Mar 13, 2011 at 11:00:09PM +0100, Jesper Juhl wrote:
> I believe the return type of main should always be 'int'.
> 
> Signed-off-by: Jesper Juhl <jj@chaosbits.net>
Acked-by: Harry Wei <harryxiyou@gmail.com>
> ---
>  main.c |    4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/arch/x86/boot/main.c b/arch/x86/boot/main.c
> index 40358c8..4b80da8 100644
> --- a/arch/x86/boot/main.c
> +++ b/arch/x86/boot/main.c
> @@ -125,7 +125,7 @@ static void init_heap(void)
>  	}
>  }
>  
> -void main(void)
> +int main(void)
>  {
>  	/* First, copy the boot header into the "zeropage" */
>  	copy_boot_params();
> @@ -175,4 +175,6 @@ void main(void)
>  
>  	/* Do the last things and invoke protected mode */
>  	go_to_protected_mode();
> +
> +	return 0;
>  }
> 
> 
> -- 
> Jesper Juhl <jj@chaosbits.net>            http://www.chaosbits.net/
> Plain text mails only, please.
> Don't top-post http://www.catb.org/~esr/jargon/html/T/top-post.html
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at  http://www.tux.org/lkml/

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH][rfc] Use int as return type of main in arch/x86/boot/main.c
  2011-03-14 11:32 ` Harry Wei
@ 2011-03-14 16:49   ` H. Peter Anvin
  2011-03-14 19:04     ` Steven Rostedt
  2011-03-14 23:35     ` Jesper Juhl
  0 siblings, 2 replies; 9+ messages in thread
From: H. Peter Anvin @ 2011-03-14 16:49 UTC (permalink / raw)
  To: Jesper Juhl, linux-kernel, Ingo Molnar, Thomas Gleixner, greg,
	joe, akpm

On 03/14/2011 04:32 AM, Harry Wei wrote:
> On Sun, Mar 13, 2011 at 11:00:09PM +0100, Jesper Juhl wrote:
>> I believe the return type of main should always be 'int'.
>>
>> Signed-off-by: Jesper Juhl <jj@chaosbits.net>
> Acked-by: Harry Wei <harryxiyou@gmail.com>

It would make more sense to rename the function to something other than
main().

	-hpa


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH][rfc] Use int as return type of main in arch/x86/boot/main.c
  2011-03-13 22:00 [PATCH][rfc] Use int as return type of main in arch/x86/boot/main.c Jesper Juhl
  2011-03-14 11:32 ` Harry Wei
@ 2011-03-14 19:03 ` Steven Rostedt
  2011-03-14 22:50   ` H. Peter Anvin
  2011-03-15 13:55 ` WANG Cong
  2 siblings, 1 reply; 9+ messages in thread
From: Steven Rostedt @ 2011-03-14 19:03 UTC (permalink / raw)
  To: Jesper Juhl
  Cc: x86, linux-kernel, Ingo Molnar, Thomas Gleixner, H. Peter Anvin

On Sun, Mar 13, 2011 at 11:00:09PM +0100, Jesper Juhl wrote:
> I believe the return type of main should always be 'int'.

But this is not userspace, it is called from assmebly in header.S:

 # Jump to C code (should not return)
 calll	main

We don't care what main returns. If it does return anything, then it
dies:

# Setup corrupt somehow...
setup_bad:
        movl    $setup_corrupt, %eax
        calll   puts
        # Fall through...

        .globl  die
        .type   die, @function
die:
        hlt
        jmp     die


-- Steve

> 
> Signed-off-by: Jesper Juhl <jj@chaosbits.net>
> ---
>  main.c |    4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/arch/x86/boot/main.c b/arch/x86/boot/main.c
> index 40358c8..4b80da8 100644
> --- a/arch/x86/boot/main.c
> +++ b/arch/x86/boot/main.c
> @@ -125,7 +125,7 @@ static void init_heap(void)
>  	}
>  }
>  
> -void main(void)
> +int main(void)
>  {
>  	/* First, copy the boot header into the "zeropage" */
>  	copy_boot_params();
> @@ -175,4 +175,6 @@ void main(void)
>  
>  	/* Do the last things and invoke protected mode */
>  	go_to_protected_mode();
> +
> +	return 0;
>  }
> 
> 
> -- 
> Jesper Juhl <jj@chaosbits.net>            http://www.chaosbits.net/
> Plain text mails only, please.
> Don't top-post http://www.catb.org/~esr/jargon/html/T/top-post.html
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at  http://www.tux.org/lkml/

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH][rfc] Use int as return type of main in arch/x86/boot/main.c
  2011-03-14 16:49   ` H. Peter Anvin
@ 2011-03-14 19:04     ` Steven Rostedt
  2011-03-14 23:35     ` Jesper Juhl
  1 sibling, 0 replies; 9+ messages in thread
From: Steven Rostedt @ 2011-03-14 19:04 UTC (permalink / raw)
  To: H. Peter Anvin
  Cc: Jesper Juhl, linux-kernel, Ingo Molnar, Thomas Gleixner, greg,
	joe, akpm

On Mon, Mar 14, 2011 at 09:49:18AM -0700, H. Peter Anvin wrote:
> On 03/14/2011 04:32 AM, Harry Wei wrote:
> > On Sun, Mar 13, 2011 at 11:00:09PM +0100, Jesper Juhl wrote:
> >> I believe the return type of main should always be 'int'.
> >>
> >> Signed-off-by: Jesper Juhl <jj@chaosbits.net>
> > Acked-by: Harry Wei <harryxiyou@gmail.com>
> 
> It would make more sense to rename the function to something other than
> main().

Right, maybe "boot_start"?

-- Steve


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH][rfc] Use int as return type of main in arch/x86/boot/main.c
  2011-03-14 19:03 ` Steven Rostedt
@ 2011-03-14 22:50   ` H. Peter Anvin
  2011-03-15  2:31     ` Steven Rostedt
  0 siblings, 1 reply; 9+ messages in thread
From: H. Peter Anvin @ 2011-03-14 22:50 UTC (permalink / raw)
  To: Steven Rostedt
  Cc: Jesper Juhl, x86, linux-kernel, Ingo Molnar, Thomas Gleixner

On 03/14/2011 12:03 PM, Steven Rostedt wrote:
> On Sun, Mar 13, 2011 at 11:00:09PM +0100, Jesper Juhl wrote:
>> I believe the return type of main should always be 'int'.
> 
> But this is not userspace, it is called from assmebly in header.S:
> 
>  # Jump to C code (should not return)
>  calll	main
> 
> We don't care what main returns. If it does return anything, then it
> dies:
> 
> # Setup corrupt somehow...
> setup_bad:
>         movl    $setup_corrupt, %eax
>         calll   puts
>         # Fall through...
> 
>         .globl  die
>         .type   die, @function
> die:
>         hlt
>         jmp     die
> 

Yes, but some versions of gcc complains about a nonstandard signature to
main().  At least that's what I assume Jesper's issue was.

	-hpa

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH][rfc] Use int as return type of main in arch/x86/boot/main.c
  2011-03-14 16:49   ` H. Peter Anvin
  2011-03-14 19:04     ` Steven Rostedt
@ 2011-03-14 23:35     ` Jesper Juhl
  1 sibling, 0 replies; 9+ messages in thread
From: Jesper Juhl @ 2011-03-14 23:35 UTC (permalink / raw)
  To: H. Peter Anvin
  Cc: linux-kernel, Ingo Molnar, Thomas Gleixner, greg, joe, akpm

On Mon, 14 Mar 2011, H. Peter Anvin wrote:

> On 03/14/2011 04:32 AM, Harry Wei wrote:
> > On Sun, Mar 13, 2011 at 11:00:09PM +0100, Jesper Juhl wrote:
> >> I believe the return type of main should always be 'int'.
> >>
> >> Signed-off-by: Jesper Juhl <jj@chaosbits.net>
> > Acked-by: Harry Wei <harryxiyou@gmail.com>
> 
> It would make more sense to rename the function to something other than
> main().
> 
Right. That's probably a better aproach. Thanks.

-- 
Jesper Juhl <jj@chaosbits.net>            http://www.chaosbits.net/
Plain text mails only, please.
Don't top-post http://www.catb.org/~esr/jargon/html/T/top-post.html


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH][rfc] Use int as return type of main in arch/x86/boot/main.c
  2011-03-14 22:50   ` H. Peter Anvin
@ 2011-03-15  2:31     ` Steven Rostedt
  0 siblings, 0 replies; 9+ messages in thread
From: Steven Rostedt @ 2011-03-15  2:31 UTC (permalink / raw)
  To: H. Peter Anvin
  Cc: Jesper Juhl, x86, linux-kernel, Ingo Molnar, Thomas Gleixner

On Mon, 2011-03-14 at 15:50 -0700, H. Peter Anvin wrote:
> 
> Yes, but some versions of gcc complains about a nonstandard signature to
> main().  At least that's what I assume Jesper's issue was. 

OK, but I prefer the solution you suggested. Let's just rename it.

-- Steve



^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH][rfc] Use int as return type of main in arch/x86/boot/main.c
  2011-03-13 22:00 [PATCH][rfc] Use int as return type of main in arch/x86/boot/main.c Jesper Juhl
  2011-03-14 11:32 ` Harry Wei
  2011-03-14 19:03 ` Steven Rostedt
@ 2011-03-15 13:55 ` WANG Cong
  2 siblings, 0 replies; 9+ messages in thread
From: WANG Cong @ 2011-03-15 13:55 UTC (permalink / raw)
  To: linux-kernel

On Sun, 13 Mar 2011 23:00:09 +0100, Jesper Juhl wrote:

> I believe the return type of main should always be 'int'.
> 

In user-space, yes, but this is not true in kernel space especially here.


^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2011-03-15 13:55 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-03-13 22:00 [PATCH][rfc] Use int as return type of main in arch/x86/boot/main.c Jesper Juhl
2011-03-14 11:32 ` Harry Wei
2011-03-14 16:49   ` H. Peter Anvin
2011-03-14 19:04     ` Steven Rostedt
2011-03-14 23:35     ` Jesper Juhl
2011-03-14 19:03 ` Steven Rostedt
2011-03-14 22:50   ` H. Peter Anvin
2011-03-15  2:31     ` Steven Rostedt
2011-03-15 13:55 ` WANG Cong

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox