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

Karel Zak <[email protected]>
Newsgroups org.kernel.vger.util-linux
Message-ID <3cip52rtte72zolbb2ta6ztl63p4ez7oo2wmi5fpqvjxz45jwk@akiqt56yf4vs>
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  <[email protected]>
 http://karelzak.blogspot.com
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.