From: Steven Rostedt <rostedt@goodmis.org>
To: Donglin Peng <dolinux.peng@gmail.com>
Cc: mhiramat@kernel.org, linux-trace-devel@vger.kernel.org,
Donglin Peng <pengdonglin@xiaomi.com>
Subject: Re: [PATCH RESEND] libtraceevent: Pretty print function parameters of enum-type
Date: Sat, 7 Feb 2026 09:16:12 -0500 [thread overview]
Message-ID: <20260207091612.2bb72f61@robin> (raw)
In-Reply-To: <CAErzpmt8EQXD_noaR+gsBaAV90xAQSMJ38BgBd_8r-Q_40-abA@mail.gmail.com>
On Sat, 7 Feb 2026 13:04:02 +0800
Donglin Peng <dolinux.peng@gmail.com> wrote:
> > > +#define for_each_enum(i, enum_type, member) \
> > > + for (i = 0, member = btf_enum(enum_type); \
> > > + i < BTF_INFO_VLEN(enum_type->info); \
> > > + i++, member++)
> >
> >
> > You can make the above into:
> >
> > #define for_each_enum(enum_type, member) \
> > for (int __i = 0, member = btf_enum(enum_type); \
> > __i < BTF_INFO_VLEN((enum_type)->info); \
> > __i++, member++)
> >
> > Then you don't need to pass in the counter "i".
>
> Sorry, I found that the previous change causes a build failure.
>
> The error occurs in trace-btf.c:36:
> warning: initialization of 'int' from 'struct btf_enum *' makes
> integer from pointer without a cast [-Wint-conversion]
> 36 | for (int __i = 0, member = btf_enum(enum_type); \
>
> This is due to the member variable being redefined as an int type,
> conflicting with its assignment of a struct btf_enum *pointer from
> btf_enum(enum_type).
Ah, I had that issue before. But this should work:
#define for_each_enum(enum_type, member) \
member = btf_enum(enum_type); \
for (int __i = 0; __i < BTF_INFO_VLEN((enum_type)->info); \
__i++, member++)
Just can't use it as a single line for if statements.
if (x)
for_each_enum() {
}
But we shouldn't be doing that anyway.
-- Steve
next prev parent reply other threads:[~2026-02-07 14:16 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-02-06 9:15 [PATCH RESEND] libtraceevent: Pretty print function parameters of enum-type Donglin Peng
2026-02-06 15:02 ` Steven Rostedt
2026-02-07 4:28 ` Donglin Peng
2026-02-07 5:04 ` Donglin Peng
2026-02-07 14:16 ` Steven Rostedt [this message]
2026-02-08 12:02 ` Donglin Peng
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260207091612.2bb72f61@robin \
--to=rostedt@goodmis.org \
--cc=dolinux.peng@gmail.com \
--cc=linux-trace-devel@vger.kernel.org \
--cc=mhiramat@kernel.org \
--cc=pengdonglin@xiaomi.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.