From: lteo Date: Fri, 16 Jan 2015 03:19:57 +0000 (+0000) Subject: Remove pointless casts for several malloc/calloc/free calls. No object X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=1b8dcd42e689e6f9a3568339cefb3dfb6453a1a9;p=openbsd Remove pointless casts for several malloc/calloc/free calls. No object file change. --- diff --git a/lib/libpcap/nametoaddr.c b/lib/libpcap/nametoaddr.c index 5fee6e19b70..ef98b504e8a 100644 --- a/lib/libpcap/nametoaddr.c +++ b/lib/libpcap/nametoaddr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: nametoaddr.c,v 1.15 2014/12/06 23:20:17 krw Exp $ */ +/* $OpenBSD: nametoaddr.c,v 1.16 2015/01/16 03:19:57 lteo Exp $ */ /* * Copyright (c) 1990, 1991, 1992, 1993, 1994, 1995, 1996 @@ -316,7 +316,7 @@ pcap_ether_aton(const char *s) register u_char *ep, *e; register u_int d; - e = ep = (u_char *)malloc(6); + e = ep = malloc(6); if (e == NULL) bpf_error("malloc"); @@ -356,7 +356,7 @@ pcap_ether_hostton(const char *name) while ((ep = pcap_next_etherent(fp)) != NULL) { if (strcmp(ep->name, name) == 0) { - ap = (u_char *)malloc(6); + ap = malloc(6); if (ap != NULL) { memcpy(ap, ep->addr, 6); return (ap); @@ -377,7 +377,7 @@ pcap_ether_hostton(const char *name) ap = NULL; if (ether_hostton(name, (struct ether_addr *)a) == 0) { - ap = (u_char *)malloc(6); + ap = malloc(6); if (ap != NULL) memcpy((char *)ap, (char *)a, 6); } diff --git a/lib/libpcap/pcap-bpf.c b/lib/libpcap/pcap-bpf.c index 5ca44688c13..d3184d2ee10 100644 --- a/lib/libpcap/pcap-bpf.c +++ b/lib/libpcap/pcap-bpf.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pcap-bpf.c,v 1.25 2015/01/16 03:04:19 lteo Exp $ */ +/* $OpenBSD: pcap-bpf.c,v 1.26 2015/01/16 03:19:57 lteo Exp $ */ /* * Copyright (c) 1993, 1994, 1995, 1996, 1998 @@ -288,7 +288,7 @@ get_dlt_list(int fd, int v, struct bpf_dltlist *bdlp, char *ebuf) { memset(bdlp, 0, sizeof(*bdlp)); if (ioctl(fd, BIOCGDLTLIST, (caddr_t)bdlp) == 0) { - bdlp->bfl_list = (u_int *) calloc(bdlp->bfl_len + 1, sizeof(u_int)); + bdlp->bfl_list = calloc(bdlp->bfl_len + 1, sizeof(u_int)); if (bdlp->bfl_list == NULL) { (void)snprintf(ebuf, PCAP_ERRBUF_SIZE, "malloc: %s", pcap_strerror(errno)); @@ -651,7 +651,7 @@ pcap_activate(pcap_t *p) goto bad; } p->bufsize = v; - p->buffer = (u_char *)malloc(p->bufsize); + p->buffer = malloc(p->bufsize); if (p->buffer == NULL) { snprintf(p->errbuf, PCAP_ERRBUF_SIZE, "malloc: %s", pcap_strerror(errno)); @@ -744,7 +744,7 @@ monitor_mode(pcap_t *p, int set) * Allocate a buffer to hold all the media types, and * get the media types. */ - media_list = (int *) calloc(req.ifm_count, sizeof(int)); + media_list = calloc(req.ifm_count, sizeof(int)); if (media_list == NULL) { snprintf(p->errbuf, PCAP_ERRBUF_SIZE, "malloc: %s", pcap_strerror(errno)); diff --git a/lib/libpcap/pcap.c b/lib/libpcap/pcap.c index 6757e769ab0..2dd70d123b2 100644 --- a/lib/libpcap/pcap.c +++ b/lib/libpcap/pcap.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pcap.c,v 1.15 2014/06/26 04:03:33 lteo Exp $ */ +/* $OpenBSD: pcap.c,v 1.16 2015/01/16 03:19:57 lteo Exp $ */ /* * Copyright (c) 1993, 1994, 1995, 1996, 1997, 1998 @@ -256,7 +256,7 @@ pcap_list_datalinks(pcap_t *p, int **dlt_buffer) * DLT for an interface. Return a list of DLTs * containing only the DLT this device supports. */ - *dlt_buffer = (int*)malloc(sizeof(**dlt_buffer)); + *dlt_buffer = malloc(sizeof(**dlt_buffer)); if (*dlt_buffer == NULL) { (void)snprintf(p->errbuf, sizeof(p->errbuf), "malloc: %s", pcap_strerror(errno)); diff --git a/lib/libpcap/savefile.c b/lib/libpcap/savefile.c index 5c3bff9dc77..c9b79c991bd 100644 --- a/lib/libpcap/savefile.c +++ b/lib/libpcap/savefile.c @@ -1,4 +1,4 @@ -/* $OpenBSD: savefile.c,v 1.12 2014/03/14 03:45:41 lteo Exp $ */ +/* $OpenBSD: savefile.c,v 1.13 2015/01/16 03:19:57 lteo Exp $ */ /* * Copyright (c) 1993, 1994, 1995, 1996, 1997 @@ -184,7 +184,7 @@ pcap_fopen_offline(FILE *fp, char *errbuf) if (p->bufsize < 0) p->bufsize = BPF_MAXBUFSIZE; - p->sf.base = (u_char *)malloc(p->bufsize + BPF_ALIGNMENT); + p->sf.base = malloc(p->bufsize + BPF_ALIGNMENT); if (p->sf.base == NULL) { strlcpy(errbuf, "out of swap", PCAP_ERRBUF_SIZE); goto bad; @@ -258,8 +258,8 @@ sf_next_packet(pcap_t *p, struct pcap_pkthdr *hdr, u_char *buf, int buflen) if (tsize < hdr->caplen) { tsize = ((hdr->caplen + 1023) / 1024) * 1024; if (tp != NULL) - free((u_char *)tp); - tp = (u_char *)malloc(tsize); + free(tp); + tp = malloc(tsize); if (tp == NULL) { tsize = 0; snprintf(p->errbuf, PCAP_ERRBUF_SIZE,