From 433fadf2ac64df23d485f553089a0c26cdb9cc1d Mon Sep 17 00:00:00 2001 From: asomers Date: Tue, 13 Aug 2019 16:22:43 +0000 Subject: [PATCH] Consistently use the byteorder functions in the correct direction MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Though ntohs and htons are functionally identical, they have different meanings.Using the correct one helps to document the code. Submitted by: Ján Sučan MFC after: 2 weeks Sponsored by: Google, inc. (Google Summer of Code 2019) Differential Revision: https://reviews.freebsd.org/D21219 --- sbin/ping6/ping6.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/sbin/ping6/ping6.c b/sbin/ping6/ping6.c index dc303f0b890..0c4b4aa4b61 100644 --- a/sbin/ping6/ping6.c +++ b/sbin/ping6/ping6.c @@ -1324,7 +1324,7 @@ pinger(void) memcpy(nip->icmp6_ni_nonce, nonce, sizeof(nip->icmp6_ni_nonce)); - *(u_int16_t *)nip->icmp6_ni_nonce = ntohs(seq); + *(u_int16_t *)nip->icmp6_ni_nonce = htons(seq); memcpy(&outpack[ICMP6_NIQLEN], &dst.sin6_addr, sizeof(dst.sin6_addr)); @@ -1339,7 +1339,7 @@ pinger(void) memcpy(nip->icmp6_ni_nonce, nonce, sizeof(nip->icmp6_ni_nonce)); - *(u_int16_t *)nip->icmp6_ni_nonce = ntohs(seq); + *(u_int16_t *)nip->icmp6_ni_nonce = htons(seq); cc = ICMP6_NIQLEN; datalen = 0; @@ -1351,7 +1351,7 @@ pinger(void) memcpy(nip->icmp6_ni_nonce, nonce, sizeof(nip->icmp6_ni_nonce)); - *(u_int16_t *)nip->icmp6_ni_nonce = ntohs(seq); + *(u_int16_t *)nip->icmp6_ni_nonce = htons(seq); memcpy(&outpack[ICMP6_NIQLEN], &dst.sin6_addr, sizeof(dst.sin6_addr)); @@ -1366,14 +1366,14 @@ pinger(void) memcpy(nip->icmp6_ni_nonce, nonce, sizeof(nip->icmp6_ni_nonce)); - *(u_int16_t *)nip->icmp6_ni_nonce = ntohs(seq); + *(u_int16_t *)nip->icmp6_ni_nonce = htons(seq); cc = ICMP6_NIQLEN; datalen = 0; } else { icp->icmp6_type = ICMP6_ECHO_REQUEST; icp->icmp6_code = 0; icp->icmp6_id = htons(ident); - icp->icmp6_seq = ntohs(seq); + icp->icmp6_seq = htons(seq); if (timing) { struct timeval tv; struct tv32 *tv32; -- 2.42.0