Skip to content

Commit 9ff8ff3

Browse files
committed
parse-options: add cast to correct pointer type to OPT_SET_PTR
Do not force users of OPT_SET_PTR to cast pointer to correct underlying pointer type by integrating cast into OPT_SET_PTR macro. Cast is required to prevent 'initialization makes integer from pointer without a cast' compiler warning. Signed-off-by: Junio C Hamano <[email protected]>
1 parent e25c070 commit 9ff8ff3

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

parse-options.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ struct option {
129129
#define OPT_HIDDEN_BOOL(s, l, v, h) { OPTION_SET_INT, (s), (l), (v), NULL, \
130130
(h), PARSE_OPT_NOARG | PARSE_OPT_HIDDEN, NULL, 1}
131131
#define OPT_SET_PTR(s, l, v, h, p) { OPTION_SET_PTR, (s), (l), (v), NULL, \
132-
(h), PARSE_OPT_NOARG, NULL, (p) }
132+
(h), PARSE_OPT_NOARG, NULL, (intptr_t)(p) }
133133
#define OPT_CMDMODE(s, l, v, h, i) { OPTION_CMDMODE, (s), (l), (v), NULL, \
134134
(h), PARSE_OPT_NOARG|PARSE_OPT_NONEG, NULL, (i) }
135135
#define OPT_INTEGER(s, l, v, h) { OPTION_INTEGER, (s), (l), (v), N_("n"), (h) }

test-parse-options.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ int main(int argc, char **argv)
6060
OPT_STRING('o', NULL, &string, "str", "get another string"),
6161
OPT_NOOP_NOARG(0, "obsolete"),
6262
OPT_SET_PTR(0, "default-string", &string,
63-
"set string to default", (intptr_t)"default"),
63+
"set string to default", "default"),
6464
OPT_STRING_LIST(0, "list", &list, "str", "add str to list"),
6565
OPT_GROUP("Magic arguments"),
6666
OPT_ARGUMENT("quux", "means --quux"),

0 commit comments

Comments
 (0)