From a6b3a1f0bfc394a18b4cb4181a4827bf054206b4 Mon Sep 17 00:00:00 2001 From: Denis Vlasenko Date: Fri, 25 Apr 2008 08:13:36 +0000 Subject: [PATCH] arping: save a few bytes by using mempcpy function old new delta catcher 357 339 -18 --- networking/arping.c | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/networking/arping.c b/networking/arping.c index 2b7a43cb6..9d2c671bc 100644 --- a/networking/arping.c +++ b/networking/arping.c @@ -66,6 +66,13 @@ struct globals { count = -1; \ } while (0) +// If GNUisms are not available... +//static void *mempcpy(void *_dst, const void *_src, int n) +//{ +// memcpy(_dst, _src, n); +// return (char*)_dst + n; +//} + static int send_pack(struct in_addr *src_addr, struct in_addr *dst_addr, struct sockaddr_ll *ME, struct sockaddr_ll *HE) @@ -81,20 +88,15 @@ static int send_pack(struct in_addr *src_addr, ah->ar_pln = 4; ah->ar_op = option_mask32 & ADVERT ? htons(ARPOP_REPLY) : htons(ARPOP_REQUEST); - memcpy(p, &ME->sll_addr, ah->ar_hln); - p += ME->sll_halen; - - memcpy(p, src_addr, 4); - p += 4; + p = mempcpy(p, &ME->sll_addr, ah->ar_hln); + p = mempcpy(p, src_addr, 4); if (option_mask32 & ADVERT) - memcpy(p, &ME->sll_addr, ah->ar_hln); + p = mempcpy(p, &ME->sll_addr, ah->ar_hln); else - memcpy(p, &HE->sll_addr, ah->ar_hln); - p += ah->ar_hln; + p = mempcpy(p, &HE->sll_addr, ah->ar_hln); - memcpy(p, dst_addr, 4); - p += 4; + p = mempcpy(p, dst_addr, 4); err = sendto(sock_fd, buf, p - buf, 0, (struct sockaddr *) HE, sizeof(*HE)); if (err == p - buf) { -- 2.25.1