From: | Peter Eisentraut <peter(at)eisentraut(dot)org> |
---|---|
To: | Bertrand Drouvot <bertranddrouvot(dot)pg(at)gmail(dot)com>, pgsql-hackers(at)lists(dot)postgresql(dot)org |
Subject: | Re: define pg_structiszero(addr, s, r) |
Date: | 2024-09-18 08:03:21 |
Message-ID: | 3023d29e-0fe7-4bec-9028-7f3c0102e437@eisentraut.org |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
On 18.09.24 06:16, Bertrand Drouvot wrote:
> +#define pg_structiszero(addr, s, r) \
> + do { \
> + /* We assume this initializes to zeroes */ \
> + static const s all_zeroes; \
> + r = (memcmp(addr, &all_zeroes, sizeof(all_zeroes)) == 0); \
> + } while (0)
This assumption is kind of the problem, isn't it? Because, you can't
assume that. And the existing code is arguably kind of wrong. But
moreover, this macro also assumes that the "addr" argument has no random
padding bits.
In the existing code, you can maybe make a local analysis that the code
is working correctly, although I'm not actually sure. But if you are
repackaging this as a general macro under a general-sounding name, then
the requirements should be more stringent.
From | Date | Subject | |
---|---|---|---|
Next Message | Peter Eisentraut | 2024-09-18 08:09:38 | Re: information_schema.view attgenerated |
Previous Message | Bertrand Drouvot | 2024-09-18 07:54:20 | Re: define pg_structiszero(addr, s, r) |