| From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
|---|---|
| To: | Peter Eisentraut <peter(at)eisentraut(dot)org> |
| Cc: | Zakariyah Ali <zakariyahali100(at)gmail(dot)com>, pgsql-hackers(at)lists(dot)postgresql(dot)org |
| Subject: | Re: [PATCH] Fix compiler warnings by using designated initializers |
| Date: | 2026-06-10 14:31:48 |
| Message-ID: | 1286016.1781101908@sss.pgh.pa.us |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
Peter Eisentraut <peter(at)eisentraut(dot)org> writes:
> It looks like all of the changes are of the form
> - ErrorSaveContext escontext = {T_ErrorSaveContext};
> + ErrorSaveContext escontext = {.type = T_ErrorSaveContext};
Right, that was my understanding too.
> Maybe we could do this more elegantly and safer with a non-pointer
> variant of makeNode/newNode.
> Like
> #define initNode(_type_) ((_type_){.type = T_##_type_})
> ErrorSaveContext escontext = initNode(ErrorSaveContext);
Hmm, that would reduce the risk of writing the wrong T_Foo constant in
this context, but it doesn't seem to me that that risk is high as-is.
Macro wrapper or not, I'm still unclear on why we should think that
this change improves anything. It seems 100.00% arbitrary that this
particular compiler switch produces a warning about the first usage
and not the second, or that some other compiler wouldn't produce a
warning about the second usage. I do see that the gcc manual
documents -Wmissing-field-initializers as behaving this way, but
that doesn't make it any less random.
So my answer to this is "don't use -Wmissing-field-initializers".
The only argument I can see in favor of trying to make our build
clean with that is if we were going to try to be clean with
-Wextra in general. But a quick check says that -Wextra still
produces thousands of lines of pedantry.
In any case, I'd want to see an explicit project decision to make
cleanliness against any new warning switch be a supported thing.
That would probably mean turning it on by default, not just
occasionally accepting drive-by patches about it.
regards, tom lane
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Andres Freund | 2026-06-10 14:36:22 | Re: GetBufferDescriptor() being called for local buffers from MarkBufferDirtyHint() |
| Previous Message | Tatsuo Ishii | 2026-06-10 14:19:02 | Re: Row pattern recognition |