From 7183161c8d1f45a4570838c8948bc1ed4fccf3e2 Mon Sep 17 00:00:00 2001 From: Tomi Ollila Date: Fri, 25 Sep 2015 22:19:38 +0300 Subject: [PATCH] Re: [PATCH] cli: use designated initializer to initialize add_files_state --- 80/1ec8ed6c099cf165a78691adbcf600bb47cbf7 | 112 ++++++++++++++++++++++ 1 file changed, 112 insertions(+) create mode 100644 80/1ec8ed6c099cf165a78691adbcf600bb47cbf7 diff --git a/80/1ec8ed6c099cf165a78691adbcf600bb47cbf7 b/80/1ec8ed6c099cf165a78691adbcf600bb47cbf7 new file mode 100644 index 000000000..ed8c8ab18 --- /dev/null +++ b/80/1ec8ed6c099cf165a78691adbcf600bb47cbf7 @@ -0,0 +1,112 @@ +Return-Path: +X-Original-To: notmuch@notmuchmail.org +Delivered-To: notmuch@notmuchmail.org +Received: from localhost (localhost [127.0.0.1]) + by arlo.cworth.org (Postfix) with ESMTP id E8A466DE0B64 + for ; Fri, 25 Sep 2015 12:19:35 -0700 (PDT) +X-Virus-Scanned: Debian amavisd-new at cworth.org +X-Spam-Flag: NO +X-Spam-Score: 0.785 +X-Spam-Level: +X-Spam-Status: No, score=0.785 tagged_above=-999 required=5 tests=[AWL=0.133, + SPF_NEUTRAL=0.652] autolearn=disabled +Received: from arlo.cworth.org ([127.0.0.1]) + by localhost (arlo.cworth.org [127.0.0.1]) (amavisd-new, port 10024) + with ESMTP id zBu9vWhDHxfN for ; + Fri, 25 Sep 2015 12:19:33 -0700 (PDT) +Received: from guru.guru-group.fi (guru.guru-group.fi [46.183.73.34]) + by arlo.cworth.org (Postfix) with ESMTP id 7EF246DE02D2 + for ; Fri, 25 Sep 2015 12:19:33 -0700 (PDT) +Received: from guru.guru-group.fi (localhost [IPv6:::1]) + by guru.guru-group.fi (Postfix) with ESMTP id B0FB010008D; + Fri, 25 Sep 2015 22:19:38 +0300 (EEST) +From: Tomi Ollila +To: Jani Nikula , notmuch@notmuchmail.org +Subject: Re: [PATCH] cli: use designated initializer to initialize + add_files_state +In-Reply-To: <1443206855-21701-1-git-send-email-jani@nikula.org> +References: <1443206855-21701-1-git-send-email-jani@nikula.org> +User-Agent: Notmuch/0.20.2+68~g0c35549 (http://notmuchmail.org) Emacs/24.3.1 + (x86_64-unknown-linux-gnu) +X-Face: HhBM'cA~ +MIME-Version: 1.0 +Content-Type: text/plain +X-BeenThere: notmuch@notmuchmail.org +X-Mailman-Version: 2.1.18 +Precedence: list +List-Id: "Use and development of the notmuch mail system." + +List-Unsubscribe: , + +List-Archive: +List-Post: +List-Help: +List-Subscribe: , + +X-List-Received-Date: Fri, 25 Sep 2015 19:19:36 -0000 + +On Fri, Sep 25 2015, Jani Nikula wrote: + +> The side effect is that all of add_files_state will be initialized to +> zero, removing any lingering doubt that some of it might not be +> initialized. It's not a small struct, and the initialization is +> scattered around a bit, so this makes the code more readable. + +LGTM. Should I test ? ;/ + +Tomi + + +> --- +> notmuch-new.c | 13 +++++-------- +> 1 file changed, 5 insertions(+), 8 deletions(-) +> +> diff --git a/notmuch-new.c b/notmuch-new.c +> index 33645349cd5f..442a2f0ae288 100644 +> --- a/notmuch-new.c +> +++ b/notmuch-new.c +> @@ -933,7 +933,11 @@ int +> notmuch_new_command (notmuch_config_t *config, int argc, char *argv[]) +> { +> notmuch_database_t *notmuch; +> - add_files_state_t add_files_state; +> + add_files_state_t add_files_state = { +> + .verbosity = VERBOSITY_NORMAL, +> + .debug = FALSE, +> + .output_is_a_tty = isatty (fileno (stdout)), +> + }; +> struct timeval tv_start; +> int ret = 0; +> struct stat st; +> @@ -948,10 +952,6 @@ notmuch_new_command (notmuch_config_t *config, int argc, char *argv[]) +> notmuch_bool_t quiet = FALSE, verbose = FALSE; +> notmuch_status_t status; +> +> - add_files_state.verbosity = VERBOSITY_NORMAL; +> - add_files_state.debug = FALSE; +> - add_files_state.output_is_a_tty = isatty (fileno (stdout)); +> - +> notmuch_opt_desc_t options[] = { +> { NOTMUCH_OPT_BOOLEAN, &quiet, "quiet", 'q', 0 }, +> { NOTMUCH_OPT_BOOLEAN, &verbose, "verbose", 'v', 0 }, +> @@ -1086,9 +1086,6 @@ notmuch_new_command (notmuch_config_t *config, int argc, char *argv[]) +> talloc_free (dot_notmuch_path); +> dot_notmuch_path = NULL; +> +> - add_files_state.processed_files = 0; +> - add_files_state.added_messages = 0; +> - add_files_state.removed_messages = add_files_state.renamed_messages = 0; +> gettimeofday (&add_files_state.tv_start, NULL); +> +> add_files_state.removed_files = _filename_list_create (config); +> -- +> 2.1.4 +> +> _______________________________________________ +> notmuch mailing list +> notmuch@notmuchmail.org +> http://notmuchmail.org/mailman/listinfo/notmuch -- 2.26.2