Hello, I just found this board due to some unresolved trouble I've been having with a program I'm writing. When I compile (on gcc) I receive this warning.
b_poplist.c:48: warning: assignment from incompatible pointer type
If anyone knows why this warning comes up and could assist me in correcting it, it would be much appreciated.
I have tried to cast the right side as (b_list*) but that heeds no different results.
ie: cb_list->next = (b_list*)hb_list
Here is my code for b_poplist.c
Also, the structure for the linked list b_list is such:Code:#include "b_list.h" #include <stdio.h> #include <stdlib.h> #include <string.h> #include <sys/socket.h> #include <bluetooth/bluetooth.h> #include <bluetooth/hci.h> #include <bluetooth/hci_lib.h> #include <unistd.h> b_list *b_poplist(void) { inquiry_info *ii = NULL; int max_rsp, num_rsp; int dev_id, sock, len, flags; int i; char addr[19] = { 0 }; char name[248] = { 0 }; dev_id = hci_get_route(NULL); sock = hci_open_dev( dev_id ); if (dev_id < 0 || sock < 0) { perror("opening socket"); exit(1); } len = 8; max_rsp = 255; flags = IREQ_CACHE_FLUSH; ii = (inquiry_info*)malloc(max_rsp * sizeof(inquiry_info)); num_rsp = hci_inquiry(dev_id, len, max_rsp, NULL, &ii, flags); if( num_rsp < 0 ) perror("hci_inquiry"); b_list *hb_list, *cb_list; hb_list = NULL; for (i = 0; i < num_rsp; i++) { ba2str(&(ii+i)->bdaddr, addr); memset(name, 0, sizeof(name)); if (hci_read_remote_name(sock, &(ii+i)->bdaddr, sizeof(name), name, 0) < 0) strcpy(name, "[unknown]"); printf("FOUND: (%d) = %s , %s\n",i , name, addr); cb_list = calloc(1, sizeof(b_list)); cb_list->name = name; cb_list->m_addrs = addr; cb_list->next = hb_list; /* Warning occurs here line 48 */ hb_list = cb_list; printf("ADDED: (%d) = %s , %s\n", i, hb_list->name, hb_list->m_addrs); } cb_list = hb_list; free( ii ); close( sock ); printf("RETURNED: %s, %s\n", hb_list->name, hb_list->m_addrs); return hb_list; }
Also, if you notice anything else in the code that could be fixed up to run a little better that would be appreciated as well.Code:typedef struct { char* name; char* m_addrs; struct b_list* next; } b_list;
Thanks,
Brian



LinkBack URL
About LinkBacks



