From c898bbc5e4b582c28379bc64b7f9c9ec96106993 Mon Sep 17 00:00:00 2001 From: René Scharfe Date: Wed, 9 Jul 2025 11:45:24 +0200 Subject: parse-options: add precision handling for OPTION_SET_INT MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Similar to 09705696f7 (parse-options: introduce precision handling for `OPTION_INTEGER`, 2025-04-17) support value variables of different sizes for OPTION_SET_INT. Do that by requiring their "precision" to be set, casting their "value" pointer accordingly and checking whether the value fits. Factor out the casting code from the part of do_get_value() that handles OPTION_INTEGER to avoid code duplication. We're going to use it in the next patches as well. Signed-off-by: René Scharfe Signed-off-by: Junio C Hamano --- t/helper/test-parse-options.c | 1 + 1 file changed, 1 insertion(+) (limited to 't/helper/test-parse-options.c') diff --git a/t/helper/test-parse-options.c b/t/helper/test-parse-options.c index 1e03ff88f6..2ba2546d70 100644 --- a/t/helper/test-parse-options.c +++ b/t/helper/test-parse-options.c @@ -131,6 +131,7 @@ int cmd__parse_options(int argc, const char **argv) .short_name = 'B', .long_name = "no-fear", .value = &boolean, + .precision = sizeof(boolean), .help = "be brave", .flags = PARSE_OPT_NOARG | PARSE_OPT_NONEG, .defval = 1, -- cgit v1.2.3