public inbox for dtrace@lists.linux.dev
 help / color / mirror / Atom feed
From: eugene.loh@oracle.com
To: dtrace@lists.linux.dev, dtrace-devel@oss.oracle.com
Subject: [PATCH 2/2] Use a consistent type for dtrace_consume()
Date: Tue, 12 Aug 2025 18:46:06 -0400	[thread overview]
Message-ID: <20250812224606.16606-2-eugene.loh@oracle.com> (raw)
In-Reply-To: <20250812224606.16606-1-eugene.loh@oracle.com>

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


  reply	other threads:[~2025-08-12 22:46 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 ` eugene.loh [this message]
2025-08-15 15:35   ` [DTrace-devel] [PATCH 2/2] Use a consistent type for dtrace_consume() Kris Van Hees
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=20250812224606.16606-2-eugene.loh@oracle.com \
    --to=eugene.loh@oracle.com \
    --cc=dtrace-devel@oss.oracle.com \
    --cc=dtrace@lists.linux.dev \
    /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