From: Johannes Sixt Date: Wed, 17 May 2017 18:15:03 GMT Subject: Re: [PATCH v1 2/5] Teach git to optionally utilize a file system monitor to speed up detecting new or changed files. Message-ID: <2e5ea82d-3b8f-f508-e2af-5f193241a573@kdbg.org> In-Reply-To: <0a3f38b7-788b-b364-3fef-83191e4b9bea@gmail.com> Am 17.05.2017 um 16:26 schrieb Ben Peart: > On 5/16/2017 3:13 PM, Johannes Sixt wrote: >> Am 16.05.2017 um 19:17 schrieb Ben Peart: >>> OK, now I'm confused as to the best path for adding a get_be64. This >>> one is trivial: >>> >>> #define get_be64(p) ntohll(*(uint64_t *)(p)) >> >> I cringe when I see a cast like this. Unless you can guarantee that p is >> char* (bare or signed or unsigned), you fall pray to strict aliasing >> violations, aka undefined behavior. And I'm not even mentioning correct >> alignment, yet. > > Note, this macro is only used where the CPU architecture is OK with > unaligned memory access. I'm not worried about the unaligned memory access: It either works, or we get a SIGBUS. The undefined behavior is more worrisome because the code may work or not, and we can never be sure which it is. -- Hannes