Re: [dev] Suckless DNS server

From: Jeremy <jer_AT_jer.cx>
Date: Wed, 19 Jul 2023 17:38:58 -0700

On 07/20/23 04:57AM, NRK wrote:
>
> C standard defines shift operator as multiplication and division by
> powers of 2. And the result of `x * 256` never depend on the system's
> byte order and so neither does `x << 8`.
>
> Rob Pike already has an excellent article on this, so I'll just refer to
> that: https://commandcenter.blogspot.com/2012/04/byte-order-fallacy.html
>

I now realize that I was not right. You're correct.

> > Instead, one can use htons(byteorder.3).
>
> If anything, those functions are precisely the source of confusion like
> these and should be avoided for this reason.
>

I meant `ntohs`... and this further proves your point.
Thank you for your insight & for the article.

Jeremy
Received on Thu Jul 20 2023 - 02:38:58 CEST

This archive was generated by hypermail 2.3.0 : Thu Jul 20 2023 - 02:48:08 CEST