From d996257f5e639c45538e6e1f99af41da4aec099b Mon Sep 17 00:00:00 2001 From: Emmanuel Roullit Date: Wed, 4 Jul 2012 18:20:42 +0200 Subject: [PATCH] Code refactoring. --- libdabba/pcap.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/libdabba/pcap.c b/libdabba/pcap.c index aee47a3..cd13cd3 100644 --- a/libdabba/pcap.c +++ b/libdabba/pcap.c @@ -269,11 +269,15 @@ ssize_t pcap_write(const int fd, const uint8_t * const pkt, sf_hdr.caplen = pkt_snaplen; sf_hdr.len = pkt_len; - if ((written = write(fd, &sf_hdr, sizeof(sf_hdr))) != sizeof(sf_hdr)) { + written = write(fd, &sf_hdr, sizeof(sf_hdr)); + + if (written != sizeof(sf_hdr)) { return (-1); } - if ((written = write(fd, pkt, sf_hdr.caplen)) != (ssize_t) sf_hdr.caplen) { + written = write(fd, pkt, sf_hdr.caplen); + + if (written != (ssize_t) sf_hdr.caplen) { return (-1); } -- 2.11.4.GIT