On Thu, Jan 17, 2019 at 08:05:24PM +0700, Nguyễn Thái Ngọc Duy wrote:
> Signed-off-by: Nguyễn Thái Ngọc Duy <[email protected]>
> ---
> diff.c | 113 ++++++++++++++++++++++++++-------------------------------
> 1 file changed, 52 insertions(+), 61 deletions(-)
>
> diff --git a/diff.c b/diff.c
> index 4398b30f47..1b01b36507 100644
> --- a/diff.c
> +++ b/diff.c
> @@ -4660,77 +4660,56 @@ int parse_long_opt(const char *opt, const char **argv,
> return 2;
> }
>
> -static int stat_opt(struct diff_options *options, const char **av)
> +static int diff_opt_stat(const struct option *opt, const char *value, int
> unset)
> {
> - const char *arg = av[0];
> - char *end;
> + struct diff_options *options = opt->value;
> int width = options->stat_width;
> int name_width = options->stat_name_width;
> int graph_width = options->stat_graph_width;
> int count = options->stat_count;
> - int argcount = 1;
> + char *end;
>
> - if (!skip_prefix(arg, "--stat", &arg))
> - BUG("stat option does not begin with --stat: %s", arg);
> - end = (char *)arg;
> + BUG_ON_OPT_NEG(unset);
>
> - switch (*arg) {
> - case '-':
> - if (skip_prefix(arg, "-width", &arg)) {
> - if (*arg == '=')
> - width = strtoul(arg + 1, &end, 10);
> - else if (!*arg && !av[1])
> - die_want_option("--stat-width");
> - else if (!*arg) {
> - width = strtoul(av[1], &end, 10);
> - argcount = 2;
> - }
> - } else if (skip_prefix(arg, "-name-width", &arg)) {
> - if (*arg == '=')
> - name_width = strtoul(arg + 1, &end, 10);
> - else if (!*arg && !av[1])
> - die_want_option("--stat-name-width");
> - else if (!*arg) {
> - name_width = strtoul(av[1], &end, 10);
> - argcount = 2;
> - }
> - } else if (skip_prefix(arg, "-graph-width", &arg)) {
> - if (*arg == '=')
> - graph_width = strtoul(arg + 1, &end, 10);
> - else if (!*arg && !av[1])
> - die_want_option("--stat-graph-width");
> - else if (!*arg) {
> - graph_width = strtoul(av[1], &end, 10);
> - argcount = 2;
> - }
> - } else if (skip_prefix(arg, "-count", &arg)) {
> - if (*arg == '=')
> - count = strtoul(arg + 1, &end, 10);
> - else if (!*arg && !av[1])
> - die_want_option("--stat-count");
> - else if (!*arg) {
> - count = strtoul(av[1], &end, 10);
> - argcount = 2;
> - }
This hunk removes the last couple of callsites of the static
die_want_option() function, and building this commit fails with:
diff.c:107:22: error: ‘die_want_option’ defined but not used
[-Werror=unused-function]
static NORETURN void die_want_option(const char *option_name)
^~~~~~~~~~~~~~~
cc1: all warnings being treated as errors