This is the mail archive of the
ecos-patches@sourceware.org
mailing list for the eCos project.
Patch for printing long longs from diag_printf
- From: Rutger Hofman <rutger at cs dot vu dot nl>
- To: ecos-patches at ecos dot sourceware dot org
- Date: Thu, 31 May 2007 17:36:26 +0200
- Subject: Patch for printing long longs from diag_printf
Currently (eCos CVS from 10 minutes ago) diag_printf truncates it
integer-typed arguments to the size of a long or an int. For long longs,
this is obviously wrong: it should just not truncate. See the attached
patch to repair this.
Question: what about shorts and chars? Shouldn't those also be
truncated? I did nothing here, because I'm not sure what to do.
Rutger Hofman
VU Amsterdam
Index: ChangeLog
===================================================================
RCS file: /cvs/ecos/ecos/packages/infra/current/ChangeLog,v
retrieving revision 1.57
diff -u -r1.57 ChangeLog
--- ChangeLog 26 Oct 2006 18:25:08 -0000 1.57
+++ ChangeLog 31 May 2007 15:36:45 -0000
@@ -1,3 +1,8 @@
+2007-05-31 Rutger Hofman <rutger@cs.vu.nl>
+
+ * src/diag.cxx: when printing a long long, should not truncate
+ its value to a long or int size
+
2006-10-26 Stefan Sommerfeld <sommerfeld@mikrom.com>
* include/cyg_types.h: fixed typo, __GNU_PATCHLEVEL__ was checked,
Index: src/diag.cxx
===================================================================
RCS file: /cvs/ecos/ecos/packages/infra/current/src/diag.cxx,v
retrieving revision 1.19
diff -u -r1.19 diag.cxx
--- src/diag.cxx 27 Mar 2005 18:14:59 -0000 1.19
+++ src/diag.cxx 31 May 2007 15:36:46 -0000
@@ -375,7 +375,9 @@
}
} else {
// Mask to unsigned, sized quantity
- if (islong) {
+ if (islonglong) {
+ // No need to mask
+ } else if (islong) {
val &= ((long long)1 << (sizeof(long) * 8)) - 1;
} else{
val &= ((long long)1 << (sizeof(int) * 8)) - 1;