Rework macro pgstat_is_ioop_tracked_in_bytes()
authorMichael Paquier <[email protected]>
Thu, 16 Jan 2025 23:26:17 +0000 (08:26 +0900)
committerMichael Paquier <[email protected]>
Thu, 16 Jan 2025 23:26:17 +0000 (08:26 +0900)
As written, it was triggering a compilation warning for old versions of
clang, as reported by buildfarm members ayu, batfish and demoiselle.
Forcing a cast with "unsigned int" should fix the warning.

While on it, the macro is moved to pgstat.h, closer to the declaration
of IOOp, per suggestion from Tom Lane.

Reported-by: Tom Lane
Reviewed-by: Bertrand Drouvot, Tom Lane, Nazir Bilal Yavuz
Discussion: https://postgr.es/m/1272824.1736961543@sss.pgh.pa.us

src/backend/utils/activity/pgstat_io.c
src/include/pgstat.h

index e03b021af3d2f91a37b756c44c728adebe0c2bf1..027aad8b24ef27662bdc26b75612c6659f402d66 100644 (file)
 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
index a878402f502e3c609c4615b0885b9400bc6bc111..2d40fe3e70ffe400018f7f1bac30d0bcc44d5ccc 100644 (file)
@@ -314,6 +314,10 @@ typedef enum IOOp
 
 #define IOOP_NUM_TYPES (IOOP_WRITE + 1)
 
+#define pgstat_is_ioop_tracked_in_bytes(io_op) \
+       (((unsigned int) (io_op)) < IOOP_NUM_TYPES && \
+        ((unsigned int) (io_op)) >= IOOP_EXTEND)
+
 typedef struct PgStat_BktypeIO
 {
        uint64          bytes[IOOBJECT_NUM_TYPES][IOCONTEXT_NUM_TYPES][IOOP_NUM_TYPES];