mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH 0/4] Fixes for x86
@ 2011-11-09 21:39 Lucas De Marchi
  2011-11-09 21:39 ` [PATCH 1/4] Make fprintf return number of bytes written Lucas De Marchi
                   ` (4 more replies)
  0 siblings, 5 replies; 11+ messages in thread
From: Lucas De Marchi @ 2011-11-09 21:39 UTC (permalink / raw)
  To: barebox

The following patches are fixes for x86 in order to be able to build barebox
with ARCH=x86 and generic_defconfig. Patch 3 fixes build for any version of gcc
while the last one is specific to gcc 4.6 (I'm not sure about gcc 4.5).

With gcc 4.6 there's still an error, but when it's linking barebox, that I
didn't find out how to fix. I thought the problem was in the linker or linker
script but they seem to be ok since it works when compiled with gcc 4.4. The
error is the following:

  LD      barebox
ld: section .eh_frame loaded at [0000000000011a54,0000000000018ac3] overlaps section .barebox_initcalls loaded at [0000000000011a54,0000000000011a9b]
make: *** [barebox] Error 1


Regards,
Lucas De Marchi



Lucas De Marchi (4):
  Make fprintf return number of bytes written
  Add setupmbr to gitignore
  x86: fix build error because of missing header
  x86: fix symbol size calculation

 arch/x86/boot/pmjump.S           |    3 ++-
 arch/x86/include/asm/types.h     |    2 ++
 arch/x86/include/asm/unaligned.h |   14 ++++++++++++++
 arch/x86/lib/traveler.S          |   11 +++++++----
 common/console.c                 |    4 +++-
 common/console_simple.c          |    4 +++-
 include/stdio.h                  |    2 +-
 scripts/setupmbr/.gitignore      |    1 +
 8 files changed, 33 insertions(+), 8 deletions(-)
 create mode 100644 arch/x86/include/asm/unaligned.h
 create mode 100644 scripts/setupmbr/.gitignore

-- 
1.7.7.2


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

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

* [PATCH 1/4] Make fprintf return number of bytes written
  2011-11-09 21:39 [PATCH 0/4] Fixes for x86 Lucas De Marchi
@ 2011-11-09 21:39 ` Lucas De Marchi
  2011-11-10 10:53   ` Marc Kleine-Budde
  2011-11-11 11:27   ` Sascha Hauer
  2011-11-09 21:39 ` [PATCH 2/4] Add setupmbr to gitignore Lucas De Marchi
                   ` (3 subsequent siblings)
  4 siblings, 2 replies; 11+ messages in thread
From: Lucas De Marchi @ 2011-11-09 21:39 UTC (permalink / raw)
  To: barebox

Return number of bytes written, like its siblings function. This also
removes the warning below on gcc >= 4.6.

common/console.c:333:7: warning: variable ‘i’ set but not used
[-Wunused-but-set-variable]

Signed-off-by: Lucas De Marchi <lucas.demarchi@profusion.mobi>
---
 common/console.c        |    4 +++-
 common/console_simple.c |    4 +++-
 include/stdio.h         |    2 +-
 3 files changed, 7 insertions(+), 3 deletions(-)

diff --git a/common/console.c b/common/console.c
index 06e9c29..7f2810e 100644
--- a/common/console.c
+++ b/common/console.c
@@ -327,7 +327,7 @@ void console_flush(void)
 }
 EXPORT_SYMBOL(console_flush);
 
-void fprintf (int file, const char *fmt, ...)
+int fprintf (int file, const char *fmt, ...)
 {
 	va_list args;
 	uint i;
@@ -343,6 +343,8 @@ void fprintf (int file, const char *fmt, ...)
 
 	/* Print the string */
 	fputs (file, printbuffer);
+
+        return i;
 }
 EXPORT_SYMBOL(fprintf);
 
diff --git a/common/console_simple.c b/common/console_simple.c
index 7304d8e..d73af98 100644
--- a/common/console_simple.c
+++ b/common/console_simple.c
@@ -45,7 +45,7 @@ int vprintf (const char *fmt, va_list args)
 }
 EXPORT_SYMBOL(vprintf);
 
-void fprintf (int file, const char *fmt, ...)
+int fprintf (int file, const char *fmt, ...)
 {
 	va_list args;
 	uint i;
@@ -61,6 +61,8 @@ void fprintf (int file, const char *fmt, ...)
 
 	/* Print the string */
 	fputs(file, printbuffer);
+
+        return i;
 }
 EXPORT_SYMBOL(fprintf);
 
diff --git a/include/stdio.h b/include/stdio.h
index a0d81d3..0c68fa8 100644
--- a/include/stdio.h
+++ b/include/stdio.h
@@ -54,7 +54,7 @@ int	vscnprintf(char *buf, size_t size, const char *fmt, va_list args);
 #define stderr		2
 #define MAX_FILES	128
 
-void	fprintf(int file, const char *fmt, ...) __attribute__ ((format(__printf__, 2, 3)));
+int	fprintf(int file, const char *fmt, ...) __attribute__ ((format(__printf__, 2, 3)));
 int	fputs(int file, const char *s);
 int	fputc(int file, const char c);
 int	ftstc(int file);
-- 
1.7.7.2


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

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

* [PATCH 2/4] Add setupmbr to gitignore
  2011-11-09 21:39 [PATCH 0/4] Fixes for x86 Lucas De Marchi
  2011-11-09 21:39 ` [PATCH 1/4] Make fprintf return number of bytes written Lucas De Marchi
@ 2011-11-09 21:39 ` Lucas De Marchi
  2011-11-09 21:39 ` [PATCH 3/4] x86: fix build error because of missing header Lucas De Marchi
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 11+ messages in thread
From: Lucas De Marchi @ 2011-11-09 21:39 UTC (permalink / raw)
  To: barebox

Signed-off-by: Lucas De Marchi <lucas.demarchi@profusion.mobi>
---
 scripts/setupmbr/.gitignore |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)
 create mode 100644 scripts/setupmbr/.gitignore

diff --git a/scripts/setupmbr/.gitignore b/scripts/setupmbr/.gitignore
new file mode 100644
index 0000000..a7301f9
--- /dev/null
+++ b/scripts/setupmbr/.gitignore
@@ -0,0 +1 @@
+setupmbr
-- 
1.7.7.2


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

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

* [PATCH 3/4] x86: fix build error because of missing header
  2011-11-09 21:39 [PATCH 0/4] Fixes for x86 Lucas De Marchi
  2011-11-09 21:39 ` [PATCH 1/4] Make fprintf return number of bytes written Lucas De Marchi
  2011-11-09 21:39 ` [PATCH 2/4] Add setupmbr to gitignore Lucas De Marchi
@ 2011-11-09 21:39 ` Lucas De Marchi
  2011-11-09 21:39 ` [PATCH 4/4] x86: fix symbol size calculation Lucas De Marchi
  2011-11-11 11:29 ` [PATCH 0/4] Fixes for x86 Sascha Hauer
  4 siblings, 0 replies; 11+ messages in thread
From: Lucas De Marchi @ 2011-11-09 21:39 UTC (permalink / raw)
  To: barebox

Signed-off-by: Lucas De Marchi <lucas.demarchi@profusion.mobi>
---
 arch/x86/include/asm/types.h     |    2 ++
 arch/x86/include/asm/unaligned.h |   14 ++++++++++++++
 2 files changed, 16 insertions(+), 0 deletions(-)
 create mode 100644 arch/x86/include/asm/unaligned.h

diff --git a/arch/x86/include/asm/types.h b/arch/x86/include/asm/types.h
index 17c5fd7..d520869 100644
--- a/arch/x86/include/asm/types.h
+++ b/arch/x86/include/asm/types.h
@@ -39,6 +39,8 @@ typedef unsigned short u16;
 
 typedef unsigned int u32;
 
+typedef unsigned long long u64;
+
 #endif /* __ASSEMBLY__ */
 
 #endif /* __ASM_X86_TYPES_H */
diff --git a/arch/x86/include/asm/unaligned.h b/arch/x86/include/asm/unaligned.h
new file mode 100644
index 0000000..a7bd416
--- /dev/null
+++ b/arch/x86/include/asm/unaligned.h
@@ -0,0 +1,14 @@
+#ifndef _ASM_X86_UNALIGNED_H
+#define _ASM_X86_UNALIGNED_H
+
+/*
+ * The x86 can do unaligned accesses itself.
+ */
+
+#include <linux/unaligned/access_ok.h>
+#include <linux/unaligned/generic.h>
+
+#define get_unaligned __get_unaligned_le
+#define put_unaligned __put_unaligned_le
+
+#endif /* _ASM_X86_UNALIGNED_H */
-- 
1.7.7.2


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

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

* [PATCH 4/4] x86: fix symbol size calculation
  2011-11-09 21:39 [PATCH 0/4] Fixes for x86 Lucas De Marchi
                   ` (2 preceding siblings ...)
  2011-11-09 21:39 ` [PATCH 3/4] x86: fix build error because of missing header Lucas De Marchi
@ 2011-11-09 21:39 ` Lucas De Marchi
  2011-11-11 11:29 ` [PATCH 0/4] Fixes for x86 Sascha Hauer
  4 siblings, 0 replies; 11+ messages in thread
From: Lucas De Marchi @ 2011-11-09 21:39 UTC (permalink / raw)
  To: barebox

The size is being calculated after changing to another section, which
gives error with gcc 4.6:

  AS      arch/x86/lib/traveler.o
/tmp/ccP0z8xx.s: Assembler messages:
/tmp/ccP0z8xx.s: Error: .size expression for real_to_prot does not evaluate to a constant
/tmp/ccP0z8xx.s: Error: .size expression for prot_to_real does not evaluate to a constant
make[1]: *** [arch/x86/lib/traveler.o] Error 1

Signed-off-by: Lucas De Marchi <lucas.demarchi@profusion.mobi>
---
 arch/x86/boot/pmjump.S  |    3 ++-
 arch/x86/lib/traveler.S |   11 +++++++----
 2 files changed, 9 insertions(+), 5 deletions(-)

diff --git a/arch/x86/boot/pmjump.S b/arch/x86/boot/pmjump.S
index d2fb8f0..09bfc6e 100644
--- a/arch/x86/boot/pmjump.S
+++ b/arch/x86/boot/pmjump.S
@@ -44,6 +44,7 @@ protected_mode_jump:
 
 	/* Transition to 32-bit flat mode */
 	data32  ljmp $__BOOT_CS, $in_pm32
+	.size protected_mode_jump, .-protected_mode_jump
 
 /* ------------------------------------------------------------------------ */
 
@@ -83,5 +84,5 @@ in_pm32:
 
 	jmp uboot_entry
 
-	.size protected_mode_jump, .-protected_mode_jump
+	.size in_pm32, .-in_pm32
 
diff --git a/arch/x86/lib/traveler.S b/arch/x86/lib/traveler.S
index 0614195..4f7a9e3 100644
--- a/arch/x86/lib/traveler.S
+++ b/arch/x86/lib/traveler.S
@@ -72,6 +72,7 @@ real_to_prot:
 
 	/* jump to relocation, flush prefetch queue, and reload %cs */
 	DATA32 ljmp $__BOOT_CS, $return_to_flatmode
+	.size real_to_prot, .-real_to_prot
 
 /* ----------------------------------------------------------------------- */
 	.section .boot.text.return_to_flatmode, "ax"
@@ -102,8 +103,7 @@ return_to_flatmode:
 	/* flag we returned happy here */
 	xorl %eax, %eax
 	ret
-
-	.size real_to_prot, .-real_to_prot
+	.size return_to_flatmode, .-return_to_flatmode
 
 /* ------------------------------------------------------------------------ */
 
@@ -140,13 +140,16 @@ prot_to_real:
 
 	/* at last, also limit the code segment to 16 bit */
 	ljmp $__REAL_CS, $return_to_realmode
+	.size prot_to_real, .-prot_to_real
 
 /* ----------------------------------------------------------------------- */
 
 	.section .boot.text.return_to_realmode, "ax"
-return_to_realmode:
+	.globl return_to_realmode
+	.type return_to_realmode, @function
 	.code16
 
+return_to_realmode:
 	/* disable protected mode */
 	movl %cr0, %eax
 	andl $(~0x00000001), %eax
@@ -176,5 +179,5 @@ enter_realmode:
 	/* return on realmode stack! */
 	DATA32 ret
 
-	.size prot_to_real, .-prot_to_real
+	.size return_to_realmode, .-return_to_realmode
 
-- 
1.7.7.2


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

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

* Re: [PATCH 1/4] Make fprintf return number of bytes written
  2011-11-09 21:39 ` [PATCH 1/4] Make fprintf return number of bytes written Lucas De Marchi
