From b18c2decd76eeffbd483c041c02bb0fb01b0f124 Mon Sep 17 00:00:00 2001 From: Peter Eisentraut Date: Wed, 14 Dec 2022 16:08:13 +0100 Subject: [PATCH] Rearrange some static assertions for consistency Put lengthof first. Reported-by: Peter Smith Discussion: https://www.postgresql.org/message-id/CAHut+PsUDMySVRuRc=h+P5N3+=TGvj4W_mi32XXg9dt4o-BXbA@mail.gmail.com --- src/backend/executor/execExprInterp.c | 2 +- src/backend/utils/cache/syscache.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/backend/executor/execExprInterp.c b/src/backend/executor/execExprInterp.c index 1dab2787b7..be48886511 100644 --- a/src/backend/executor/execExprInterp.c +++ b/src/backend/executor/execExprInterp.c @@ -496,7 +496,7 @@ ExecInterpExpr(ExprState *state, ExprContext *econtext, bool *isnull) &&CASE_EEOP_LAST }; - StaticAssertStmt(EEOP_LAST + 1 == lengthof(dispatch_table), + StaticAssertStmt(lengthof(dispatch_table) == EEOP_LAST + 1, "dispatch_table out of whack with ExprEvalOp"); if (unlikely(state == NULL)) diff --git a/src/backend/utils/cache/syscache.c b/src/backend/utils/cache/syscache.c index eec644ec84..8b35968353 100644 --- a/src/backend/utils/cache/syscache.c +++ b/src/backend/utils/cache/syscache.c @@ -1068,7 +1068,7 @@ InitCatalogCache(void) { int cacheId; - StaticAssertStmt(SysCacheSize == (int) lengthof(cacheinfo), + StaticAssertStmt(lengthof(cacheinfo) == SysCacheSize, "SysCacheSize does not match syscache.c's array"); Assert(!CacheInitialized);