Skip to content

Commit d4f7036

Browse files
rscharfegitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 0d5448a commit d4f7036

File tree

2 files changed

+2
-20
lines changed

2 files changed

+2
-20
lines changed

list-objects-filter-options.c

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -290,10 +290,6 @@ int opt_parse_list_objects_filter(const struct option *opt,
290290
const char *arg, int unset)
291291
{
292292
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);
297293

298294
if (unset || !arg)
299295
list_objects_filter_set_no_filter(filter_options);

list-objects-filter-options.h

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -111,27 +111,13 @@ void parse_list_objects_filter(
111111
* The opt->value to opt_parse_list_objects_filter() is either a
112112
* "struct list_objects_filter_option *" when using
113113
* 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.
124114
*/
125115
int opt_parse_list_objects_filter(const struct option *opt,
126116
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) }
132117

133118
#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)
135121

136122
/*
137123
* Translates abbreviated numbers in the filter's filter_spec into their

0 commit comments

Comments
 (0)