Re: define pg_structiszero(addr, s, r)
| От | Peter Eisentraut |
|---|---|
| Тема | Re: define pg_structiszero(addr, s, r) |
| Дата | |
| Msg-id | 3023d29e-0fe7-4bec-9028-7f3c0102e437@eisentraut.org обсуждение исходный текст |
| Ответы |
Re: define pg_structiszero(addr, s, r)
|
| Список | 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.
В списке pgsql-hackers по дате отправления: