chvprintf problem Topic is solved

Report here problems in any of ChibiOS components. This forum is NOT for support.
jmajew
Posts: 3
Joined: Mon Feb 24, 2020 11:54 am
Been thanked: 1 time

chvprintf problem  Topic is solved

Postby jmajew » Fri Mar 06, 2020 9:43 pm

Hello,

I think I have just found a small issue with chvprintf function, which is related to the width definition when the width is supposed to be defined during run-time, e.g.:

Code: Select all

uint32_t ii = 1234;
uint8_t width = 12;
chprintf( (BaseSequentialStream *)&SD3, "%0*d \r\n", width , ii);

The results should be:
000000001234

and is:
*d

For the record I am using current version of chibios from github and gcc compiler 6.3.1. The platform is nucleo144 stm32f767 but the issue would be visible on any platform.

I have a fix which works for me:
file chprintfc.c, function chvprintf, starting line 174

current version:

Code: Select all

    /* Width modifier.*/
    if (c == '*') {
      width = va_arg(ap, int);
    }

modified version:

Code: Select all

    /* Width modifier.*/
    if ( *fmt == '*') {
      width = va_arg(ap, int);
      ++fmt;
      c = *fmt++;
    }

The problem can be tested using simple project (blinker + few lines calling chprintf) which I have attached to this post.

Funny is that exactly this few lines were modified in around May 2019 and the bug was introduced - the earlier version worked ok...

Jurek
Attachments
blink_20.zip
(13.13 KiB) Downloaded 124 times

User avatar
Giovanni
Site Admin
Posts: 14457
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 1076 times
Been thanked: 922 times
Contact:

Re: chvprintf problem

Postby Giovanni » Sat Mar 07, 2020 9:48 am

Hi,

Fixed in trunk, thanks.

Giovanni


Return to “Bug Reports”

Who is online

Users browsing this forum: No registered users and 53 guests