@ 2011-11-10 10:53   ` Marc Kleine-Budde
  2011-11-10 13:15     ` Lucas De Marchi
  2011-11-11 11:27   ` Sascha Hauer
  1 sibling, 1 reply; 11+ messages in thread
From: Marc Kleine-Budde @ 2011-11-10 10:53 UTC (permalink / raw)
  To: Lucas De Marchi; +Cc: barebox


[-- Attachment #1.1: Type: text/plain, Size: 2594 bytes --]

On 11/09/2011 10:39 PM, Lucas De Marchi wrote:
> Return number of bytes written, like its siblings function. This also
> removes the warning below on gcc >= 4.6.
> 
> common/console.c:333:7: warning: variable ‘i’ set but not used
> [-Wunused-but-set-variable]

please use one tab not 8 spaces for indention.

Marc

> Signed-off-by: Lucas De Marchi <lucas.demarchi@profusion.mobi>
> ---
>  common/console.c        |    4 +++-
>  common/console_simple.c |    4 +++-
>  include/stdio.h         |    2 +-
>  3 files changed, 7 insertions(+), 3 deletions(-)
> 
> diff --git a/common/console.c b/common/console.c
> index 06e9c29..7f2810e 100644
> --- a/common/console.c
> +++ b/common/console.c
> @@ -327,7 +327,7 @@ void console_flush(void)
>  }
>  EXPORT_SYMBOL(console_flush);
>  
> -void fprintf (int file, const char *fmt, ...)
> +int fprintf (int file, const char *fmt, ...)
>  {
>  	va_list args;
>  	uint i;
> @@ -343,6 +343,8 @@ void fprintf (int file, const char *fmt, ...)
>  
>  	/* Print the string */
>  	fputs (file, printbuffer);
> +
> +        return i;
>  }
>  EXPORT_SYMBOL(fprintf);
>  
> diff --git a/common/console_simple.c b/common/console_simple.c
> index 7304d8e..d73af98 100644
> --- a/common/console_simple.c
> +++ b/common/console_simple.c
> @@ -45,7 +45,7 @@ int vprintf (const char *fmt, va_list args)
>  }
>  EXPORT_SYMBOL(vprintf);
>  
> -void fprintf (int file, const char *fmt, ...)
> +int fprintf (int file, const char *fmt, ...)
>  {
>  	va_list args;
>  	uint i;
> @@ -61,6 +61,8 @@ void fprintf (int file, const char *fmt, ...)
>  
>  	/* Print the string */
>  	fputs(file, printbuffer);
> +
> +        return i;
>  }
>  EXPORT_SYMBOL(fprintf);
>  
> diff --git a/include/stdio.h b/include/stdio.h
> index a0d81d3..0c68fa8 100644
> --- a/include/stdio.h
> +++ b/include/stdio.h
> @@ -54,7 +54,7 @@ int	vscnprintf(char *buf, size_t size, const char *fmt, va_list args);
>  #define stderr		2
>  #define MAX_FILES	128
>  
> -void	fprintf(int file, const char *fmt, ...) __attribute__ ((format(__printf__, 2, 3)));
> +int	fprintf(int file, const char *fmt, ...) __attribute__ ((format(__printf__, 2, 3)));
>  int	fputs(int file, const char *s);
>  int	fputc(int file, const char c);
>  int	ftstc(int file);


-- 
Pengutronix e.K.                  | Marc Kleine-Budde           |
Industrial Linux Solutions        | Phone: +49-231-2826-924     |
Vertretung West/Dortmund          | Fax:   +49-5121-206917-5555 |
Amtsgericht Hildesheim, HRA 2686  | http://www.pengutronix.de   |


[-- Attachment #1.2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 262 bytes --]

[-- Attachment #2: Type: text/plain, Size: 149 bytes --]

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

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

* [PATCH 1/4] Make fprintf return number of bytes written
  2011-11-10 10:53   ` Marc Kleine-Budde
