diff options
author | Enrico Scholz <enrico.scholz@sigma-chemnitz.de> | 2022-08-30 09:38:04 +0200 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2022-08-31 08:31:21 +0200 |
commit | 7a52de00c64e3e04880ea6258a8b5260033f22c5 (patch) | |
tree | bf920960dfdae06b873e46210ab232c261b3cedd /fs | |
parent | 3fdff746b02031fbd1cf90e419d0d7694802eb9e (diff) | |
download | barebox-7a52de00c64e3e04880ea6258a8b5260033f22c5.tar.gz |
tftp: add debug_assert() macro
Is a noop in normal cases (when compiler sees that the condition can
be evaluated without sideeffects) but allows optimizations based on
the condition.
E.g. in
| void foo(int a)
| {
| debug_assert(a == 23);
|
| if (a == 23)
| return;
|
| bar();
| }
the call to 'bar()' will be optimized away.
Signed-off-by: Enrico Scholz <enrico.scholz@sigma-chemnitz.de>
Link: https://lore.barebox.org/20220830073816.2694734-10-enrico.scholz@sigma-chemnitz.de
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'fs')
-rw-r--r-- | fs/tftp.c | 9 |
1 files changed, 9 insertions, 0 deletions
@@ -70,6 +70,15 @@ #define TFTP_ERR_RESEND 1 +#ifdef DEBUG +# define debug_assert(_cond) BUG_ON(!(_cond)) +#else +# define debug_assert(_cond) do { \ + if (!(_cond)) \ + __builtin_unreachable(); \ + } while (0) +#endif + struct file_priv { struct net_connection *tftp_con; int push; |