Hi,
On Tue, Jan 20, 2026 at 1:59 PM Chao Li <li.evan.chao@gmail.com> wrote:
>
> Good catch. But I think we should retain the explanation for -2. How about like:
>
> For buf_internal.h:
> ```
> /*
> * Buffer's index number: >= 0 for shared buffers, < -1 for local buffers.
> * * For shared buffers, buf_id is 0 to NBuffers-1.
> * * For local buffers, buf_id is -2 to -NLocBuffers-1.
> *
> * This ensures that (buf_id+1) done by BufferDescriptorGetBuffer never returns InvalidBuffer(0).
> */
> int buf_id;
> ```
>
> For localbuf.c
> ```
> /*
> * buf_id must be <= -2 for local buffers so that the
> * Buffer handle (buf_id + 1) is <= -1, avoiding InvalidBuffer (0)
> */
> ```
Thank you for looking into this!
I agree with your suggestion to add "This ensures that ..." comment. But if
we add it, I guess that we won't need to duplicate this comment in localbuf.c .
BTW, maybe it is not good that we are hardcoding the name of the
BufferDescriptorGetBuffer function in the comments, but I saw the same thing
in several other places.
Please, see the attached patch that includes your proposal.
--
Best regards,
Daniil Davydov