summaryrefslogtreecommitdiff
path: root/networking
diff options
context:
space:
mode:
authorDenis Vlasenko2008-04-25 08:13:36 +0000
committerDenis Vlasenko2008-04-25 08:13:36 +0000
commita6b3a1f0bfc394a18b4cb4181a4827bf054206b4 (patch)
treea8251e40e9e9cd00a347da3236348727f2c5efa6 /networking
parent4d89a8bd1d6a081be559656b67f4adfc75137740 (diff)
downloadbusybox-a6b3a1f0bfc394a18b4cb4181a4827bf054206b4.zip
busybox-a6b3a1f0bfc394a18b4cb4181a4827bf054206b4.tar.gz
arping: save a few bytes by using mempcpy
function old new delta catcher 357 339 -18
Diffstat (limited to 'networking')
-rw-r--r--networking/arping.c22
1 files changed, 12 insertions, 10 deletions
diff --git a/networking/arping.c b/networking/arping.c
index 2b7a43c..9d2c671 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) {