I've a function which take an uint8_t * argument :
uint8_t* ihex_decode(uint8_t *in, size_t len, uint8_t *out)
{
uint8_t i, hn, ln;
for (i = 0; i < len; i+=2) {
hn = in[i] > '9' ? (in[i]|32) - 'a' + 10 : in[i] - '0';
ln = in[i+1] > '9' ? (in[i+1]|32) - 'a' + 10 : in[i+1] - '0';
out[i/2] = (hn << 4 ) | ln;
}
return out;
}
I use this function with :
uint8_t data[SPM_PAGESIZE]; // SPM_PAGESIZE = 256 bytes
uint8_t sysex_data[SPM_PAGESIZE/2];
ihex_decode(data, strlen(data), sysex_data);
But in this case, my compiler (avr-gcc) return a warning :
main.c|89|warning: pointer targets in passing argument 1 of 'strlen' differ in signedness /usr/include/string.h|399|note: expected 'const char *' but argument is of type 'uint8_t *'
So, i've found a solution by type casting the data var :
ihex_decode(data, strlen((const char *)data), sysex_data);
The warning disappears but I wonder if this solution is safe.
Is there a better way ?
Thanks