@ 2011-11-10 13:15     ` Lucas De Marchi
  2011-11-10 13:20       ` Marc Kleine-Budde
  0 siblings, 1 reply; 11+ messages in thread
From: Lucas De Marchi @ 2011-11-10 13:15 UTC (permalink / raw)
  To: barebox

Return number of bytes written, like its siblings function. This also
removes the warning below on gcc >= 4.6.

common/console.c:333:7: warning: variable ‘i’ set but not used
[-Wunused-but-set-variable]

Signed-off-by: Lucas De Marchi <lucas.demarchi@profusion.mobi>
---

v2: use proper indentation

 common/console.c        |    4 +++-
 common/console_simple.c |    4 +++-
 include/stdio.h         |    2 +-
 3 files changed, 7 insertions(+), 3 deletions(-)

diff --git a/common/console.c b/common/console.c
index 06e9c29..0d2a33b 100644
--- a/common/console.c
+++ b/common/console.c
@@ -327,7 +327,7 @@ void console_flush(void)
 }
 EXPORT_SYMBOL(console_flush);
 
-void fprintf (int file, const char *fmt, ...)
+int fprintf (int file, const char *fmt, ...)
 {
 	va_list args;
 	uint i;
@@ -343,6 +343,8 @@ void fprintf (int file, const char *fmt, ...)
 
 	/* Print the string */
 	fputs (file, printbuffer);
+
+	return i;
 }
 EXPORT_SYMBOL(fprintf);
 
