Skip to content

Commit 9553b41

Browse files
committed
Fix warning introduced in 5c279a6.
Change two macros to be static inline functions instead to keep the data type consistent. This avoids a "comparison is always true" warning that was occurring with -Wtype-limits. In the process, change the names to look less like macros. Discussion: https://postgr.es/m/20220407063505.njnnrmbn4sxqfsts@alap3.anarazel.de
1 parent e349c95 commit 9553b41

File tree

5 files changed

+22
-12
lines changed

5 files changed

+22
-12
lines changed

src/backend/access/transam/rmgr.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ RegisterCustomRmgr(RmgrId rmid, RmgrData *rmgr)
101101
ereport(ERROR, (errmsg("custom resource manager name is invalid"),
102102
errhint("Provide a non-empty name for the custom resource manager.")));
103103

104-
if (!RMID_IS_CUSTOM(rmid))
104+
if (!RmgrIdIsCustom(rmid))
105105
ereport(ERROR, (errmsg("custom resource manager ID %d is out of range", rmid),
106106
errhint("Provide a custom resource manager ID between %d and %d.",
107107
RM_MIN_CUSTOM_ID, RM_MAX_CUSTOM_ID)));
@@ -153,7 +153,7 @@ pg_get_wal_resource_managers(PG_FUNCTION_ARGS)
153153
continue;
154154
values[0] = Int32GetDatum(rmid);
155155
values[1] = CStringGetTextDatum(GetRmgr(rmid).rm_name);
156-
values[2] = BoolGetDatum(RMID_IS_BUILTIN(rmid));
156+
values[2] = BoolGetDatum(RmgrIdIsBuiltin(rmid));
157157
tuplestore_putvalues(rsinfo->setResult, rsinfo->setDesc, values, nulls);
158158
}
159159

src/backend/access/transam/xlogreader.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1102,7 +1102,7 @@ ValidXLogRecordHeader(XLogReaderState *state, XLogRecPtr RecPtr,
11021102
(uint32) SizeOfXLogRecord, record->xl_tot_len);
11031103
return false;
11041104
}
1105-
if (!RMID_IS_VALID(record->xl_rmid))
1105+
if (!RmgrIdIsValid(record->xl_rmid))
11061106
{
11071107
report_invalid_record(state,
11081108
"invalid resource manager ID %u at %X/%X",

src/bin/pg_waldump/pg_waldump.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -749,7 +749,7 @@ XLogDumpDisplayStats(XLogDumpConfig *config, XLogDumpStats *stats)
749749
tot_len;
750750
const RmgrDescData *desc;
751751

752-
if (!RMID_IS_VALID(ri))
752+
if (!RmgrIdIsValid(ri))
753753
continue;
754754

755755
desc = GetRmgrDesc(ri);
@@ -761,7 +761,7 @@ XLogDumpDisplayStats(XLogDumpConfig *config, XLogDumpStats *stats)
761761
fpi_len = stats->rmgr_stats[ri].fpi_len;
762762
tot_len = rec_len + fpi_len;
763763

764-
if (RMID_IS_CUSTOM(ri) && count == 0)
764+
if (RmgrIdIsCustom(ri) && count == 0)
765765
continue;
766766

767767
XLogDumpStatsRow(desc->rm_name,
@@ -1025,7 +1025,7 @@ main(int argc, char **argv)
10251025
*/
10261026
if (sscanf(optarg, "custom%03d", &rmid) == 1)
10271027
{
1028-
if (!RMID_IS_CUSTOM(rmid))
1028+
if (!RmgrIdIsCustom(rmid))
10291029
{
10301030
pg_log_error("custom resource manager \"%s\" does not exist",
10311031
optarg);

src/bin/pg_waldump/rmgrdesc.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,9 +86,9 @@ initialize_custom_rmgrs(void)
8686
const RmgrDescData *
8787
GetRmgrDesc(RmgrId rmid)
8888
{
89-
Assert(RMID_IS_VALID(rmid));
89+
Assert(RmgrIdIsValid(rmid));
9090

91-
if (RMID_IS_BUILTIN(rmid))
91+
if (RmgrIdIsBuiltin(rmid))
9292
return &RmgrDescTable[rmid];
9393
else
9494
{

src/include/access/rmgr.h

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,20 @@ typedef enum RmgrIds
3737
#define RM_N_IDS (UINT8_MAX + 1)
3838
#define RM_N_BUILTIN_IDS (RM_MAX_BUILTIN_ID + 1)
3939
#define RM_N_CUSTOM_IDS (RM_MAX_CUSTOM_ID - RM_MIN_CUSTOM_ID + 1)
40-
#define RMID_IS_BUILTIN(rmid) ((rmid) <= RM_MAX_BUILTIN_ID)
41-
#define RMID_IS_CUSTOM(rmid) ((rmid) >= RM_MIN_CUSTOM_ID && \
42-
(rmid) <= RM_MAX_CUSTOM_ID)
43-
#define RMID_IS_VALID(rmid) (RMID_IS_BUILTIN((rmid)) || RMID_IS_CUSTOM((rmid)))
40+
41+
static inline bool
42+
RmgrIdIsBuiltin(int rmid)
43+
{
44+
return rmid <= RM_MAX_BUILTIN_ID;
45+
}
46+
47+
static inline bool
48+
RmgrIdIsCustom(int rmid)
49+
{
50+
return rmid >= RM_MIN_CUSTOM_ID && rmid <= RM_MAX_CUSTOM_ID;
51+
}
52+
53+
#define RmgrIdIsValid(rmid) (RmgrIdIsBuiltin((rmid)) || RmgrIdIsCustom((rmid)))
4454

4555
/*
4656
* RmgrId to use for extensions that require an RmgrId, but are still in

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy