From patchwork Mon Nov 5 06:44:27 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff King X-Patchwork-Id: 10667439 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id EFEEF1709 for ; Mon, 5 Nov 2018 06:44:31 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DD701287FD for ; Mon, 5 Nov 2018 06:44:31 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D145129511; Mon, 5 Nov 2018 06:44:31 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 57733287FD for ; Mon, 5 Nov 2018 06:44:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729387AbeKEQCh (ORCPT ); Mon, 5 Nov 2018 11:02:37 -0500 Received: from cloud.peff.net ([104.130.231.41]:40420 "HELO cloud.peff.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with SMTP id S1728955AbeKEQCh (ORCPT ); Mon, 5 Nov 2018 11:02:37 -0500 Received: (qmail 21973 invoked by uid 109); 5 Nov 2018 06:44:29 -0000 Received: from Unknown (HELO peff.net) (10.0.1.2) by cloud.peff.net (qpsmtpd/0.94) with SMTP; Mon, 05 Nov 2018 06:44:29 +0000 Authentication-Results: cloud.peff.net; auth=none Received: (qmail 17260 invoked by uid 111); 5 Nov 2018 06:43:47 -0000 Received: from sigill.intra.peff.net (HELO sigill.intra.peff.net) (10.0.0.7) by peff.net (qpsmtpd/0.94) with (ECDHE-RSA-AES256-GCM-SHA384 encrypted) SMTP; Mon, 05 Nov 2018 01:43:47 -0500 Authentication-Results: peff.net; auth=none Received: by sigill.intra.peff.net (sSMTP sendmail emulation); Mon, 05 Nov 2018 01:44:27 -0500 Date: Mon, 5 Nov 2018 01:44:27 -0500 From: Jeff King To: git@vger.kernel.org Subject: [PATCH 12/13] parse-options: drop OPT_DATE() Message-ID: <20181105064427.GL25864@sigill.intra.peff.net> References: <20181105063718.GA24877@sigill.intra.peff.net> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20181105063718.GA24877@sigill.intra.peff.net> Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP There are no users of OPT_DATE except for test-parse-options; its only caller went away in 27ec394a97 (prune: introduce OPT_EXPIRY_DATE() and use it, 2013-04-25). It also has a bug: it does not specify PARSE_OPT_NONEG, but its callback does not respect the "unset" flag, and will feed NULL to approxidate() and segfault. Probably this should be marked with NONEG, or the callback should set the timestamp to some sentinel value (e.g,. "0", or "(time_t)-1"). But since there are no callers, deleting it means we don't even have to think about what the right behavior should be. Signed-off-by: Jeff King --- parse-options-cb.c | 7 ------- parse-options.h | 4 ---- t/helper/test-parse-options.c | 1 - t/t0040-parse-options.sh | 22 ---------------------- 4 files changed, 34 deletions(-) diff --git a/parse-options-cb.c b/parse-options-cb.c index e8236534ac..6a61166b26 100644 --- a/parse-options-cb.c +++ b/parse-options-cb.c @@ -28,13 +28,6 @@ int parse_opt_abbrev_cb(const struct option *opt, const char *arg, int unset) return 0; } -int parse_opt_approxidate_cb(const struct option *opt, const char *arg, - int unset) -{ - *(timestamp_t *)(opt->value) = approxidate(arg); - return 0; -} - int parse_opt_expiry_date_cb(const struct option *opt, const char *arg, int unset) { diff --git a/parse-options.h b/parse-options.h index dd14911a29..c3f2d2eceb 100644 --- a/parse-options.h +++ b/parse-options.h @@ -150,9 +150,6 @@ struct option { (h), 0, &parse_opt_string_list } #define OPT_UYN(s, l, v, h) { OPTION_CALLBACK, (s), (l), (v), NULL, \ (h), PARSE_OPT_NOARG, &parse_opt_tertiary } -#define OPT_DATE(s, l, v, h) \ - { OPTION_CALLBACK, (s), (l), (v), N_("time"),(h), 0, \ - parse_opt_approxidate_cb } #define OPT_EXPIRY_DATE(s, l, v, h) \ { OPTION_CALLBACK, (s), (l), (v), N_("expiry-date"),(h), 0, \ parse_opt_expiry_date_cb } @@ -232,7 +229,6 @@ extern struct option *parse_options_concat(struct option *a, struct option *b); /*----- some often used options -----*/ extern int parse_opt_abbrev_cb(const struct option *, const char *, int); -extern int parse_opt_approxidate_cb(const struct option *, const char *, int); extern int parse_opt_expiry_date_cb(const struct option *, const char *, int); extern int parse_opt_color_flag_cb(const struct option *, const char *, int); extern int parse_opt_verbosity_cb(const struct option *, const char *, int); diff --git a/t/helper/test-parse-options.c b/t/helper/test-parse-options.c index 9cb8a0ea0f..f0623bb42b 100644 --- a/t/helper/test-parse-options.c +++ b/t/helper/test-parse-options.c @@ -119,7 +119,6 @@ int cmd__parse_options(int argc, const char **argv) OPT_INTEGER('j', NULL, &integer, "get a integer, too"), OPT_MAGNITUDE('m', "magnitude", &magnitude, "get a magnitude"), OPT_SET_INT(0, "set23", &integer, "set integer to 23", 23), - OPT_DATE('t', NULL, ×tamp, "get timestamp of