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

[PATCH v2 08/10] parse-options: add more BUG_ON() annotations

From
Jeff King <peff@peff.net>
Date
Aug 31, 2023, 21:21 UTC
Message-ID
<20230831212149.GH949469@coredump.intra.peff.net>
In-Reply-To
<20230831211637.GA949188@coredump.intra.peff.net>

These callbacks are similar to the ones touched by 517fe807d6 (assert NOARG/NONEG behavior of parse-options callbacks, 2018-11-05), but were either missed in that commit (the one in add.c) or were added later (the one in log.c).

Signed-off-by: Jeff King <peff@peff.net>
---
 builtin/add.c | 2 ++
 builtin/log.c | 2 ++
 2 files changed, 4 insertions(+)
diff --git a/builtin/add.c b/builtin/add.c
index 4b0dd798df..cf59108523 100644
--- a/builtin/add.c
+++ b/builtin/add.c
@@ -232,6 +232,8 @@ static char *chmod_arg;
 
 static int ignore_removal_cb(const struct option *opt, const char *arg, int unset)
 {
+	BUG_ON_OPT_ARG(arg);
+
 	/* if we are told to ignore, we are not adding removals */
 	*(int *)opt->value = !unset ? 0 : 1;
 	return 0;
diff --git a/builtin/log.c b/builtin/log.c
index 3599063554..190e1952e9 100644
--- a/builtin/log.c
+++ b/builtin/log.c
@@ -121,6 +121,8 @@ static struct string_list decorate_refs_include = STRING_LIST_INIT_NODUP;
 static int clear_decorations_callback(const struct option *opt UNUSED,
 				      const char *arg, int unset)
 {
+	BUG_ON_OPT_NEG(unset);
+	BUG_ON_OPT_ARG(arg);
 	string_list_clear(&decorate_refs_include, 0);
 	string_list_clear(&decorate_refs_exclude, 0);
 	use_default_decoration_filter = 0;
-- 
2.42.0.561.gaa987ecc69
Previous: Jeff KingNext: Jeff King
Message 42 of 47 in “more unused parameters in parseopt callbacks”
  1. 0/8 more unused parameters in parseopt callbacksJeff King, Aug 31, 2023
  2. 1/8 merge: make xopts a strvecJeff King, Aug 31, 2023
  3. Jeff KingAug 31, 2023
  4. Phillip WoodAug 31, 2023
  5. Junio C HamanoAug 31, 2023
  6. Taylor BlauAug 31, 2023
  7. 2/8 merge: simplify parsing of "-n" optionJeff King, Aug 31, 2023
  8. Junio C HamanoAug 31, 2023
  9. 3/8 parse-options: prefer opt->value to globals in callbacksJeff King, Aug 31, 2023
  10. Junio C HamanoAug 31, 2023
  11. 4/8 parse-options: mark unused "opt" parameter in callbacksJeff King, Aug 31, 2023
  12. Junio C HamanoAug 31, 2023
  13. Jeff KingAug 31, 2023
  14. Jeff KingAug 31, 2023
  15. 5/8 merge: do not pass unused opt->value parameterJeff King, Aug 31, 2023
  16. Junio C HamanoAug 31, 2023
  17. 6/8 parse-options: add more BUG_ON() annotationsJeff King, Aug 31, 2023
  18. Junio C HamanoAug 31, 2023
  19. 7/8 interpret-trailers: mark unused "unset" parameters in option callbacksJeff King, Aug 31, 2023
  20. Junio C HamanoAug 31, 2023
  21. Jeff KingAug 31, 2023
  22. 8/8 parse-options: mark unused parameters in noop callbackJeff King, Aug 31, 2023
  23. Junio C HamanoAug 31, 2023
  24. 0/10 more unused parameters in parseopt callbacksJeff King, Aug 31, 2023
  25. 01/10 merge: make xopts a strvecJeff King, Aug 31, 2023
  26. 02/10 merge: simplify parsing of "-n" optionJeff King, Aug 31, 2023
  27. René ScharfeSep 2, 2023
  28. Jeff KingSep 5, 2023
  29. 03/10 format-patch: use OPT_STRING_LIST for to/cc optionsJeff King, Aug 31, 2023
  30. 04/10 checkout-index: delay automatic setting of to_tempfileJeff King, Aug 31, 2023
  31. Junio C HamanoAug 31, 2023
  32. René ScharfeSep 2, 2023
  33. 04/10 checkout-index: delay automatic setting of to_tempfileJeff King, Sep 5, 2023
  34. 05/10 parse-options: prefer opt->value to globals in callbacksJeff King, Aug 31, 2023
  35. René ScharfeSep 2, 2023
  36. Jeff KingSep 5, 2023
  37. 06/10 parse-options: mark unused "opt" parameter in callbacksJeff King, Aug 31, 2023
  38. René ScharfeSep 2, 2023
  39. Jeff KingSep 5, 2023
  40. René ScharfeSep 19, 2023
  41. 07/10 merge: do not pass unused opt->value parameterJeff King, Aug 31, 2023
  42. 08/10 parse-options: add more BUG_ON() annotationsJeff King, Aug 31, 2023
  43. 09/10 interpret-trailers: mark unused "unset" parameters in option callbacksJeff King, Aug 31, 2023
  44. 10/10 parse-options: mark unused parameters in noop callbackJeff King, Aug 31, 2023
  45. René ScharfeSep 2, 2023
  46. Jeff KingSep 5, 2023
  47. René ScharfeSep 7, 2023

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.