Hi Eike,
Eike Rathke wrote:
Hi Stephan,
On Wed, Aug 31, 2005 at 10:04:47 +0200, Stephan Bergmann wrote:
Sorry for the (may be stupid) question, but why not just change
OSL_VERIFY to emit nothing, in case OSL_DEBUG_LEVEL == 0? I would expect
that only weird code would relay on the evaluation in case of a zero
debug level. And these case can probably easily be changed to something
with "assert" (or ensure).
No, the code I saw was of the form
OSL_VERIFY(close(f) >= 0);
Well, to me that _is_ weird code. The programmer tried to save
a variable and an assignment of the return value to the variable, but
trades that in for not detecting an unsuccessfull close() in an
OSL_DEBUG_LEVEL == 0 build, and not reacting on it. That's not only bad
style, that's ugly, and maybe even wrong code.
Leaving statements of debug macros in a product version most times leads
to unnecessary code being executed, instead nasty uses such as above
should be detected and eliminated and then OSL_VERIFY() set to empty for
OSL_DEBUG_LEVEL == 0.
Btw, since when would a close() return a value > 0 ?!?
From the man page of "close":
"NOTES
Not checking the return value of close is a common but
nevertheless serious programming error. It is quite possible that
errors on a previous write(2) operation are first reported at the final
close. Not checking the return value when closing the file may lead to
silent loss of data. This can especially be observed with NFS and
with disk quota."
In respect to this, the above code is very weird, if not wrong at all.
Such errors _must_ be propagated. So, who wants to have the bug ?! ;-)
Eike
Kay
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]