diff options
| author | Junio C Hamano <gitster@pobox.com> | 2025-04-24 17:25:33 -0700 |
|---|---|---|
| committer | Junio C Hamano <gitster@pobox.com> | 2025-04-24 17:25:34 -0700 |
| commit | 2bc5414c411aab33c155b1070b7764ef6a49a02d (patch) | |
| tree | 3f2b065f7c9c54838ab380ba5d16e7a9f742344b /builtin/config.c | |
| parent | Merge branch 'ds/doc-disable-hooks' (diff) | |
| parent | parse-options: detect mismatches in integer signedness (diff) | |
| download | git-2bc5414c411aab33c155b1070b7764ef6a49a02d.tar.gz git-2bc5414c411aab33c155b1070b7764ef6a49a02d.zip | |
Merge branch 'ps/parse-options-integers'
Update parse-options API to catch mistakes to pass address of an
integral variable of a wrong type/size.
* ps/parse-options-integers:
parse-options: detect mismatches in integer signedness
parse-options: introduce precision handling for `OPTION_UNSIGNED`
parse-options: introduce precision handling for `OPTION_INTEGER`
parse-options: rename `OPT_MAGNITUDE()` to `OPT_UNSIGNED()`
parse-options: support unit factors in `OPT_INTEGER()`
global: use designated initializers for options
parse: fix off-by-one for minimum signed values
Diffstat (limited to 'builtin/config.c')
| -rw-r--r-- | builtin/config.c | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/builtin/config.c b/builtin/config.c index 53a90094e3..f70d635477 100644 --- a/builtin/config.c +++ b/builtin/config.c @@ -131,9 +131,16 @@ struct config_display_options { #define TYPE_COLOR 6 #define TYPE_BOOL_OR_STR 7 -#define OPT_CALLBACK_VALUE(s, l, v, h, i) \ - { OPTION_CALLBACK, (s), (l), (v), NULL, (h), PARSE_OPT_NOARG | \ - PARSE_OPT_NONEG, option_parse_type, (i) } +#define OPT_CALLBACK_VALUE(s, l, v, h, i) { \ + .type = OPTION_CALLBACK, \ + .short_name = (s), \ + .long_name = (l), \ + .value = (v), \ + .help = (h), \ + .flags = PARSE_OPT_NOARG | PARSE_OPT_NONEG, \ + .callback = option_parse_type, \ + .defval = (i), \ +} static int option_parse_type(const struct option *opt, const char *arg, int unset) |
