Messages in this thread | | | From | Linus Torvalds <> | Date | Tue, 27 Feb 2024 12:49:34 -0800 | Subject | Re: [PATCH 1/3] cleanup: Add cond_guard() to conditional guards |
| |
On Tue, 27 Feb 2024 at 08:48, Dan Williams <dan.j.williams@intel.com> wrote: > > cond_guard(mutex_intr, return -EINTR, &mutex);
Again, this is *not* helping make code readable and less likely to have bugs.
The macro has obvious deficiencies, like the "_fail" argument not being surrounded by "{ }" (the equivalent of parenthesizing an expression argument), but even with that trivial fix the syntax is just too ugly to live, and doesn't match normal C syntax.
And yes, we have other macros that don't have normal C syntax, and they are ugly too (example: #define CHKINFO(ret) in drivers/video/fbdev/hgafb.c), but we should have higher standards for globally visible helpers, and we should have *MUCH* higher standards for helpers that are supposed to be all about reducing mistakes.
Bad / odd syntax does not reduce mistakes.
If a sane 'guard' model doesn't work for some code, the answer is not to make an insane guard model. The answer is to not use 'guard' in code like that.
Linus
| |