News for hackers. Stuff that matters.
Re:Tidy First? by aulin on Friday January 12, 2024 @12:22AM (#38964209)
You can define your guard clauses as macros and have them always log a warning and still have your debug log before the final return. See e.g. g_return_if_fail/reached and g_return_val_if_fail/reached in glib/gmessages.h.

Early returns can definitely cause bugs, but here we're talking about basic sanity checks and argument validation, not about program logic. Their purpose is if any of those checks fail we are in a very bad state and there's no point on entering the function at all.

There are no comments on this comment yet.