Re: Missing CFI in iterate_word_similarity() - Mailing list pgsql-hackers

From Daniel Gustafsson
Subject Re: Missing CFI in iterate_word_similarity()
Date
Msg-id 64010994-D43E-4327-B4C1-8ACED4F7D052@yesql.se
Whole thread Raw
In response to Re: Missing CFI in iterate_word_similarity()  (Tom Lane <tgl@sss.pgh.pa.us>)
Responses Re: Missing CFI in iterate_word_similarity()
List pgsql-hackers
> On 2 Sep 2022, at 14:57, Tom Lane <tgl@sss.pgh.pa.us> wrote:
>
> Daniel Gustafsson <daniel@yesql.se> writes:
>> Placing code before declarations will generate a compiler warning, so the check
>> must go after trgindex is declared.  I've fixed that in the attached to get the
>> cfbot green.  Marking this ready for committer in the meantime.
>
> I noticed the same thing, but sticking the CFI immediately after the
> declaration didn't read well either.  I was considering moving it to
> the bottom of the loop instead of that.

I was contemplating that too, but kept it at the top after seeing quite a few
examples of that in other contrib modules (like amcheck/verify_nbtree.c and
pg_visibility/pg_visibility.c).  I don't have any strong feelings either way,
I'm happy to move it last.

> A possible objection is that
> if there's ever a "continue;" in the loop, those iterations would bypass
> the CFI; but we don't necessarily need a CFI every time.

Yeah, I don't think we need to worry about that.  If an added continue;
shortcuts the loop to the point where keeping the CFI last becomes a problem
then it's probably time to look at rewriting the loop.

--
Daniel Gustafsson        https://vmware.com/




pgsql-hackers by date:

Previous
From: Tom Lane
Date:
Subject: Re: Missing CFI in iterate_word_similarity()
Next
From: Tom Lane
Date:
Subject: Re: Missing CFI in iterate_word_similarity()