public inbox for dtrace@lists.linux.dev
 help / color / mirror / Atom feed
From: Kris Van Hees <kris.van.hees@oracle.com>
To: eugene.loh@oracle.com
Cc: dtrace@lists.linux.dev, dtrace-devel@oss.oracle.com
Subject: Re: [DTrace-devel] [PATCH 2/2] Use a consistent type for dtrace_consume()
Date: Fri, 15 Aug 2025 11:35:14 -0400	[thread overview]
Message-ID: <aJ9Tsgo33AyjR2F0@oracle.com> (raw)
In-Reply-To: <20250812224606.16606-2-eugene.loh@oracle.com>

On Tue, Aug 12, 2025 at 06:46:06PM -0400, eugene.loh--- via DTrace-devel wrote:
> From: Eugene Loh <eugene.loh@oracle.com>
> 
> For a long time, the type of dtrace_consume() has been
> - int                 according to libdtrace/dtrace.h
> - dtrace_workstatus_t according to libdtrace/dt_consume.c
> 
> With some recent compilers, however, this triggers the warning (redacted
> here):
> 
>     libdtrace/dt_consume.c:3041:1: warning: conflicting types
>     for ???dtrace_consume??? due to enum/integer mismatch;
>     have ???dtrace_workstatus_t(...)??? [-Wenum-int-mismatch]
>      3041 | dtrace_consume(...)
>           | ^~~~~~~~~~~~~~
>     In file included from libdtrace/dt_impl.h:14,
>                      from libdtrace/dt_consume.c:16:
>     libdtrace/dtrace.h:210:12: note: previous declaration of
>     ???dtrace_consume??? with type ???int(...)???
>       210 | extern int dtrace_consume(...)
>           |            ^~~~~~~~~~~~~~
> 
> which is a nuisance.
> 
> Note that dtrace_consume() is called from only one site, where its
> value is compared to DTRACE_WORKSTATUS_ERROR, which is an argument
> for the dtrace_workstatus_t type.
> 
> On the other hand, dtrace_consume() is defined to return a variety
> of values, like 0, dt_set_errno(), and dt_consume_cpu(), all of which
> are int, but also DTRACE_WORKSTATUS_OKAY, DTRACE_WORKSTATUS_ERROR,
> and rval, all of which are dtrace_workstatus_t.  But then rval itself
> is set to dtrace_workstatus_t dt_consume_begin() or int
> dt_consume_cpu().  So, there is simply no consistency here.
> 
> Having the prototype be dtrace_workstatus_t requires some amount
> of code refactoring.
> 
> Just change the definition to int and clean up the warning.
> 
> Signed-off-by: Eugene Loh <eugene.loh@oracle.com>

Reviewed-by: Kris Van Hees <kris.van.hees@oracle.com>

... I admit this was my fault.  I tried to refactor the code so that we could
    have dtrace_consume() return dtrace_workstatus_t, but only got this far.
    I agree that for now, changing the return type of dtrace_consume() is the
    best action to get rid of the compiler warning.  Maybe we can revisit the
    actual refactoring work later to clean this up properly.

> ---
>  libdtrace/dt_consume.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/libdtrace/dt_consume.c b/libdtrace/dt_consume.c
> index 07b19d498..d9be563d9 100644
> --- a/libdtrace/dt_consume.c
> +++ b/libdtrace/dt_consume.c
> @@ -3037,7 +3037,7 @@ dt_consume_fini(dtrace_hdl_t *dtp)
>  	dt_htab_destroy(dtp->dt_spec_bufs);
>  }
>  
> -dtrace_workstatus_t
> +int
>  dtrace_consume(dtrace_hdl_t *dtp, FILE *fp, dtrace_consume_probe_f *pf,
>  	       dtrace_consume_rec_f *rf, void *arg)
>  {
> -- 
> 2.47.3
> 
> 
> _______________________________________________
> DTrace-devel mailing list
> DTrace-devel@oss.oracle.com
> https://oss.oracle.com/mailman/listinfo/dtrace-devel

  reply	other threads:[~2025-08-15 15:35 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-08-12 22:46 [PATCH 1/2] Possible uninitialized 'last' variable in usdt_copyin_data() eugene.loh
2025-08-12 22:46 ` [PATCH 2/2] Use a consistent type for dtrace_consume() eugene.loh
2025-08-15 15:35   ` Kris Van Hees [this message]
2025-08-15 15:25 ` [PATCH 1/2] Possible uninitialized 'last' variable in usdt_copyin_data() Kris Van Hees
2025-08-15 17:12   ` Eugene Loh
2025-08-15 17:50     ` Kris Van Hees

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=aJ9Tsgo33AyjR2F0@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox