list-objects-filter: remove OPT_PARSE_LIST_OBJECTS_FILTER_INIT()
OPT_PARSE_LIST_OBJECTS_FILTER_INIT() with a non-NULL second argument passes a function pointer via an object pointer, which is undefined. It may work fine on platforms that implement C99 extension J.5.7 (Function pointer casts). Remove the unused macro and avoid the dependency on that extension. Signed-off-by: René Scharfe <l.s.r@web.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
René Scharfe committed
Nov 29, 2022 at 13:26 UTC
d4f7036887f54184d666a1096ee96dfb2e9ad881
2 files changed
+2
-20
list-objects-filter-options.c
-4
@@ -290,10 +290,6 @@ int opt_parse_list_objects_filter(const struct option *opt,
290
const char *arg, int unset)
291
{
292
struct list_objects_filter_options *filter_options = opt->value;
293
- opt_lof_init init = (opt_lof_init)opt->defval;
294
-
295
- if (init)
296
- filter_options = init(opt->value);
293
294
if (unset || !arg)
295
list_objects_filter_set_no_filter(filter_options);
list-objects-filter-options.h
+2
-16
@@ -111,27 +111,13 @@ void parse_list_objects_filter(
111
* The opt->value to opt_parse_list_objects_filter() is either a
112
* "struct list_objects_filter_option *" when using
113
* OPT_PARSE_LIST_OBJECTS_FILTER().
114
- *
115
- * Or, if using no "struct option" field is used by the callback,
116
- * except the "defval" which is expected to be an "opt_lof_init"
117
- * function, which is called with the "opt->value" and must return a
118
- * pointer to the ""struct list_objects_filter_option *" to be used.
119
- *
120
- * The OPT_PARSE_LIST_OBJECTS_FILTER_INIT() can be used e.g. the
121
- * "struct list_objects_filter_option" is embedded in a "struct
122
- * rev_info", which the "defval" could be tasked with lazily
123
- * initializing. See cmd_pack_objects() for an example.
114
*/
115
int opt_parse_list_objects_filter(const struct option *opt,
116
const char *arg, int unset);
127
-typedef struct list_objects_filter_options *(*opt_lof_init)(void *);
128
-#define OPT_PARSE_LIST_OBJECTS_FILTER_INIT(fo, init) \
129
- { OPTION_CALLBACK, 0, "filter", (fo), N_("args"), \
130
- N_("object filtering"), 0, opt_parse_list_objects_filter, \
131
- (intptr_t)(init) }
117
118
#define OPT_PARSE_LIST_OBJECTS_FILTER(fo) \
134
- OPT_PARSE_LIST_OBJECTS_FILTER_INIT((fo), NULL)
119
+ OPT_CALLBACK(0, "filter", (fo), N_("args"), \
120
+ N_("object filtering"), opt_parse_list_objects_filter)
121
122
/*
123
* Translates abbreviated numbers in the filter's filter_spec into their