Will it be safe to fix the warning below with casting, or could I simple change the prototype to return a u_char
instead?
warning: returning 'u_char [256]' from a function with result type 'char *' converts between pointers to integer types with different sign [-Wpointer-sign]
char * whatever(unsigned char *text)
{
static u_char retval[256];
int pos = 0;
*retval = 0;
if (!text)
return retval;
for (; *text && (pos < 254); text++, pos++) {
if (*text < 32) {
retval[pos++] = '^';
retval[pos] = *text + 64;
} else if (*text == 127) {
retval[pos++] = '^';
retval[pos] = '?';
} else
retval[pos] = *text;
}
retval[pos] = 0;
return retval;
}
I'm open to other possibilities as well.