[Swan-dev] passert.h: PASSERT should not return a value

D. Hugh Redelmeier hugh at mimosa.com
Fri Aug 20 16:00:42 UTC 2021

| From: Andrew Cagney <andrew.cagney at gmail.com>

|     includes: allow if (!passert(...))
|     mainly so it is easy to switch between pexpect()
|     and passert().
| (which is presumably to make debugging easier)


The use of a passert as if it returned a value looks like a mistake.  It 
makes unreachable code.  I would hope that static analysis tools would 
warn when they see it.

If, during debugging, you want a passert with the same test and location 
as an existing pexpect, you can easily add the passert without changing 
the pexpect.

In my experience, adding code for debugging is better than changing code 
for debugging.  When you no longer want it, you delete it, rather than 
having to reversing a change.

(Since "make base" on my system didn't whine after my change, there does 
not seem to be case in HEAD where the value returned by PASSERT is used.)

More information about the Swan-dev mailing list