Thread (39 messages) 39 messages, 4 authors, 2024-07-24

Re: [PATCH v4 4/7] t-reftable-merged: improve the const-correctness of helper functions

From: Patrick Steinhardt <hidden>
Date: 2024-07-24 09:12:10

On Fri, Jul 12, 2024 at 11:09:00AM +0530, Chandra Pratap wrote:
quoted hunk ↗ jump to hunk
In t-reftable-merged.c, a number of helper functions used by the
tests can be re-defined with parameters made 'const' which makes
it easier to understand if they're read-only or not. Re-define
these functions along these lines.

Mentored-by: Patrick Steinhardt [off-list ref]
Mentored-by: Christian Couder [off-list ref]
Signed-off-by: Chandra Pratap <redacted>
---
 t/unit-tests/t-reftable-merged.c | 19 +++++++++----------
 1 file changed, 9 insertions(+), 10 deletions(-)
diff --git a/t/unit-tests/t-reftable-merged.c b/t/unit-tests/t-reftable-merged.c
index f4c14c5d47..ff2f448bb6 100644
--- a/t/unit-tests/t-reftable-merged.c
+++ b/t/unit-tests/t-reftable-merged.c
@@ -15,7 +15,7 @@ license that can be found in the LICENSE file or at
 #include "reftable/reftable-merged.h"
 #include "reftable/reftable-writer.h"
 
-static ssize_t strbuf_add_void(void *b, const void *data, size_t sz)
+static ssize_t strbuf_add_void(void *b, const void *data, const size_t sz)
It is quite uncustomary for the Git codebase to mark such plain values
as `const`. While there is value in marking pointers as constant such
that the caller knows that the data it points to won't get modified,
there isn't really any value in marking pass-by-value parameters.

As far as I can see all changes relate to pass-by-value parameters, so
I'd rather drop this patch.

Patrick

Attachments

Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help