mirror of
https://git.postgresql.org/git/postgresql.git
synced 2024-09-28 21:01:48 +02:00
Fix warning introduced in 5c279a6d35
.
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
This commit is contained in:
parent
e349c95d3e
commit
9553b4115f
@ -101,7 +101,7 @@ RegisterCustomRmgr(RmgrId rmid, RmgrData *rmgr)
|
|||||||
ereport(ERROR, (errmsg("custom resource manager name is invalid"),
|
ereport(ERROR, (errmsg("custom resource manager name is invalid"),
|
||||||
errhint("Provide a non-empty name for the custom resource manager.")));
|
errhint("Provide a non-empty name for the custom resource manager.")));
|
||||||
|
|
||||||
if (!RMID_IS_CUSTOM(rmid))
|
if (!RmgrIdIsCustom(rmid))
|
||||||
ereport(ERROR, (errmsg("custom resource manager ID %d is out of range", rmid),
|
ereport(ERROR, (errmsg("custom resource manager ID %d is out of range", rmid),
|
||||||
errhint("Provide a custom resource manager ID between %d and %d.",
|
errhint("Provide a custom resource manager ID between %d and %d.",
|
||||||
RM_MIN_CUSTOM_ID, RM_MAX_CUSTOM_ID)));
|
RM_MIN_CUSTOM_ID, RM_MAX_CUSTOM_ID)));
|
||||||
@ -153,7 +153,7 @@ pg_get_wal_resource_managers(PG_FUNCTION_ARGS)
|
|||||||
continue;
|
continue;
|
||||||
values[0] = Int32GetDatum(rmid);
|
values[0] = Int32GetDatum(rmid);
|
||||||
values[1] = CStringGetTextDatum(GetRmgr(rmid).rm_name);
|
values[1] = CStringGetTextDatum(GetRmgr(rmid).rm_name);
|
||||||
values[2] = BoolGetDatum(RMID_IS_BUILTIN(rmid));
|
values[2] = BoolGetDatum(RmgrIdIsBuiltin(rmid));
|
||||||
tuplestore_putvalues(rsinfo->setResult, rsinfo->setDesc, values, nulls);
|
tuplestore_putvalues(rsinfo->setResult, rsinfo->setDesc, values, nulls);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1102,7 +1102,7 @@ ValidXLogRecordHeader(XLogReaderState *state, XLogRecPtr RecPtr,
|
|||||||
(uint32) SizeOfXLogRecord, record->xl_tot_len);
|
(uint32) SizeOfXLogRecord, record->xl_tot_len);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (!RMID_IS_VALID(record->xl_rmid))
|
if (!RmgrIdIsValid(record->xl_rmid))
|
||||||
{
|
{
|
||||||
report_invalid_record(state,
|
report_invalid_record(state,
|
||||||
"invalid resource manager ID %u at %X/%X",
|
"invalid resource manager ID %u at %X/%X",
|
||||||
|
@ -749,7 +749,7 @@ XLogDumpDisplayStats(XLogDumpConfig *config, XLogDumpStats *stats)
|
|||||||
tot_len;
|
tot_len;
|
||||||
const RmgrDescData *desc;
|
const RmgrDescData *desc;
|
||||||
|
|
||||||
if (!RMID_IS_VALID(ri))
|
if (!RmgrIdIsValid(ri))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
desc = GetRmgrDesc(ri);
|
desc = GetRmgrDesc(ri);
|
||||||
@ -761,7 +761,7 @@ XLogDumpDisplayStats(XLogDumpConfig *config, XLogDumpStats *stats)
|
|||||||
fpi_len = stats->rmgr_stats[ri].fpi_len;
|
fpi_len = stats->rmgr_stats[ri].fpi_len;
|
||||||
tot_len = rec_len + fpi_len;
|
tot_len = rec_len + fpi_len;
|
||||||
|
|
||||||
if (RMID_IS_CUSTOM(ri) && count == 0)
|
if (RmgrIdIsCustom(ri) && count == 0)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
XLogDumpStatsRow(desc->rm_name,
|
XLogDumpStatsRow(desc->rm_name,
|
||||||
@ -1025,7 +1025,7 @@ main(int argc, char **argv)
|
|||||||
*/
|
*/
|
||||||
if (sscanf(optarg, "custom%03d", &rmid) == 1)
|
if (sscanf(optarg, "custom%03d", &rmid) == 1)
|
||||||
{
|
{
|
||||||
if (!RMID_IS_CUSTOM(rmid))
|
if (!RmgrIdIsCustom(rmid))
|
||||||
{
|
{
|
||||||
pg_log_error("custom resource manager \"%s\" does not exist",
|
pg_log_error("custom resource manager \"%s\" does not exist",
|
||||||
optarg);
|
optarg);
|
||||||
|
@ -86,9 +86,9 @@ initialize_custom_rmgrs(void)
|
|||||||
const RmgrDescData *
|
const RmgrDescData *
|
||||||
GetRmgrDesc(RmgrId rmid)
|
GetRmgrDesc(RmgrId rmid)
|
||||||
{
|
{
|
||||||
Assert(RMID_IS_VALID(rmid));
|
Assert(RmgrIdIsValid(rmid));
|
||||||
|
|
||||||
if (RMID_IS_BUILTIN(rmid))
|
if (RmgrIdIsBuiltin(rmid))
|
||||||
return &RmgrDescTable[rmid];
|
return &RmgrDescTable[rmid];
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -37,10 +37,20 @@ typedef enum RmgrIds
|
|||||||
#define RM_N_IDS (UINT8_MAX + 1)
|
#define RM_N_IDS (UINT8_MAX + 1)
|
||||||
#define RM_N_BUILTIN_IDS (RM_MAX_BUILTIN_ID + 1)
|
#define RM_N_BUILTIN_IDS (RM_MAX_BUILTIN_ID + 1)
|
||||||
#define RM_N_CUSTOM_IDS (RM_MAX_CUSTOM_ID - RM_MIN_CUSTOM_ID + 1)
|
#define RM_N_CUSTOM_IDS (RM_MAX_CUSTOM_ID - RM_MIN_CUSTOM_ID + 1)
|
||||||
#define RMID_IS_BUILTIN(rmid) ((rmid) <= RM_MAX_BUILTIN_ID)
|
|
||||||
#define RMID_IS_CUSTOM(rmid) ((rmid) >= RM_MIN_CUSTOM_ID && \
|
static inline bool
|
||||||
(rmid) <= RM_MAX_CUSTOM_ID)
|
RmgrIdIsBuiltin(int rmid)
|
||||||
#define RMID_IS_VALID(rmid) (RMID_IS_BUILTIN((rmid)) || RMID_IS_CUSTOM((rmid)))
|
{
|
||||||
|
return rmid <= RM_MAX_BUILTIN_ID;
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline bool
|
||||||
|
RmgrIdIsCustom(int rmid)
|
||||||
|
{
|
||||||
|
return rmid >= RM_MIN_CUSTOM_ID && rmid <= RM_MAX_CUSTOM_ID;
|
||||||
|
}
|
||||||
|
|
||||||
|
#define RmgrIdIsValid(rmid) (RmgrIdIsBuiltin((rmid)) || RmgrIdIsCustom((rmid)))
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* RmgrId to use for extensions that require an RmgrId, but are still in
|
* RmgrId to use for extensions that require an RmgrId, but are still in
|
||||||
|
Loading…
Reference in New Issue
Block a user