diff --git a/common/console_simple.c b/common/console_simple.c
index 7304d8e..1f60e79 100644
--- a/common/console_simple.c
+++ b/common/console_simple.c
@@ -45,7 +45,7 @@ int vprintf (const char *fmt, va_list args)
 }
 EXPORT_SYMBOL(vprintf);
 
-void fprintf (int file, const char *fmt, ...)
+int fprintf (int file, const char *fmt, ...)
 {
 	va_list args;
 	uint i;
@@ -61,6 +61,8 @@ void fprintf (int file, const char *fmt, ...)
 
 	/* Print the string */
 	fputs(file, printbuffer);
+
+	return i;
 }
 EXPORT_SYMBOL(fprintf);
 
diff --git a/include/stdio.h b/include/stdio.h
index a0d81d3..0c68fa8 100644
--- a/include/stdio.h
+++ b/include/stdio.h
@@ -54,7 +54,7 @@ int	vscnprintf(char *buf, size_t size, const char *fmt, va_list args);
 #define stderr		2
 #define MAX_FILES	128
 
-void	fprintf(int file, const char *fmt, ...) __attribute__ ((format(__printf__, 2, 3)));
+int	fprintf(int file, const char *fmt, ...) __attribute__ ((format(__printf__, 2, 3)));
 int	fputs(int file, const char *s);
 int	fputc(int file, const char c);
 int	ftstc(int file);
-- 
1.7.7.2


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

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

* Re: [PATCH 1/4] Make fprintf return number of bytes written
  2011-11-10 13:15     ` Lucas De Marchi
@ 2011-11-10 13:20       ` Marc Kleine-Budde
  0 siblings, 0 replies; 11+ messages in thread
From: Marc Kleine-Budde @ 2011-11-10 13:20 UTC (permalink / raw)
  To: Lucas De Marchi; +Cc: barebox


