Re: Modernize const handling with readline

Поиск
Список
Период
Сортировка
От Aleksander Alekseev
Тема Re: Modernize const handling with readline
Дата
Msg-id CAJ7c6TNdeqko=kZtSLx=QWg9qKuGg53Od3nr9sJKuXcHxURqSA@mail.gmail.com
обсуждение исходный текст
Ответ на Modernize const handling with readline  (Peter Eisentraut <peter@eisentraut.org>)
Ответы Re: Modernize const handling with readline  (Peter Eisentraut <peter@eisentraut.org>)
Список pgsql-hackers
Hi,

> The comment
>
>      /* On some platforms, readline is declared as readline(char *) */
>
> is obsolete.  The casting away of const can be removed.
>
> The const in the readline() prototype was added in GNU readline 4.2,
> released in 2001.  BSD libedit has also had const in the prototype since
> at least 2001.
>
> (The commit that introduced this comment (187e865174) talked about
> FreeBSD 4.8, which didn't have readline compatibility in libedit yet, so
> it must have been talking about GNU readline in the base system.  This
> checks out, but already FreeBSD 5 had an updated GNU readline with const.)

LGTM.

While examining the code for similar places I noticed that the
following functions can also be const'ified:

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

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.

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)
```

Will there be a value in addressing anything of this?

-- 
Best regards,
Aleksander Alekseev



В списке pgsql-hackers по дате отправления:

Предыдущее
От: Amit Kapila
Дата:
Сообщение: Re: Synchronizing slots from primary to standby
Следующее
От: Andrei Lepikhov
Дата:
Сообщение: Re: Add the ability to limit the amount of memory that can be allocated to backends.