newlib-nano is unable to process sscanf() input after the 1st unsigned char value (%hhu or %hhx)
When running this code, I get only the first unsigned char value read from the input string, but not any subsequent ones:
int main(void)
{
char* input = "0 1 2 3 4 5";
static volatile uint8_t data[6];
volatile int byte_read_count;
memset(data, 0x55, sizeof(data));
byte_read_count = sscanf(input, "%u %u %hhu %hhu %hhu %hhu",
&data[0],
&data[1],
&data[2],
&data[3],
&data[4],
&data[5]);
return;
}
I'm expecting the array 'data' to contain values 0, 1, 2, 3, 4, 5, but instead I get 0, 1, 2, 0, 0, 85. This happens only with format specifiers "%hhu" and "%hhx". As an aside, byte_read_count is set to 3 (this at least matches the number of parameters that are correctly set by sscanf), but I was expecting it to be 6 since I'm trying to read 6 values from the input string.
I've tried other variations of the input/format strings, and sscanf always correctly reads the first %hhu parameter in the format string, then fills the next two parameters with zeroes and ignores the rest. This appears to be a bug in newlib-nano.
Also, when using %u or %hu instead of %hhu, everything works correctly.
I was able to narrow this issue down to the newlib-nano standard C library since when I switch to the standard newlib, this issue goes away.
I'm using CubeIDE 1.13.2 (the latest currently available) with all the latest updates for libraries and tools installed.
Hopefully, this issue can be resolved in the future releases.
