git/list[1] front-page[2] threads[3] people[4] search[5] about
 

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

From
Patrick Steinhardt <ps@pks.im>
Date
Jul 24, 2024, 09:12 UTC
Message-ID
<ZqDFZAWBlW39Q25T@tanuki>
In-Reply-To
<20240712055041.6476-5-chandrapratap3519@gmail.com>
On Fri, Jul 12, 2024 at 11:09:00AM +0530, Chandra Pratap wrote:
Show 22 quoted lines
> 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@pks.im>
> Mentored-by: Christian Couder <chriscool@tuxfamily.org>
> Signed-off-by: Chandra Pratap <chandrapratap3519@gmail.com>
> ---
>  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
Previous: Chandra PratapNext: Chandra Pratap
Message 38 of 41 in “t: port reftable/merged_test.c to the unit testing framework”
  1. Chandra PratapJul 3, 2024
  2. 1/5 t: move reftable/merged_test.c to the unit testing frameworkChandra Pratap, Jul 3, 2024
  3. Karthik NayakJul 5, 2024
  4. Chandra PratapJul 6, 2024
  5. 2/5 t: harmonize t-reftable-merged.c with coding guidelinesChandra Pratap, Jul 3, 2024
  6. Karthik NayakJul 5, 2024
  7. 3/5 t-reftable-merged: add tests for reftable_merged_table_max_update_indexChandra Pratap, Jul 3, 2024
  8. 4/5 t-reftable-merged: use reftable_ref_record_equal to compare ref recordsChandra Pratap, Jul 3, 2024
  9. Karthik NayakJul 5, 2024
  10. 5/5 t-reftable-merged: add test for REFTABLE_FORMAT_ERRORChandra Pratap, Jul 3, 2024
  11. Karthik NayakJul 5, 2024
  12. [GSoC][PATCH v2 0/7] t: port reftable/merged_test.c to the unit testing frameworkChandra Pratap, Jul 9, 2024
  13. 1/7 t: move reftable/merged_test.c to the unit testing frameworkChandra Pratap, Jul 9, 2024
  14. Justin ToblerJul 9, 2024
  15. 2/7 t: harmonize t-reftable-merged.c with coding guidelinesChandra Pratap, Jul 9, 2024
  16. 3/7 t-reftable-merged: improve the test t_merged_single_record()Chandra Pratap, Jul 9, 2024
  17. 4/7 t-reftable-merged: improve the const-correctness of helper functionsChandra Pratap, Jul 9, 2024
  18. 5/7 t-reftable-merged: add tests for reftable_merged_table_max_update_indexChandra Pratap, Jul 9, 2024
  19. 6/7 t-reftable-merged: use reftable_ref_record_equal to compare ref recordsChandra Pratap, Jul 9, 2024
  20. 7/7 t-reftable-merged: add test for REFTABLE_FORMAT_ERRORChandra Pratap, Jul 9, 2024
  21. Karthik NayakJul 10, 2024
  22. Karthik NayakJul 10, 2024
  23. Junio C HamanoJul 11, 2024
  24. [GSoC][PATCH v3 0/7] t: port reftable/merged_test.c to the unit testing frameworkChandra Pratap, Jul 11, 2024
  25. 1/7 t: move reftable/merged_test.c to the unit testing frameworkChandra Pratap, Jul 11, 2024
  26. 2/7 t: harmonize t-reftable-merged.c with coding guidelinesChandra Pratap, Jul 11, 2024
  27. Junio C HamanoJul 11, 2024
  28. 3/7 t-reftable-merged: improve the test t_merged_single_record()Chandra Pratap, Jul 11, 2024
  29. 4/7 t-reftable-merged: improve the const-correctness of helper functionsChandra Pratap, Jul 11, 2024
  30. 5/7 t-reftable-merged: add tests for reftable_merged_table_max_update_indexChandra Pratap, Jul 11, 2024
  31. 6/7 t-reftable-merged: use reftable_ref_record_equal to compare ref recordsChandra Pratap, Jul 11, 2024
  32. 7/7 t-reftable-merged: add test for REFTABLE_FORMAT_ERRORChandra Pratap, Jul 11, 2024
  33. [GSoC][PATCH v4 0/7] t: port reftable/merged_test.c to the unit testing frameworkChandra Pratap, Jul 12, 2024
  34. 1/7 t: move reftable/merged_test.c to the unit testing frameworkChandra Pratap, Jul 12, 2024
  35. 2/7 t: harmonize t-reftable-merged.c with coding guidelinesChandra Pratap, Jul 12, 2024
  36. 3/7 t-reftable-merged: improve the test t_merged_single_record()Chandra Pratap, Jul 12, 2024
  37. 4/7 t-reftable-merged: improve the const-correctness of helper functionsChandra Pratap, Jul 12, 2024
  38. Patrick SteinhardtJul 24, 2024
  39. 5/7 t-reftable-merged: add tests for reftable_merged_table_max_update_indexChandra Pratap, Jul 12, 2024
  40. 6/7 t-reftable-merged: use reftable_ref_record_equal to compare ref recordsChandra Pratap, Jul 12, 2024
  41. 7/7 t-reftable-merged: add test for REFTABLE_FORMAT_ERRORChandra Pratap, Jul 12, 2024

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.