From 7cc473aed830db1395ed0d0701791889a6e96e4f Mon Sep 17 00:00:00 2001 From: Ralf Baechle Date: Mon, 17 Jun 2013 09:36:38 +0200 Subject: Kill a ton of useless casts to char * all over the code. Signed-off-by: Ralf Baechle --- ax25ipd/config.c | 2 +- ax25ipd/io.c | 25 ++++++++++++++----------- ax25mond/ax25mond.c | 4 ++-- ax25rtd/listener.c | 6 +++--- call/yapp.c | 4 ++-- 5 files changed, 22 insertions(+), 19 deletions(-) diff --git a/ax25ipd/config.c b/ax25ipd/config.c index 315a243..8d9405b 100644 --- a/ax25ipd/config.c +++ b/ax25ipd/config.c @@ -312,7 +312,7 @@ int parse_line(char *buf) j = inet_addr(q); if (j == -1) return -5; /* if -1, bad deal! */ - memcpy(tip, (char *) &j, 4); + memcpy(tip, &j, 4); } if (my_udp) diff --git a/ax25ipd/io.c b/ax25ipd/io.c index 356ebdc..4277612 100644 --- a/ax25ipd/io.c +++ b/ax25ipd/io.c @@ -126,13 +126,13 @@ void io_init(void) * address structure. Since both to and from are static, they are * already clear. */ - bzero((char *) &to, sizeof(struct sockaddr)); + bzero(&to, sizeof(struct sockaddr)); to.sin_family = AF_INET; - bzero((char *) &from, sizeof(struct sockaddr)); + bzero(&from, sizeof(struct sockaddr)); from.sin_family = AF_INET; - bzero((char *) &udpbind, sizeof(struct sockaddr)); + bzero(&udpbind, sizeof(struct sockaddr)); udpbind.sin_family = AF_INET; } @@ -415,7 +415,9 @@ out_ttyfd: n = recvfrom(udpsock, buf, MAX_FRAME, 0, (struct sockaddr *) &from, &fromlen); } while (io_error(n, buf, n, READ_MSG, UDP_MODE, __LINE__)); - LOGL4("udpdata from=%s port=%d l=%d\n", (char *) inet_ntoa(from. sin_addr), ntohs(from. sin_port), n); + LOGL4("udpdata from=%s port=%d l=%d\n", + inet_ntoa(from. sin_addr), + ntohs(from. sin_port), n); stats.udp_in++; if (n > 0) from_ip(buf, n); @@ -431,7 +433,8 @@ out_ttyfd: while (io_error(n, buf, n, READ_MSG, IP_MODE, __LINE__)); ipptr = (struct iphdr *) buf; hdr_len = 4 * ipptr-> ihl; - LOGL4("ipdata from=%s l=%d, hl=%d\n", (char *) inet_ntoa(from. sin_addr), n, hdr_len); + LOGL4("ipdata from=%s l=%d, hl=%d\n", + inet_ntoa(from. sin_addr), n, hdr_len); stats.ip_in++; if (n > hdr_len) from_ip(buf + hdr_len, n - hdr_len); @@ -445,7 +448,8 @@ out_ttyfd: while (io_error(n, buf, n, READ_MSG, ICMP_MODE, __LINE__)); ipptr = (struct iphdr *) buf; hdr_len = 4 * ipptr-> ihl; - LOGL4("icmpdata from=%s l=%d, hl=%d\n", (char *) inet_ntoa(from. sin_addr), n, hdr_len); + LOGL4("icmpdata from=%s l=%d, hl=%d\n", + inet_ntoa(from. sin_addr), n, hdr_len); } #endif } @@ -461,11 +465,10 @@ void send_ip(unsigned char *buf, int l, unsigned char *targetip) if (l <= 0) return; - memcpy((char *) &to.sin_addr, - targetip, 4); - memcpy((char *) &to.sin_port, - &targetip[4], 2); - LOGL4("sendipdata to=%s %s %d l=%d\n", (char *) inet_ntoa(to. sin_addr), to.sin_port ? "udp" : "ip", ntohs(to.sin_port), l); + memcpy(&to.sin_addr, targetip, 4); + memcpy(&to.sin_port, &targetip[4], 2); + LOGL4("sendipdata to=%s %s %d l=%d\n", inet_ntoa(to. sin_addr), + to.sin_port ? "udp" : "ip", ntohs(to.sin_port), l); if (to.sin_port) { if (udp_mode) { stats.udp_out++; diff --git a/ax25mond/ax25mond.c b/ax25mond/ax25mond.c index 6f842e1..e27f6aa 100644 --- a/ax25mond/ax25mond.c +++ b/ax25mond/ax25mond.c @@ -83,7 +83,7 @@ struct sockaddr *build_sockaddr(const char *name, int *addrlen) char *serv_name; char buf[1024]; - memset((char *) &addr, 0, sizeof(addr)); + memset(&addr, 0, sizeof(addr)); *addrlen = 0; host_name = strcpy(buf, name); @@ -120,7 +120,7 @@ struct sockaddr *build_sockaddr(const char *name, int *addrlen) if (isdigit(*serv_name & 0xff)) { addr.si.sin_port = htons(atoi(serv_name)); } else { - struct servent *sp = getservbyname(serv_name, (char *) 0); + struct servent *sp = getservbyname(serv_name, NULL); endservent(); if (!sp) return 0; diff --git a/ax25rtd/listener.c b/ax25rtd/listener.c index 9dce370..27353e9 100644 --- a/ax25rtd/listener.c +++ b/ax25rtd/listener.c @@ -138,7 +138,7 @@ int set_arp(config * config, long ip, ax25_address * call) fds = socket(AF_INET, SOCK_DGRAM, 0); - memset((char *) &arp, 0, sizeof(arp)); + memset(&arp, 0, sizeof(arp)); isa = (struct sockaddr_in *) &arp.arp_pa; asa = (struct sockaddr_ax25 *) &arp.arp_ha; @@ -234,7 +234,7 @@ int set_route(config * config, long ip) fds = socket(AF_INET, SOCK_DGRAM, 0); - memset((char *) &rt, 0, sizeof(rt)); + memset(&rt, 0, sizeof(rt)); isa = (struct sockaddr_in *) &rt.rt_dst; @@ -280,7 +280,7 @@ int del_kernel_ip_route(char *dev, long ip) fds = socket(AF_INET, SOCK_DGRAM, 0); - memset((char *) &rt, 0, sizeof(struct rtentry)); + memset(&rt, 0, sizeof(struct rtentry)); isa = (struct sockaddr_in *) &rt.rt_dst; diff --git a/call/yapp.c b/call/yapp.c index 0402990..a8fda53 100644 --- a/call/yapp.c +++ b/call/yapp.c @@ -291,7 +291,7 @@ static int yapp_download_data(int *filefd, unsigned char *buffer) char *hptr, *hfield[3]; if ((length = buffer[1]) == 0) length = 256; - hptr = (char *) buffer + 2; + hptr = buffer + 2; while (length > 0) { int hlen; hlen = strlen(hptr) + 1; @@ -549,7 +549,7 @@ static int yapp_upload_data(int filefd, char *filename, int filelength, len = buffer[1]; if (buffer[len] == 'C') yappc = 1; - rpos = atol((char *) buffer + 4); + rpos = atol(buffer + 4); lseek(filefd, rpos, SEEK_SET); buffer[0] = ACK; buffer[1] = yappc ? ACK : 0x02; -- cgit v1.2.3