From: Kris Van Hees <kris.van.hees@oracle.com>
To: Eugene Loh <eugene.loh@oracle.com>
Cc: Kris Van Hees <kris.van.hees@oracle.com>,
dtrace@lists.linux.dev, dtrace-devel@oss.oracle.com
Subject: Re: [PATCH 1/3] parser: add dt_node_is_tstring()
Date: Wed, 16 Jul 2025 01:16:37 -0400 [thread overview]
Message-ID: <aHc1tajKJW6lAuhP@oracle.com> (raw)
In-Reply-To: <1c67ce82-fbe6-2fa1-f8dd-c92ea3eb0932@oracle.com>
On Wed, Jul 16, 2025 at 12:43:10AM -0400, Eugene Loh wrote:
> Reviewed-by: Eugene Loh <eugene.loh@oracle.com>
>
> Two minor comments:
>
> 1. It is practically unheard of in our code base to start the switch
> statement with the default case. With maybe one exception, we put the
> default case at the end.
I know, but I wanted to really clearly communicate that the most common case
will be that the node does not have a tstring, i.e. default is the most common
case.
> 2. How about using this function in dt_cg_tstring_free() so that it becomes
>
> static void
> dt_cg_tstring_free(dt_pcb_t *pcb, dt_node_t *dnp)
> {
> if (dt_node_is_tstring(dnp) {
> dt_cg_tstring_xfree(pcb, dnp->dn_tstring->dn_value);
> dnp->dn_tstring = NULL;
> }
> }
Good idea.
> On 7/15/25 15:50, Kris Van Hees wrote:
>
> > Returns 1 if the given node has a tstring associated with it. Internal
> > change to make implementing optimized tstring-handling easier.
> >
> > Signed-off-by: Kris Van Hees <kris.van.hees@oracle.com>
> > ---
> > libdtrace/dt_parser.c | 15 +++++++++++++++
> > libdtrace/dt_parser.h | 1 +
> > 2 files changed, 16 insertions(+)
> >
> > diff --git a/libdtrace/dt_parser.c b/libdtrace/dt_parser.c
> > index eefe8341..f777a910 100644
> > --- a/libdtrace/dt_parser.c
> > +++ b/libdtrace/dt_parser.c
> > @@ -1227,6 +1227,21 @@ dt_node_is_actfunc(const dt_node_t *dnp)
> > dnp->dn_ident->di_kind == DT_IDENT_ACTFUNC;
> > }
> > +int
> > +dt_node_is_tstring(const dt_node_t *dnp)
> > +{
> > + switch (dnp->dn_kind) {
> > + default:
> > + return 0;
> > + case DT_NODE_FUNC:
> > + case DT_NODE_OP1:
> > + case DT_NODE_OP2:
> > + case DT_NODE_OP3:
> > + case DT_NODE_DEXPR:
> > + return dnp->dn_tstring != NULL;
> > + }
> > +}
> > +
> > /*
> > * The original rules for integer constant typing are described in K&R[A2.5.1].
> > * However, since we support long long, we instead use the rules from ISO C99
> > diff --git a/libdtrace/dt_parser.h b/libdtrace/dt_parser.h
> > index 13f3cc99..ff32a84a 100644
> > --- a/libdtrace/dt_parser.h
> > +++ b/libdtrace/dt_parser.h
> > @@ -182,6 +182,7 @@ extern int dt_node_is_ptrcompat(const dt_node_t *, const dt_node_t *,
> > extern int dt_node_is_argcompat(const dt_node_t *, const dt_node_t *);
> > extern int dt_node_is_posconst(const dt_node_t *);
> > extern int dt_node_is_actfunc(const dt_node_t *);
> > +extern int dt_node_is_tstring(const dt_node_t *);
> > extern dt_node_t *dt_node_int(uintmax_t);
> > extern dt_node_t *dt_node_string(char *);
prev parent reply other threads:[~2025-07-16 5:16 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-07-15 19:50 [PATCH 1/3] parser: add dt_node_is_tstring() Kris Van Hees
2025-07-16 4:43 ` Eugene Loh
2025-07-16 5:16 ` Kris Van Hees [this message]
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=aHc1tajKJW6lAuhP@oracle.com \
--to=kris.van.hees@oracle.com \
--cc=dtrace-devel@oss.oracle.com \
--cc=dtrace@lists.linux.dev \
--cc=eugene.loh@oracle.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.