[-- Attachment #1.1: Type: text/plain, Size: 2616 bytes --]

On 11/10/2011 02:15 PM, Lucas De Marchi wrote:
> Return number of bytes written, like its siblings function. This also
> removes the warning below on gcc >= 4.6.
> 
> common/console.c:333:7: warning: variable ‘i’ set but not used
> [-Wunused-but-set-variable]
> 
> Signed-off-by: Lucas De Marchi <lucas.demarchi@profusion.mobi>

Acked-by: Marc Kleine-Budde <mkl@pengutronix.de>

> ---
> 
> v2: use proper indentation
> 
>  common/console.c        |    4 +++-
>  common/console_simple.c |    4 +++-
>  include/stdio.h         |    2 +-
>  3 files changed, 7 insertions(+), 3 deletions(-)
> 
> diff --git a/common/console.c b/common/console.c
> index 06e9c29..0d2a33b 100644
> --- a/common/console.c
> +++ b/common/console.c
> @@ -327,7 +327,7 @@ void console_flush(void)
>  }
>  EXPORT_SYMBOL(console_flush);
>  
> -void fprintf (int file, const char *fmt, ...)
> +int fprintf (int file, const char *fmt, ...)
>  {
>  	va_list args;
>  	uint i;
> @@ -343,6 +343,8 @@ void fprintf (int file, const char *fmt, ...)
>  
>  	/* Print the string */
>  	fputs (file, printbuffer);
> +
> +	return i;
>  }
>  EXPORT_SYMBOL(fprintf);
>  
> diff --git a/common/console_simple.c b/common/console_simple.c
> index 7304d8e..1f60e79 100644
> --- a/common/console_simple.c
> +++ b/common/console_simple.c
> @@ -45,7 +45,7 @@ int vprintf (const char *fmt, va_list args)
>  }
>  EXPORT_SYMBOL(vprintf);
>  
> -void fprintf (int file, const char *fmt, ...)
> +int fprintf (int file, const char *fmt, ...)
>  {
>  	va_list args;
>  	uint i;
> @@ -61,6 +61,8 @@ void fprintf (int file, const char *fmt, ...)
>  
>  	/* Print the string */
>  	fputs(file, printbuffer);
> +
> +	return i;
>  }
>  EXPORT_SYMBOL(fprintf);
>  
> diff --git a/include/stdio.h b/include/stdio.h
> index a0d81d3..0c68fa8 100644
> --- a/include/stdio.h
> +++ b/include/stdio.h
> @@ -54,7 +54,7 @@ int	vscnprintf(char *buf, size_t size, const char *fmt, va_list args);
>  #define stderr		2
>  #define MAX_FILES	128
>  
> -void	fprintf(int file, const char *fmt, ...) __attribute__ ((format(__printf__, 2, 3)));
> +int	fprintf(int file, const char *fmt, ...) __attribute__ ((format(__printf__, 2, 3)));
>  int	fputs(int file, const char *s);
>  int	fputc(int file, const char c);
>  int	ftstc(int file);


-- 
Pengutronix e.K.                  | Marc Kleine-Budde           |
Industrial Linux Solutions        | Phone: +49-231-2826-924     |
Vertretung West/Dortmund          | Fax:   +49-5121-206917-5555 |
Amtsgericht Hildesheim, HRA 2686  | http://www.pengutronix.de   |


