diff mbox series

[6/8] parse-options: add more BUG_ON() annotations

Message ID 20230831071900.GD3197751@coredump.intra.peff.net (mailing list archive)
State Superseded
Headers show
Series more unused parameters in parseopt callbacks | expand

Commit Message

Jeff King Aug. 31, 2023, 7:19 a.m. UTC
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(+)

Comments

Junio C Hamano Aug. 31, 2023, 4:58 p.m. UTC | #1
Jeff King <peff@peff.net> writes:

> 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).

They obviously look good.  Thanks.


>
> 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 87e29c4171..80fa642858 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;
diff mbox series

Patch

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 87e29c4171..80fa642858 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;