I've read through similar questions, but I've not been able to find one that helps me understand this warning in this case. I'm in my first week of trying to learn C, so apologies in advance.
I get the following warning and note:
In function 'read_line':
warning: pointer targets in passing argument 1 of 'read_byte' differ in signedness [-Wpointer-sign]
res = read_byte(&data);
^
note: expected 'char *' but argument is of type 'uint8_t *'
char read_byte(char * data)
When trying to compile this code:
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <stdint.h>
#include <fcntl.h>
#include <unistd.h>
char read_byte(char * data)
{
if(fs > 0 )
{
int n = read(fs, data, 1);
if (n < 0)
{
fprintf(stderr, "Read error\n");
return 1;
}
}
return *data;
}
uint8_t read_line(char * linebuf)
{
uint8_t data, res;
char * ptr = linebuf;
do
{
res = read_byte(&data);
if( res < 0 )
{
fprintf(stderr, "res < 0\n");
break;
}
switch ( data )
{
case '\r' :
break;
case '\n' :
break;
default :
*(ptr++) = data;
break;
}
}while(data != '\n');
*ptr = 0; // terminaison
return res;
}
int main(int argc, char **argv)
{
char buf[128];
if( read_line(buf) == 10 )
{
// parse data
}
close(fs);
return 0;
}
I removed useless part including the one which opens the port and initializes fs.