Char signedness bug in usbGenericSetInterrupt() [fixed]
Posted: Thu Nov 14, 2013 10:03 pm
Code: Select all
static void usbGenericSetInterrupt(uchar *data, uchar len, usbTxStatus_t *txStatus)
{
uchar *p;
char i;
[...]
i = len;
do{ /* if len == 0, we still copy 1 byte, but that's no problem */
*p++ = *data++;
}while(--i > 0); /* loop control at the end is 2 bytes shorter than at beginning */
[...]
It sure seems it's assuming that char is signed. It's common to use -funsigned-char to avoid unnecessary sign-extension, which would apparently break the above code. There is an schar in usbdrv.h:
Code: Select all
#ifndef schar
#define schar signed char
#endif
so it doesn't seem they want to rely on char being signed.