From: Jani Nikula Date: Fri, 25 Sep 2015 18:47:35 +0000 (+0300) Subject: [PATCH] cli: use designated initializer to initialize add_files_state X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=73bd52850cd7d5b1a8bef169a01ad0d2821af920;p=notmuch-archives.git [PATCH] cli: use designated initializer to initialize add_files_state --- diff --git a/c7/b9b7b5872cf0bd265ebee3b75308cbea3b922c b/c7/b9b7b5872cf0bd265ebee3b75308cbea3b922c new file mode 100644 index 000000000..52e93d36d --- /dev/null +++ b/c7/b9b7b5872cf0bd265ebee3b75308cbea3b922c @@ -0,0 +1,111 @@ +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 B6F846DE0924 + for ; Fri, 25 Sep 2015 11:47:57 -0700 (PDT) +X-Virus-Scanned: Debian amavisd-new at cworth.org +X-Spam-Flag: NO +X-Spam-Score: -0.521 +X-Spam-Level: +X-Spam-Status: No, score=-0.521 tagged_above=-999 required=5 tests=[AWL=0.199, + RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01] + 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 YYRrfe4EnDiV for ; + Fri, 25 Sep 2015 11:47:56 -0700 (PDT) +Received: from mail-wi0-f178.google.com (mail-wi0-f178.google.com + [209.85.212.178]) + by arlo.cworth.org (Postfix) with ESMTPS id B117B6DE02D2 + for ; Fri, 25 Sep 2015 11:47:55 -0700 (PDT) +Received: by wiclk2 with SMTP id lk2so31076924wic.1 + for ; Fri, 25 Sep 2015 11:47:53 -0700 (PDT) +X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; + d=1e100.net; s=20130820; + h=x-gm-message-state:from:to:cc:subject:date:message-id; + bh=wJkOMnk94WYIFe6F7GiEPhSBNnbXJ+yIKeEWFvCerC8=; + b=UcQg76tx74zzxdzF/AJacwJhd+3DihXSK6Rfllp4OaebDIu+ZyAv8CN6GHnnPfcyhy + YhEaJgRuAX+m0rKpTNW9NlDahSOU5TTKL1P3/pv1wGw8BWVRu9o4HKBUERUxnabH0Hup + aVGHw0nopzwEw1ksqawzZjHwhT9yArMXz76HxGb4kYlIGiqhxxQ/0GqEZq4lubisLtS4 + nJTJG2ZBB7ALW//LD0HI84pFns+8j1gpB4VqZK3VHc4hd6xeaC8Hc3JlsZKZR8ODdiBp + bmD9tLl4gKR6hlBsDg6mQCVBSbwzA1/LbkJcnJOrAe/evZD7jY7QGqmJ+cCzaE8N2xsf + yOZA== +X-Gm-Message-State: + ALoCoQktkxjT0RVv499eFLQUDyrj9az6hGIy5bge58rHB7DiMOE9nOn4VqUuDZf1XyoB6v+FZiR4 +X-Received: by 10.180.230.197 with SMTP id ta5mr4896059wic.26.1443206873666; + Fri, 25 Sep 2015 11:47:53 -0700 (PDT) +Received: from localhost (mobile-access-bcee63-221.dhcp.inet.fi. + [188.238.99.221]) + by smtp.gmail.com with ESMTPSA id h7sm4659383wjz.7.2015.09.25.11.47.52 + (version=TLSv1/SSLv3 cipher=OTHER); + Fri, 25 Sep 2015 11:47:52 -0700 (PDT) +From: Jani Nikula +To: notmuch@notmuchmail.org +Subject: [PATCH] cli: use designated initializer to initialize add_files_state +Date: Fri, 25 Sep 2015 21:47:35 +0300 +Message-Id: <1443206855-21701-1-git-send-email-jani@nikula.org> +X-Mailer: git-send-email 2.1.4 +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 18:47:57 -0000 + +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. +--- + 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 +