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

Joe Jin <[email protected]>
Newsgroups org.kernel.vger.util-linux
Message-ID <[email protected]>
On 2/27/25 01:25, Karel Zak wrote:
> 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.

I'll remove the macro.

>
>> +#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.

Thanks for your suggestions, I'll create an inline function.

Thanks,
Joe

>
>     Karel
>
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.