pg.ddx.io  pgsql-hackers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Bryan Green <dbryan.green@gmail.com>
Cc: pgsql-hackers@lists.postgresql.org
Subject: Re: C nitpick about pgwin32_dispatch_queued_signals()
Date: Sun, 02 Nov 2025 11:47:45 -0500
Message-ID: <428507.1762102065@sss.pgh.pa.us> (raw)
In-Reply-To: <9c55d148-17c5-4d3a-96a1-7ece939a202a@gmail.com>
References: <cc4ef8db-f8dc-4347-8a22-e7ebf44c0308@chrullrich.net>
	<9c55d148-17c5-4d3a-96a1-7ece939a202a@gmail.com>

Bryan Green <dbryan.green@gmail.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.

> 2. Restructure to use && instead of ?::

>      #define INTERRUPTS_PENDING_CONDITION() \
>          (unlikely(UNBLOCKED_SIGNAL_QUEUE()) && \
>              (pgwin32_dispatch_queued_signals(), true), \
>           unlikely(InterruptPending))

> I'd lean towards #2 --- it's cleaner and avoids the whole issue.

I dunno, don't really like the nested comma operator here.
It's probably necessary to avoid having a void argument to &&,
but it's confusing.  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/.

			regards, tom lane





view thread (5+ messages)  latest in thread

Message-ID: <428507.1762102065@sss.pgh.pa.us>
Permalink:  ../428507.1762102065@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/428507.1762102065@sss.pgh.pa.us

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-hackers@postgresql.org
  Cc: tgl@sss.pgh.pa.us, dbryan.green@gmail.com, pgsql-hackers@lists.postgresql.org
  Subject: Re: C nitpick about pgwin32_dispatch_queued_signals()
  In-Reply-To: <428507.1762102065@sss.pgh.pa.us>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox