Re: Modernize const handling with readline

From: Peter Eisentraut <peter(at)eisentraut(dot)org>
To: Aleksander Alekseev <aleksander(at)timescale(dot)com>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Modernize const handling with readline
Date: 2023-10-04 14:37:16
Message-ID: e08317a0-a2e7-c60d-c14a-ad9fc34f8f6c@eisentraut.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 03.10.23 13:28, Aleksander Alekseev wrote:
> While examining the code for similar places I noticed that the
> following functions can also be const'ified:
>
> - crc32_sz

I suppose this could be changed.

> - pg_checksum_page (? temporary modifies the page but then restores it)

Then it's not really const?

> - XLogRegisterData (?)

I don't think this would work, at least without further work elsewhere,
because the data is stored in XLogRecData, which has no const handling.

> The callers of cstring_to_text[_with_len] often cast the argument to
> (char *) while in fact it's (const char *). This can be refactored
> too.

These look fine to me.

> Additionally there is a slight difference between XLogRegisterBlock()
> declaration in xloginsert.h:
>
> ```
> extern void XLogRegisterBlock(uint8 block_id, RelFileLocator *rlocator,
> ForkNumber forknum, BlockNumber blknum,
> char *page,
> uint8 flags);
> ```
>
> ... and xloginsert.c:
>
> ```
> void
> XLogRegisterBlock(uint8 block_id, RelFileLocator *rlocator, ForkNumber forknum,
> BlockNumber blknum, Page page, uint8 flags)
> ```

It looks like the reason here is that xloginsert.h does not have the
Page type in scope. I don't know how difficult it would be to change
that, but it seems fine as is.

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Robert Haas 2023-10-04 14:39:19 Re: --sync-method isn't documented to take an argument
Previous Message Alvaro Herrera 2023-10-04 14:35:32 Re: --sync-method isn't documented to take an argument