From: Ondřej Surý Date: Mon, 18 Aug 2025 06:05:33 +0000 (+0200) Subject: Use ISC_UxxTOyy_BE macros for {peek,get,put}_uint16 macros X-Git-Tag: v9.21.12~40^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=80dac1bbae31fa947d70b6a5387ae6f68e4d8061;p=thirdparty%2Fbind9.git Use ISC_UxxTOyy_BE macros for {peek,get,put}_uint16 macros Reduce the duplication and use existing macros from isc/endian.h for network to host and vice versa conversion. --- diff --git a/lib/dns/rdataslab_p.h b/lib/dns/rdataslab_p.h index 2fed31a2f04..5ce39fbbc63 100644 --- a/lib/dns/rdataslab_p.h +++ b/lib/dns/rdataslab_p.h @@ -13,6 +13,8 @@ #pragma once +#include + #include #define ANCIENT(header) \ @@ -58,15 +60,15 @@ ((atomic_load_acquire(&(header)->attributes) & \ DNS_SLABHEADERATTR_ZEROTTL) != 0) -#define peek_uint16(buffer) ({ ((uint16_t)*(buffer) << 8) | *((buffer) + 1); }) +#define peek_uint16(buffer) ISC_U8TO16_BE(buffer) #define get_uint16(buffer) \ ({ \ uint16_t __ret = peek_uint16(buffer); \ buffer += sizeof(uint16_t); \ __ret; \ }) -#define put_uint16(buffer, val) \ - ({ \ - *buffer++ = (val & 0xff00) >> 8; \ - *buffer++ = (val & 0x00ff); \ - }) +#define put_uint16(buffer, val) \ + { \ + ISC_U16TO8_BE(buffer, val); \ + (buffer) += sizeof(uint16_t); \ + }