I am a bit confused as to why I am getting the warning "return from incompatable pointer type" with the code I have written below. I define yelp as a YelpDataBst* and the function has a return type of YelpDataBst*, so why am I getting this warning?
Code:
typedef struct BusList_t{
long int addressOffset;
long int reviewOffset;
struct BusList_t* next;
}BusList;
typedef struct BusTree_t{
char* name;
//int id;
BusList* locations;
struct BusTree_t* left;
struct BusTree_t* right;
}BusTree;
struct YelpDataBst{
BusTree* Bushead;
};
struct YelpDataBST* create_business_bst(const char* businesses_path, const char* reviews_path){
if(fopen(businesses_path,"r") == NULL || fopen(reviews_path,"r") == NULL)
return NULL;
FILE* fp_bp = fopen(businesses_path, "r");
FILE* fp_rp = fopen(reviews_path, "r");
struct YelpDataBst* yelp = malloc(sizeof(struct YelpDataBst));
int ID = -1;
int tempID;
long int addressOffset;
long int reviewOffset;
char line[2000];
char line2[2000];
char* token;
char* token2;
char* name;
int len;
BusList* busListHead = NULL;
BusTree* busTreeNode = NULL;
BusTree* busTreeHead = NULL;
ID = -1;
tempID = 0;
fgets(line,2000,fp_rp);
fgets(line2,2000,fp_bp);
fseek(fp_rp,0, SEEK_SET);
fseek(fp_bp,0,SEEK_SET);
int ct = 0;
while(!feof(fp_rp)){
len = strlen(line);
token = strtok(line, "\t");
tempID = atoi(token);
if(ct == 0){
tempID = 1;
ct++;
}
if((ID != tempID || (ID < 0)) && tempID != 0){
token2 = strtok(line2, "\t");
addressOffset = ftell(fp_bp);
if(tempID == 1)
tempID = 0;
token2 = strtok(NULL, "\t");
if(token2 != NULL){
if(name != NULL)
if(strcmp(token2, name) == 0){
fgets(line2, 2000,fp_bp);
token2 = strtok(line2, "\t");
token2 = strtok(NULL, "\t");
}
name = strdup(token2);
}
reviewOffset = ftell(fp_rp);
if(tempID != 0)
reviewOffset -= len;
ID = atoi(token);
busTreeNode = BusTree_create(name, busListHead, addressOffset, reviewOffset);
busTreeHead = BusTree_insert(busTreeHead, busTreeNode); //replace with create node for tree
free(name);
fgets(line2,2000,fp_bp);
}
fgets(line,2000,fp_rp);
}
yelp->Bushead = busTreeHead;
BusTree_print(yelp->Bushead);
BusTree_destroy(busTreeHead);
return yelp;
}