On Wed, Jan 15, 2025 at 11:34:14PM -0500, Tom Lane wrote:
> Michael Paquier <mich...@paquier.xyz> writes:
> > I cannot reproduce that, perhaps I'm just missing something with these
> > switches.  Do you think that a cast would cool things?  Please see the
> > attached for the idea.
> 
> There are only three animals showing this warning (ayu, batfish,
> demoiselle) so it likely requires particular clang versions
> as well as the right -W switches.

All of them on ppc with clang 4 or 5.  That's dated.  :)

> Maybe a cast would silence it, but your draft seems
> underparenthesized.  (Which raises the question of whether we
> should be using a macro for this at all --- probably there's
> not much risk of double-evaluation being a problem, but a
> static inline would remove the risk.)

Just for an assert, I would just remove the macro rather than have an
inline function.
--
Michael
diff --git a/src/backend/utils/activity/pgstat_io.c b/src/backend/utils/activity/pgstat_io.c
index e03b021af3..12d54d5c4a 100644
--- a/src/backend/utils/activity/pgstat_io.c
+++ b/src/backend/utils/activity/pgstat_io.c
@@ -23,14 +23,6 @@
 static PgStat_PendingIO PendingIOStats;
 static bool have_iostats = false;
 
-/*
- * Check if an IOOp is tracked in bytes.  This relies on the ordering of IOOp
- * defined in pgstat.h, so make sure to update this check when changing its
- * elements.
- */
-#define pgstat_is_ioop_tracked_in_bytes(io_op) \
-	((io_op) < IOOP_NUM_TYPES && (io_op) >= IOOP_EXTEND)
-
 /*
  * Check that stats have not been counted for any combination of IOObject,
  * IOContext, and IOOp which are not tracked for the passed-in BackendType. If
@@ -78,7 +70,8 @@ pgstat_count_io_op(IOObject io_object, IOContext io_context, IOOp io_op,
 {
 	Assert((unsigned int) io_object < IOOBJECT_NUM_TYPES);
 	Assert((unsigned int) io_context < IOCONTEXT_NUM_TYPES);
-	Assert(pgstat_is_ioop_tracked_in_bytes(io_op) || bytes == 0);
+	Assert(((unsigned int) io_op < IOOP_NUM_TYPES &&
+			(unsigned int) io_op >= IOOP_EXTEND) || bytes == 0);
 	Assert(pgstat_tracks_io_op(MyBackendType, io_object, io_context, io_op));
 
 	if (pgstat_tracks_backend_bktype(MyBackendType))

Attachment: signature.asc
Description: PGP signature

Reply via email to