Re: C nitpick about pgwin32_dispatch_queued_signals()

From: Laurenz Albe <laurenz(dot)albe(at)cybertec(dot)at>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Bryan Green <dbryan(dot)green(at)gmail(dot)com>
Cc: pgsql-hackers(at)lists(dot)postgresql(dot)org
Subject: Re: C nitpick about pgwin32_dispatch_queued_signals()
Date: 2025-11-02 16:50:24
Message-ID: 61e4a1f457e84e725be3f92e272a4f8768c4d324.camel@cybertec.at
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Sun, 2025-11-02 at 11:47 -0500, Tom Lane wrote:
> Bryan Green <dbryan(dot)green(at)gmail(dot)com> writes:
> > On 11/2/2025 7:05 AM, Christian Ullrich wrote:
> > > the current MSVC compiler deems it necessary to issue
> > > warning C4053: one void operand for '?:'
> > > for a line with CHECK_FOR_INTERRUPTS(). This boils down to this bit of
> > > miscadmin.h (line 116 in master):
> > >
> > > #define INTERRUPTS_PENDING_CONDITION() \
> > > (unlikely(UNBLOCKED_SIGNAL_QUEUE()) ?
> > > pgwin32_dispatch_queued_signals() : 0, \
> > > unlikely(InterruptPending))
> > > #endif
> > >
> > > The C spec says that of the possible results of the :? operator, either
> > > none or both can be void, and pgwin32_dispatch_queued_signals() is void
> > > (and has been as far back as I can find it).
>
> > Yeah, this is a bug, or at least a spec violation. We should fix it in
> > my opinion-- it's non-conforming C. Others may disagree, though.
>
> Agreed.
>
>
> Let's go with your #1 (casting the 0 to void).
> But can't we simplify that to just
>
> #define INTERRUPTS_PENDING_CONDITION() \
> (unlikely(UNBLOCKED_SIGNAL_QUEUE()) ?
> pgwin32_dispatch_queued_signals() : (void) 0, \
> unlikely(InterruptPending))
> #endif
>
> that is, the only change needed is s/0/(void) 0/.

+1

Laurenz Albe

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Bryan Green 2025-11-02 16:52:52 Re: C nitpick about pgwin32_dispatch_queued_signals()
Previous Message Tom Lane 2025-11-02 16:47:45 Re: C nitpick about pgwin32_dispatch_queued_signals()