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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, Jul 12, 2024 at 11:09:00AM +0530, Chandra Pratap wrote:
> 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 <ps@xxxxxx>
> Mentored-by: Christian Couder <chriscool@xxxxxxxxxxxxx>
> Signed-off-by: Chandra Pratap <chandrapratap3519@xxxxxxxxx>
> ---
>  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

Attachment: signature.asc
Description: PGP signature


[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux