RTEMS printk fails for large unsigned integers

Joris van Rantwijk jorisvr at sron.nl
Sat Nov 28 17:53:18 UTC 2009


On 27 nov 2009, at 20:32, Joel Sherrill wrote:
> On 11/27/2009 01:27 PM, Ingolf Steinbach wrote:
>>>> Furthermore, printing variable greater LONG_MAX with "%u"  
>>>> formating is
>>>> invalid/non-portable code.
>> I currently do not know the documentation of printk(). But if it is
>> similar to printf(), you would probably have to use "%lu" rather than
>> just "%u" if you output an (unsigned) *long* integer as in your case.

Ok, now I see the point that Ingolf and Ralf are making.
However, in my case the value is "unsigned int", but larger than  
LONG_MAX.

> It should be a subset of printf.  An addition to the manual
> to document it would be appreciated.  Please submit a patch
> against spprintk which illustrates any behavior you think is
> deficient.

Very well. This patch adds some problem cases.
I believe Sebastian Huber already plans to fix the bug.

Currently the test does not output anything on sparc/leon3. I added  
APPLICATION_NEEDS_CONSOLE_DRIVER to fix that. Output from the test  
looks garbled in my terminal because '\n' is not translated to '\r 
\n'. Some BSPs insert '\r' but sparc doesn't; should it do that?

There is a file with the expected output of the test. Is there a way  
to automatically run tests and have output verified against that file?

Joris.
--

Index: rtems/testsuites/sptests/spprintk/init.c
===================================================================
RCS file: /usr1/CVS/rtems/testsuites/sptests/spprintk/init.c,v
retrieving revision 1.5
diff -c -3 -p -r1.5 init.c
*** rtems/testsuites/sptests/spprintk/init.c	24 Oct 2009 06:14:30  
-0000	1.5
--- rtems/testsuites/sptests/spprintk/init.c	28 Nov 2009 17:38:22 -0000
*************** rtems_task Init(
*** 53,58 ****
--- 53,62 ----
     printk( "%%-4s of joel -- (%-4s)\n", "joel" );
     printk( "%%c of X -- (%c)\n", 'X' );

+   /* large unsigned numbers */
+   printk( "%%u of 3000000000 -- %u\n", 3000000000U);
+   printk( "%%x of 0x87654321 -- %x\n", 0x87654321);
+   printk( "%%p of 0x87654321 -- %p\n", (void *)0x87654321);

     printk( "*** END OF TEST PRINTK ***\n" );
     rtems_test_exit( 0 );
*************** rtems_task Init(
*** 61,66 ****
--- 65,71 ----
   /* configuration information */

   #define CONFIGURE_APPLICATION_DOES_NOT_NEED_CLOCK_DRIVER
+ #define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER

   #define CONFIGURE_MAXIMUM_TASKS           1

Index: rtems/testsuites/sptests/spprintk/spprintk.scn
===================================================================
RCS file: /usr1/CVS/rtems/testsuites/sptests/spprintk/spprintk.scn,v
retrieving revision 1.3
diff -c -3 -p -r1.3 spprintk.scn
*** rtems/testsuites/sptests/spprintk/spprintk.scn	9 Nov 2009  
14:30:10 -0000	1.3
--- rtems/testsuites/sptests/spprintk/spprintk.scn	28 Nov 2009  
17:38:22 -0000
*************** bad format -- %lq in parentheses (q)
*** 28,31 ****
--- 28,34 ----
   %-12s of joel -- (joel                )
   %-4s of joel -- (joel)
   %c of X -- (X)
+ %u of 3000000000 -- 3000000000
+ %x of 0x87654321 -- 87654321
+ %p of 0x87654321 -- 0x87654321
   *** END OF TEST PRINTK ***




More information about the users mailing list