This is the mail archive of the
ecos-patches@sources.redhat.com
mailing list for the eCos project.
FWD: Re: [ECOS] bug in sprintf
- From: Andrew Lunn <andrew dot lunn at ascom dot ch>
- To: eCos Patches <ecos-patches at sources dot redhat dot com>
- Date: Tue, 10 Jun 2003 12:27:15 +0200
- Subject: FWD: Re: [ECOS] bug in sprintf
Inlined is a patch based on what Knud found. Jifl suggested casting
to long rather than signed.
Andrew
----- Forwarded message from Knud Wöhler <woehler@ossi.fho-emden.de> -----
From: Knud Wöhler <woehler@ossi.fho-emden.de>
To: Andrew Lunn <andrew.lunn@ascom.ch>
Subject: Re: [ECOS] bug in sprintf
Date: Mon, 2 Jun 2003 19:41:25 +0200
[..]
I tried it with a cast to signed and it seems to work.
#define SARG() \
(flags&QUADINT ? va_arg(arg, cyg_int64) : \
flags&LONGINT ? va_arg(arg, long) : \
flags&SHORTINT ? (long)(short)va_arg(arg, int) : \
flags&SIZET ? (signed)va_arg(arg, size_t) : \ <--
(long)va_arg(arg, int))
Knud
----- End forwarded message -----
Index: packages/language/c/libc/stdio/current//ChangeLog
===================================================================
RCS file: /cvs/ecos/ecos/packages/language/c/libc/stdio/current/ChangeLog,v
retrieving revision 1.21
diff -u -r1.21 ChangeLog
--- packages/language/c/libc/stdio/current//ChangeLog 6 Mar 2003 20:57:26 -0000 1.21
+++ packages/language/c/libc/stdio/current//ChangeLog 10 Jun 2003 10:25:48 -0000
@@ -1,3 +1,11 @@
+2003-06-10 Andrew Lunn <andrew.lunn@ascom.ch>
+ Knud Wöhler <woehler@ossi.fho-emden.de>
+
+ * src/output/vfnprintf.cxx (SARG): Cast size_t to long. This seems
+ to stop gcc from producing wrong code for the plain int clause. The
+ wrong code causes negative numbers to be printed as positive because
+ the sign extend from 32 bits to 64 bits is wrong.
+
2003-03-06 Gary Thomas <gary@mlbassoc.com>
* src/input/fread.cxx (fread): Simple EOF should not set error.
Index: packages/language/c/libc/stdio/current//src/output/vfnprintf.cxx
===================================================================
RCS file: /cvs/ecos/ecos/packages/language/c/libc/stdio/current/src/output/vfnprintf.cxx,v
retrieving revision 1.6
diff -u -r1.6 vfnprintf.cxx
--- packages/language/c/libc/stdio/current//src/output/vfnprintf.cxx 29 Jan 2003 17:27:33 -0000 1.6
+++ packages/language/c/libc/stdio/current//src/output/vfnprintf.cxx 10 Jun 2003 10:25:48 -0000
@@ -240,7 +240,7 @@
(flags&QUADINT ? va_arg(arg, cyg_int64) : \
flags&LONGINT ? va_arg(arg, long) : \
flags&SHORTINT ? (long)(short)va_arg(arg, int) : \
- flags&SIZET ? va_arg(arg, size_t) : \
+ flags&SIZET ? (long)va_arg(arg, size_t) : \
(long)va_arg(arg, int))
#define UARG() \
(flags&QUADINT ? va_arg(arg, cyg_uint64) : \