[-- Attachment #1.2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 262 bytes --]

[-- Attachment #2: Type: text/plain, Size: 149 bytes --]

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

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

* Re: [PATCH 1/4] Make fprintf return number of bytes written
  2011-11-09 21:39 ` [PATCH 1/4] Make fprintf return number of bytes written Lucas De Marchi
  2011-11-10 10:53   ` Marc Kleine-Budde
@ 2011-11-11 11:27   ` Sascha Hauer
  2011-11-11 13:39     ` Lucas De Marchi
  1 sibling, 1 reply; 11+ messages in thread
From: Sascha Hauer @ 2011-11-11 11:27 UTC (permalink / raw)
  To: Lucas De Marchi; +Cc: barebox

On Wed, Nov 09, 2011 at 07:39:54PM -0200, Lucas De Marchi wrote:
> Return number of bytes written, like its siblings function. This also
> removes the warning below on gcc >= 4.6.
> 
> common/console.c:333:7: warning: variable ‘i’ set but not used
> [-Wunused-but-set-variable]
> 
> Signed-off-by: Lucas De Marchi <lucas.demarchi@profusion.mobi>
> ---
>  common/console.c        |    4 +++-
>  common/console_simple.c |    4 +++-
>  include/stdio.h         |    2 +-
>  3 files changed, 7 insertions(+), 3 deletions(-)
> 
> diff --git a/common/console.c b/common/console.c
> index 06e9c29..7f2810e 100644
> --- a/common/console.c
> +++ b/common/console.c
> @@ -327,7 +327,7 @@ void console_flush(void)
>  }
>  EXPORT_SYMBOL(console_flush);
>  
> -void fprintf (int file, const char *fmt, ...)
> +int fprintf (int file, const char *fmt, ...)
>  {
>  	va_list args;
>  	uint i;
> @@ -343,6 +343,8 @@ void fprintf (int file, const char *fmt, ...)
>  
>  	/* Print the string */
>  	fputs (file, printbuffer);
> +
> +        return i;
>  }

I just applied another patch I suggested earlier which fixes the return
value of the various puts functions. With this I suggest returning the
return value of fputs here instead of a bogus 1.


From 1856d45fbc2fa01415d97ea868d16ea7a974f66b Mon Sep 17 00:00:00 2001
From: Sascha Hauer <s.hauer@pengutronix.de>
Date: Fri, 11 Nov 2011 12:25:53 +0100
Subject: [PATCH] fix fprintf prototype and return value

The puts functions now properly return the number of characters
written. With this we can also fix fprintf.
Also, remove never reached return in fputs.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
 common/console.c |    5 ++---
 include/stdio.h  |    2 +-
 2 files changed, 3 insertions(+), 4 deletions(-)

diff --git a/common/console.c b/common/console.c
index e82934b..944dd07 100644
--- a/common/console.c
+++ b/common/console.c
@@ -318,7 +318,6 @@ int fputs(int fd, const char *s)
 		return eputs(s);
 	else
 		return write(fd, s, strlen(s));
-	return 0;
 }
 EXPORT_SYMBOL(fputs);
 
@@ -333,7 +332,7 @@ void console_flush(void)
 }
 EXPORT_SYMBOL(console_flush);
 
-void fprintf (int file, const char *fmt, ...)
+int fprintf(int file, const char *fmt, ...)
 {
 	va_list args;
 	uint i;
@@ -348,7 +347,7 @@ void fprintf (int file, const char *fmt, ...)
 	va_end (args);
 
 	/* Print the string */
-	fputs (file, printbuffer);
+	return fputs(file, printbuffer);
 }
 EXPORT_SYMBOL(fprintf);
 
diff --git a/include/stdio.h b/include/stdio.h
index bfaeb6c..4901bc7 100644
--- a/include/stdio.h
+++ b/include/stdio.h
@@ -54,7 +54,7 @@ int	vscnprintf(char *buf, size_t size, const char *fmt, va_list args);
 #define stderr		2
 #define MAX_FILES	128
 
-void	fprintf(int file, const char *fmt, ...) __attribute__ ((format(__printf__, 2, 3)));
+int	fprintf(int file, const char *fmt, ...) __attribute__ ((format(__printf__, 2, 3)));
 int	fputs(int file, const char *s);
 int	fputc(int file, const char c);
 int	ftstc(int file);
-- 
1.7.7.1

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

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

* Re: [PATCH 0/4] Fixes for x86
  2011-11-09 21:39 [PATCH 0/4] Fixes for x86 Lucas De Marchi
                   ` (3 preceding siblings ...)
  2011-11-09 21:39 ` [PATCH 4/4] x86: fix symbol size calculation Lucas De Marchi
@ 2011-11-11 11:29 ` Sascha Hauer
  4 siblings, 0 replies; 11+ messages in thread
From: Sascha Hauer @ 2011-11-11 11:29 UTC (permalink / raw)
  To: Lucas De Marchi; +Cc: barebox

On Wed, Nov 09, 2011 at 07:39:53PM -0200, Lucas De Marchi wrote:
> The following patches are fixes for x86 in order to be able to build barebox
> with ARCH=x86 and generic_defconfig. Patch 3 fixes build for any version of gcc
> while the last one is specific to gcc 4.6 (I'm not sure about gcc 4.5).
> 
> With gcc 4.6 there's still an error, but when it's linking barebox, that I
> didn't find out how to fix. I thought the problem was in the linker or linker
> script but they seem to be ok since it works when compiled with gcc 4.4. The
> error is the following:
> 
>   LD      barebox
> ld: section .eh_frame loaded at [0000000000011a54,0000000000018ac3] overlaps section .barebox_initcalls loaded at [0000000000011a54,0000000000011a9b]
> make: *** [barebox] Error 1

Applied patches 2-4. For 1 I prefer the solution just posted.

Sascha


-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

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

* Re: [PATCH 1/4] Make fprintf return number of bytes written
  2011-11-11 11:27   ` Sascha Hauer
@ 2011-11-11 13:39     ` Lucas De Marchi
  0 siblings, 0 replies; 11+ messages in thread
From: Lucas De Marchi @ 2011-11-11 13:39 UTC (permalink / raw)
  To: Sascha Hauer; +Cc: barebox

On Fri, Nov 11, 2011 at 9:27 AM, Sascha Hauer <s.hauer@pengutronix.de> wrote:
> On Wed, Nov 09, 2011 at 07:39:54PM -0200, Lucas De Marchi wrote:
>> Return number of bytes written, like its siblings function. This also
>> removes the warning below on gcc >= 4.6.
>>
>> common/console.c:333:7: warning: variable ‘i’ set but not used
>> [-Wunused-but-set-variable]
>>
>> Signed-off-by: Lucas De Marchi <lucas.demarchi@profusion.mobi>
>> ---
>>  common/console.c        |    4 +++-
>>  common/console_simple.c |    4 +++-
>>  include/stdio.h         |    2 +-
>>  3 files changed, 7 insertions(+), 3 deletions(-)
>>
>> diff --git a/common/console.c b/common/console.c
>> index 06e9c29..7f2810e 100644
>> --- a/common/console.c
>> +++ b/common/console.c
>> @@ -327,7 +327,7 @@ void console_flush(void)
>>  }
>>  EXPORT_SYMBOL(console_flush);
>>
>> -void fprintf (int file, const char *fmt, ...)
>> +int fprintf (int file, const char *fmt, ...)
>>  {
>>       va_list args;
>>       uint i;
>> @@ -343,6 +343,8 @@ void fprintf (int file, const char *fmt, ...)
>>
>>       /* Print the string */
>>       fputs (file, printbuffer);
>> +
>> +        return i;
>>  }
>
> I just applied another patch I suggested earlier which fixes the return
> value of the various puts functions. With this I suggest returning the
> return value of fputs here instead of a bogus 1.

It makes sense. Thanks

Lucas De Marchi

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

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

end of thread, other threads:[~2011-11-11 13:39 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-11-09 21:39 [PATCH 0/4] Fixes for x86 Lucas De Marchi
2011-11-09 21:39 ` [PATCH 1/4] Make fprintf return number of bytes written Lucas De Marchi
2011-11-10 10:53   ` Marc Kleine-Budde
2011-11-10 13:15     ` Lucas De Marchi
2011-11-10 13:20       ` Marc Kleine-Budde
2011-11-11 11:27   ` Sascha Hauer
2011-11-11 13:39     ` Lucas De Marchi
2011-11-09 21:39 ` [PATCH 2/4] Add setupmbr to gitignore Lucas De Marchi
2011-11-09 21:39 ` [PATCH 3/4] x86: fix build error because of missing header Lucas De Marchi
2011-11-09 21:39 ` [PATCH 4/4] x86: fix symbol size calculation Lucas De Marchi
2011-11-11 11:29 ` [PATCH 0/4] Fixes for x86 Sascha Hauer

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