From 892859455cc444aa778c27a7b4a3f0bf6e1542e1 Mon Sep 17 00:00:00 2001 From: goldsimon Date: Mon, 25 Jan 2010 08:20:46 +0000 Subject: [PATCH] bug #28659: Missing casts --- apps/httpserver/httpserver-netconn.c | 2 +- apps/httpserver_raw/httpd.c | 14 +++++++------- ports/win32/pktdrv.c | 22 +++++++++++----------- ports/win32/pktif.c | 5 ++--- 4 files changed, 21 insertions(+), 22 deletions(-) diff --git a/apps/httpserver/httpserver-netconn.c b/apps/httpserver/httpserver-netconn.c index faeea8d..424482c 100644 --- a/apps/httpserver/httpserver-netconn.c +++ b/apps/httpserver/httpserver-netconn.c @@ -24,7 +24,7 @@ http_server_netconn_serve(struct netconn *conn) err = netconn_recv(conn, &inbuf); if (err == ERR_OK) { - netbuf_data(inbuf, &buf, &buflen); + netbuf_data(inbuf, (void**)&buf, &buflen); /* Is this an HTTP GET command? (only check the first 5 chars, since there are other formats for GET, and we're keeping it very simple )*/ diff --git a/apps/httpserver_raw/httpd.c b/apps/httpserver_raw/httpd.c index 6e6bc38..bd2b783 100644 --- a/apps/httpserver_raw/httpd.c +++ b/apps/httpserver_raw/httpd.c @@ -100,9 +100,9 @@ static struct http_state* http_state_alloc() { #if HTTPD_USE_MEM_POOL - return memp_malloc(MEMP_HTTPD_STATE); + return (struct http_state *)memp_malloc(MEMP_HTTPD_STATE); #else /* HTTPD_USE_MEM_POOL */ - return mem_malloc(sizeof(struct http_state)); + return (struct http_state *)mem_malloc(sizeof(struct http_state)); #endif /* HTTPD_USE_MEM_POOL */ } @@ -224,7 +224,7 @@ http_parse_request(struct pbuf *p, struct http_state *hs) struct fs_file file; const char* filename = NULL; - data = p->payload; + data = (char*)p->payload; /* default is request not supported */ request_supported = ERR_ARG; @@ -285,7 +285,7 @@ http_parse_request(struct pbuf *p, struct http_state *hs) static void http_err(void *arg, err_t err) { - struct http_state *hs = arg; + struct http_state *hs = (struct http_state *)arg; LWIP_UNUSED_ARG(err); LWIP_DEBUGF(HTTPD_DEBUG, ("http_err: %s", lwip_strerr(err))); @@ -302,7 +302,7 @@ http_err(void *arg, err_t err) static err_t http_sent(void *arg, struct tcp_pcb *pcb, u16_t len) { - struct http_state *hs = arg; + struct http_state *hs = (struct http_state *)arg; LWIP_DEBUGF(HTTPD_DEBUG, ("http_sent: pcb=%p hs=%p len=%"U16_F"\n", (void*)pcb, (void*)hs, len)); @@ -344,7 +344,7 @@ http_sent(void *arg, struct tcp_pcb *pcb, u16_t len) static err_t http_poll(void *arg, struct tcp_pcb *pcb) { - struct http_state *hs = arg; + struct http_state *hs = (struct http_state *)arg; LWIP_DEBUGF(HTTPD_DEBUG, ("http_poll: pcb=%p hs=%p pcb_state=%s\n", (void*)pcb, (void*)hs, tcp_debug_state_str(pcb->state))); @@ -377,7 +377,7 @@ static err_t http_recv(void *arg, struct tcp_pcb *pcb, struct pbuf *p, err_t err) { err_t parsed = ERR_ABRT; - struct http_state *hs = arg; + struct http_state *hs = (struct http_state *)arg; LWIP_DEBUGF(HTTPD_DEBUG, ("http_recv: pcb=%p pbuf=%p err=%s\n", (void*)pcb, (void*)p, lwip_strerr(err))); diff --git a/ports/win32/pktdrv.c b/ports/win32/pktdrv.c index 96314e0..a77d510 100644 --- a/ports/win32/pktdrv.c +++ b/ports/win32/pktdrv.c @@ -103,7 +103,7 @@ struct packet_adapter { * @return number of adapters found or negative on error */ static int -get_adapter_list(void** adapter_list, int list_len, void* buffer, size_t buf_len) +get_adapter_list(char** adapter_list, int list_len, void* buffer, size_t buf_len) { int i; char *temp, *start; @@ -123,8 +123,8 @@ get_adapter_list(void** adapter_list, int list_len, void* buffer, size_t buf_len /* get the start of each adapter name in the list and put it into * the AdapterList array */ i = 0; - temp = buffer; - start = buffer; + temp = (char*)buffer; + start = (char*)buffer; while ((*temp != '\0') || (*(temp - 1) != '\0')) { if (*temp == '\0') { adapter_list[i] = start; @@ -147,7 +147,7 @@ get_adapter_list(void** adapter_list, int list_len, void* buffer, size_t buf_len int get_adapter_index(const char* adapter_guid) { - void *AdapterList[MAX_NUM_ADAPTERS]; + char *AdapterList[MAX_NUM_ADAPTERS]; int i; char AdapterName[ADAPTER_NAME_LEN]; /* string that contains a list of the network adapters */ int AdapterNum; @@ -156,7 +156,7 @@ get_adapter_index(const char* adapter_guid) AdapterNum = get_adapter_list(AdapterList, MAX_NUM_ADAPTERS, AdapterName, ADAPTER_NAME_LEN); if (AdapterNum > 0) { for (i = 0; i < AdapterNum; i++) { - if(strstr(AdapterList[i], adapter_guid)) { + if(strstr((char*)AdapterList[i], adapter_guid)) { return i; } } @@ -178,7 +178,7 @@ get_adapter_index(const char* adapter_guid) void* init_adapter(int adapter_num, char *mac_addr, input_fn input, void *arg) { - void *AdapterList[MAX_NUM_ADAPTERS]; + char *AdapterList[MAX_NUM_ADAPTERS]; int i; char AdapterName[ADAPTER_NAME_LEN]; /* string that contains a list of the network adapters */ int AdapterNum; @@ -186,7 +186,7 @@ init_adapter(int adapter_num, char *mac_addr, input_fn input, void *arg) unsigned char ethaddr[ETHARP_HWADDR_LEN]; struct packet_adapter *pa; - pa = malloc(sizeof(struct packet_adapter)); + pa = (struct packet_adapter *)malloc(sizeof(struct packet_adapter)); if (!pa) { printf("Unable to alloc the adapter!\n"); return NULL; @@ -209,7 +209,7 @@ init_adapter(int adapter_num, char *mac_addr, input_fn input, void *arg) /* set up the selected adapter */ lpAdapter = PacketOpenAdapter(AdapterList[i]); if (lpAdapter && (lpAdapter->hFile != INVALID_HANDLE_VALUE)) { - ppacket_oid_data = malloc(sizeof(PACKET_OID_DATA) + PACKET_OID_DATA_SIZE); + ppacket_oid_data = (PPACKET_OID_DATA)malloc(sizeof(PACKET_OID_DATA) + PACKET_OID_DATA_SIZE); if (ppacket_oid_data) { ppacket_oid_data->Oid = OID_GEN_VENDOR_DESCRIPTION; ppacket_oid_data->Length = PACKET_OID_DATA_SIZE; @@ -242,7 +242,7 @@ init_adapter(int adapter_num, char *mac_addr, input_fn input, void *arg) return NULL; } /* alloc the OID packet */ - ppacket_oid_data = malloc(sizeof(PACKET_OID_DATA) + PACKET_OID_DATA_SIZE); + ppacket_oid_data = (PPACKET_OID_DATA)malloc(sizeof(PACKET_OID_DATA) + PACKET_OID_DATA_SIZE); if (!ppacket_oid_data) { PacketCloseAdapter(pa->lpAdapter); free(pa); @@ -362,7 +362,7 @@ ProcessPackets(void *adapter, LPPACKET lpPacket) ulBytesReceived = lpPacket->ulBytesReceived; - buf = lpPacket->Buffer; + buf = (char*)lpPacket->Buffer; off=0; @@ -430,7 +430,7 @@ link_adapter(void *adapter) NDIS_MEDIA_STATE fNdisMediaState = pa->fNdisMediaState; /* get the media connect status of the selected adapter */ - ppacket_oid_data = malloc(sizeof(PACKET_OID_DATA) + sizeof(NDIS_MEDIA_STATE)); + ppacket_oid_data = (PPACKET_OID_DATA)malloc(sizeof(PACKET_OID_DATA) + sizeof(NDIS_MEDIA_STATE)); if (ppacket_oid_data) { ppacket_oid_data->Oid = OID_GEN_MEDIA_CONNECT_STATUS; ppacket_oid_data->Length = sizeof(NDIS_MEDIA_STATE); diff --git a/ports/win32/pktif.c b/ports/win32/pktif.c index 2cf69a7..f8e4f18 100644 --- a/ports/win32/pktif.c +++ b/ports/win32/pktif.c @@ -218,8 +218,7 @@ low_level_input(struct netif *netif, void *packet, int packet_len) if (((memcmp(ðhdr->dest, &netif->hwaddr, ETHARP_HWADDR_LEN)) && ((ethhdr->dest.addr[0] & 0x01) == 0)) || /* and don't let feedback packets through (limitation in winpcap?) */ - ((!memcmp(ðhdr->src, netif->hwaddr, ETHARP_HWADDR_LEN)) && - ((ethhdr->dest.addr[0] & 0x01) == 0))) { + (!memcmp(ðhdr->src, netif->hwaddr, ETHARP_HWADDR_LEN))) { return NULL; } @@ -279,7 +278,7 @@ ethernetif_input(struct netif *netif, void *packet, int packet_len) } /* points to packet payload, which starts with an Ethernet header */ - ethhdr = p->payload; + ethhdr = (struct eth_hdr *)p->payload; switch (htons(ethhdr->type)) { /* IP or ARP packet? */ case ETHTYPE_IP: