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

Re: [PATCH 11/15] t-hashmap: mark unused parameters in callback function

From
Jeff King <peff@peff.net>
Date
Aug 17, 2024, 17:18 UTC
Message-ID
<20240817171835.GA2869474@coredump.intra.peff.net>
In-Reply-To
<D3I9DJRMAQD4.UIBX5HG0XYL2@gmail.com>
On Sat, Aug 17, 2024 at 08:02:36PM +0530, Ghanshyam Thakkar wrote:
Show 11 quoted lines
> Jeff King <peff@peff.net> wrote:
> > The t_intern() setup function doesn't operate on a hashmap, so it
> > ignores its parameters. But we can't drop them since it is passed as a
> > pointer to setup(), so we have to match the other setup functions. Mark
> > them to silence -Wunused-parameter.
> 
> Sorry, but I didn't understand why we can't drop them and just call
> t_intern() instead of setup(t_intern) (I should've done that, when
> writing this). By 'other setup functions', do you mean other test
> functions which use setup()? I don't think it is necessary to have
> uniformity in function signatures of all the test functions.

I just assumed that setup() was something that should be called for each test. But yeah, looking at it, it is really only creating and cleaning up the hashmap. Since t_intern() doesn't need any of that, then it should be OK to just skip setup() entirely.

Show 13 quoted lines
> -static void t_intern(struct hashmap *map, unsigned int ignore_case)
> +static void t_intern(void)
>  {
>  	const char *values[] = { "value1", "Value1", "value2", "value2" };
>  
> @@ -356,6 +356,6 @@ int cmd_main(int argc UNUSED, const char **argv UNUSED)
>  	TEST(setup(t_iterate, 0), "iterate works");
>  	TEST(setup(t_iterate, 1), "iterate (case insensitive) works");
>  	TEST(setup(t_alloc, 0), "grow / shrink works");
> -	TEST(setup(t_intern, 0), "string interning works");
> +	TEST(t_intern(), "string interning works");
>  	return test_done();
>  }
Yeah, that makes sense. I'll update the patch accordingly. Thanks.
-Peff
Previous: Ghanshyam ThakkarNext: Jeff King
Message 14 of 18 in “marking some more unused parameters”
  1. 0/15 marking some more unused parametersJeff King, Aug 17, 2024
  2. 01/15 imap-send: mark unused parameter in ssl_socket_connect() fallbackJeff King, Aug 17, 2024
  3. 02/15 update-ref: mark more unused parameters in parser callbacksJeff King, Aug 17, 2024
  4. 03/15 refs: mark unused parameters in ref_store fsck callbacksJeff King, Aug 17, 2024
  5. 04/15 refs: mark unused parameters in do_for_each_reflog_helper()Jeff King, Aug 17, 2024
  6. 05/15 oss-fuzz: mark unused argv/argc argumentJeff King, Aug 17, 2024
  7. 06/15 t/helper: mark more unused argv/argc argumentsJeff King, Aug 17, 2024
  8. 07/15 unit-tests: ignore unused argc/argvJeff King, Aug 17, 2024
  9. 08/15 reftable: ignore unused argc/argv in test functionsJeff King, Aug 17, 2024
  10. 09/15 reftable: drop obsolete test function declarationsJeff King, Aug 17, 2024
  11. 10/15 reftable: mark unused parameters in virtual functionsJeff King, Aug 17, 2024
  12. 11/15 t-hashmap: mark unused parameters in callback functionJeff King, Aug 17, 2024
  13. Ghanshyam ThakkarAug 17, 2024
  14. Jeff KingAug 17, 2024
  15. 12/15 test-mergesort: mark unused parameters in trivial callbackJeff King, Aug 17, 2024
  16. 13/15 setup: mark unused parameter in config callbackJeff King, Aug 17, 2024
  17. 14/15 daemon: mark unused parameters in non-posix fallbacksJeff King, Aug 17, 2024
  18. 15/15 scalar: mark unused parameters in dummy functionJeff King, Aug 17, 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.