From 10f3e50b75e7c6df5df4efd1098ca00b0f5c2ff9 Mon Sep 17 00:00:00 2001 From: Fred Klassen Date: Sat, 19 Dec 2015 17:38:30 -0800 Subject: [PATCH] fix compiler warnings --- src/common/sendpacket.c | 5 +++-- src/fragroute/mod_ip6_opt.c | 3 --- src/tcpreplay_api.c | 9 +++++++-- src/tcprewrite.c | 3 +-- 4 files changed, 11 insertions(+), 9 deletions(-) diff --git a/src/common/sendpacket.c b/src/common/sendpacket.c index 34e64dd8b..449f20dba 100644 --- a/src/common/sendpacket.c +++ b/src/common/sendpacket.c @@ -160,6 +160,7 @@ static int get_iface_index(int fd, const char *device, char *); #ifdef HAVE_TUNTAP #ifdef HAVE_LINUX +#include #include #elif defined(HAVE_FREEBSD) #define TUNTAP_DEVICE_PREFIX "/dev/" @@ -775,7 +776,7 @@ sendpacket_get_hwaddr_pcap(sendpacket_t *sp) } #endif /* HAVE_PCAP_INJECT || HAVE_PCAP_SENDPACKET */ -#if defined HAVE_LIBDNET +#if defined HAVE_LIBDNET && !defined HAVE_PF_PACKET && !defined HAVE_BPF /** * Inner sendpacket_open() method for using libdnet */ @@ -806,7 +807,7 @@ sendpacket_open_libdnet(const char *device, char *errbuf) static struct tcpr_ether_addr * sendpacket_get_hwaddr_libdnet(sendpacket_t *sp) { - struct tcpr_ether_addr *addr; + struct tcpr_ether_addr *addr = NULL; int ret; assert(sp); diff --git a/src/fragroute/mod_ip6_opt.c b/src/fragroute/mod_ip6_opt.c index f90a8950e..7efbbcb9d 100644 --- a/src/fragroute/mod_ip6_opt.c +++ b/src/fragroute/mod_ip6_opt.c @@ -107,7 +107,6 @@ int ip6_opt_apply(void *d, struct pktq *pktq) { struct ip6_opt_data *opt = (struct ip6_opt_data *)d; - struct __ip6_ext_data_routing* route; struct ip6_ext_hdr* ext; int offset, len; struct pkt *pkt; @@ -134,8 +133,6 @@ ip6_opt_apply(void *d, struct pktq *pktq) len = (IP6_ADDR_LEN / 8) * opt->u.route.segments; - route = (struct __ip6_ext_data_routing*)ext; - ext->ext_data.routing.type = 0; ext->ext_data.routing.segleft = opt->u.route.segments; ((uint32_t*)ext)[1] = 0; /* reserved */ diff --git a/src/tcpreplay_api.c b/src/tcpreplay_api.c index 310c707a3..136b68606 100644 --- a/src/tcpreplay_api.c +++ b/src/tcpreplay_api.c @@ -182,9 +182,14 @@ tcpreplay_post_args(tcpreplay_t *ctx, int argc) options->speed.mode = speed_oneatatime; options->speed.speed = 0; } else if (HAVE_OPT(MBPS)) { - options->speed.mode = speed_mbpsrate; n = atof(OPT_ARG(MBPS)); - options->speed.speed = (COUNTER)(n * 1000000.0); /* convert to bps */ + if (n) { + options->speed.mode = speed_mbpsrate; + options->speed.speed = (COUNTER)(n * 1000000.0); /* convert to bps */ + } else { + options->speed.mode = speed_topspeed; + options->speed.speed = 0; + } } else if (HAVE_OPT(MULTIPLIER)) { options->speed.mode = speed_multiplier; options->speed.multiplier = atof(OPT_ARG(MULTIPLIER)); diff --git a/src/tcprewrite.c b/src/tcprewrite.c index d860bca7d..5b9eb9f1a 100644 --- a/src/tcprewrite.c +++ b/src/tcprewrite.c @@ -229,7 +229,7 @@ rewrite_packets(tcpedit_t *tcpedit, pcap_t *pin, pcap_dumper_t *pout) COUNTER packetnum = 0; int rcode; #ifdef ENABLE_FRAGROUTE - int frag_len, i, proto; + int frag_len, proto; #endif pkthdr_ptr = &pkthdr; @@ -302,7 +302,6 @@ rewrite_packets(tcpedit_t *tcpedit, pcap_t *pin, pcap_dumper_t *pout) if (fragroute_process(options.frag_ctx, *pktdata, pkthdr_ptr->caplen) < 0) errx(-1, "Error processing packet via fragroute: %s", options.frag_ctx->errbuf); - i = 0; while ((frag_len = fragroute_getfragment(options.frag_ctx, &frag)) > 0) { /* frags get the same timestamp as the original packet */ dbgx(1, "processing packet " COUNTER_SPEC " frag: %u (%d)", packetnum, i++, frag_len);