[PATCH] Constify proclist.h

Started by Aleksander Alekseevalmost 3 years ago2 messages
#1Aleksander Alekseev
aleksander@timescale.com
1 attachment(s)

Hi hackers,

This is a follow-up to [1]/messages/by-id/CAJ7c6TM2=08mNKD9aJg8vEY9hd+G4L7+Nvh30UiNT3kShgRgNg@mail.gmail.com and c8ad4d81.

Additionally Bharath pointed out that there are other pieces of code
that we may want to change in a similar fashion,
proclist.h/proclist_types.h as one example. I didn't do this yet
because I would like to know the community opinion first on whether we
should do this at all.

Since the consensus seems to be to constify everything possible here
is the patch for proclist.h. There is nothing to change in
proclist_types.h.

[1]: /messages/by-id/CAJ7c6TM2=08mNKD9aJg8vEY9hd+G4L7+Nvh30UiNT3kShgRgNg@mail.gmail.com

--
Best regards,
Aleksander Alekseev

Attachments:

v1-0001-Constify-proclist.h.patchapplication/octet-stream; name=v1-0001-Constify-proclist.h.patchDownload
From a2e7d3bc5a57896a02e791e11f825247ff7dedc9 Mon Sep 17 00:00:00 2001
From: Aleksander Alekseev <aleksander@timescale.com>
Date: Tue, 17 Jan 2023 15:09:26 +0300
Subject: [PATCH v1] Constify proclist.h
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

This is a follow-up to c8ad4d81.

Author: Aleksander Alekseev
Reviewed-by: TODO FIXME
Discussion: TODO FIXME add a new thread here
Discussion: https://postgr.es/m/CAJ7c6TM2%3D08mNKD9aJg8vEY9hd%2BG4L7%2BNvh30UiNT3kShgRgNg%40mail.gmail.com
---
 src/include/storage/proclist.h | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/src/include/storage/proclist.h b/src/include/storage/proclist.h
index 6ef896500f..e7d00e5ce1 100644
--- a/src/include/storage/proclist.h
+++ b/src/include/storage/proclist.h
@@ -35,7 +35,7 @@ proclist_init(proclist_head *list)
  * Is the list empty?
  */
 static inline bool
-proclist_is_empty(proclist_head *list)
+proclist_is_empty(const proclist_head *list)
 {
 	return list->head == INVALID_PGPROCNO;
 }
@@ -143,10 +143,10 @@ proclist_delete_offset(proclist_head *list, int procno, size_t node_offset)
  * so that the only possibilities are that it is in this list or none.
  */
 static inline bool
-proclist_contains_offset(proclist_head *list, int procno,
+proclist_contains_offset(const proclist_head *list, int procno,
 						 size_t node_offset)
 {
-	proclist_node *node = proclist_node_get(procno, node_offset);
+	const proclist_node *node = proclist_node_get(procno, node_offset);
 
 	/* If it's not in any list, it's definitely not in this one. */
 	if (node->prev == 0 && node->next == 0)
-- 
2.39.0

#2Peter Eisentraut
peter.eisentraut@enterprisedb.com
In reply to: Aleksander Alekseev (#1)
Re: [PATCH] Constify proclist.h

On 17.01.23 13:18, Aleksander Alekseev wrote:

This is a follow-up to [1] and c8ad4d81.

Additionally Bharath pointed out that there are other pieces of code
that we may want to change in a similar fashion,
proclist.h/proclist_types.h as one example. I didn't do this yet
because I would like to know the community opinion first on whether we
should do this at all.

Since the consensus seems to be to constify everything possible here
is the patch for proclist.h. There is nothing to change in
proclist_types.h.

[1]: /messages/by-id/CAJ7c6TM2=08mNKD9aJg8vEY9hd+G4L7+Nvh30UiNT3kShgRgNg@mail.gmail.com

committed