Re: [PATCH 1/3] irqtop: add batch mode support

Karel Zak
2025-02-27T09:25:38Z

On Wed, Feb 26, 2025 at 08:49:14PM GMT, Joe Jin wrote:
> +#define irqtop_batch_mode(ctl) ((ctl)->batch == true)

Do we need this macro? I think use

if (ctl->batch)
...
or

if (!ctl->batch)
...

in the code is good enough.

> +#define irqtop_printf(ctl, fmt, args...) \
> + do { \
> + if (irqtop_batch_mode(ctl)) \
> + fprintf(stdout, fmt, ##args); \
> + else { \
> + wprintw(ctl->win, fmt, ##args); \
> + } \
> + }while(0)

It would be more robust to use an inline function with vw_printw() and
vfprintf() rather than a macro with a variadic number of arguments, or
use __VA_ARGS__ in the macro.

Karel

--
Karel Zak <kzak@redhat.com>