From d5b2c5fb2fca378b5c59aa005b16375d14cfd228 Mon Sep 17 00:00:00 2001 From: Peter Eisentraut Date: Tue, 3 Nov 2026 15:39:36 +0100 Subject: [PATCH 02/10] Fix -Wcast-qual warning in lnext() With a little bit of restructuring we can avoid the warning. Also, by using list_cell_number() we don't have to duplicate the assertion. --- src/include/nodes/pg_list.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/include/nodes/pg_list.h b/src/include/nodes/pg_list.h index e93bcbf2698..2d16e0819ca 100644 --- a/src/include/nodes/pg_list.h +++ b/src/include/nodes/pg_list.h @@ -374,10 +374,10 @@ list_cell_number(const List *l, const ListCell *c) static inline ListCell * lnext(const List *l, const ListCell *c) { - Assert(c >= &l->elements[0] && c < &l->elements[l->length]); - c++; - if (c < &l->elements[l->length]) - return (ListCell *) c; + int n = list_cell_number(l, c) + 1; + + if (n < l->length) + return &l->elements[n]; else return NULL; } -- 2.56.0