From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from localhost (localhost [127.0.0.1]) by arlo.cworth.org (Postfix) with ESMTP id 2E2F86DE20AB for ; Sun, 26 Feb 2017 11:12:49 -0800 (PST) X-Virus-Scanned: Debian amavisd-new at cworth.org X-Spam-Flag: NO X-Spam-Score: -0.171 X-Spam-Level: X-Spam-Status: No, score=-0.171 tagged_above=-999 required=5 tests=[AWL=-0.151, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, 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 qsFMoC0iPKVN for ; Sun, 26 Feb 2017 11:12:48 -0800 (PST) Received: from mail-lf0-f52.google.com (mail-lf0-f52.google.com [209.85.215.52]) by arlo.cworth.org (Postfix) with ESMTPS id 3D6966DE1F59 for ; Sun, 26 Feb 2017 11:12:48 -0800 (PST) Received: by mail-lf0-f52.google.com with SMTP id b80so25469071lfe.3 for ; Sun, 26 Feb 2017 11:12:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nikula-org.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=wmEqgWYawrfp1BigLvSnqyFcxO38CxswUE5yI0ih2Pk=; b=PTjlXfxQbqIcYRgjl6FKyCLHBIk/Ebu4p7B/VFdjeTUeYU+2FoT0GuY1aF2b33yM/J VCNrry1FrMn6HzBAWbgW3MdrNiK1g8OuE3pUC+WwjhswZFL8MzKn3e+0Y7kCrZtj7H+R GaC/OCAlSVp2NS7lxdG9USoEwTWjnu4T/I/1lJhiq5g7by0PzXV+gRUlg+ebaU5D8I7T C7p4p1D7zjmUUJOR15hm07rg5s+6Rg4Tva6nQ7nibHTzMFhtAOKtyB5e1ZTRLKOHFO5E AYUvongRVH92W7chUonc/dmIxRDbI4rOtNkdmUexa/TRYN1uLXW7lPRr/J4X0iwIq1KL /1pg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=wmEqgWYawrfp1BigLvSnqyFcxO38CxswUE5yI0ih2Pk=; b=lMu5huEHj0QaWPhH0ebHq0f4K/Kxa17dbzz78fEqGHf0Cqw6kbZcSdplsBDUT1gMGj HcZ/sDiyJ8XoU7BmaYthjRHdLmRlsDE7n+70hTkWkcRHvoITZ07zfjPhVEtPj0VXe8q8 aKgFYR+aR2ulxVruWa3vWM/W9OUy2MQBsDprBcmM9FKZeShWvo2F04ITaJD063wPdo6K 2TGdB2MNULQ6e12eUoIehco0umQbS2h5qKJ/hEoxuOne+QNmA3sdJegdJFYI7+99QuiQ 6e2D52xybL3tXpr7J/vWh41CmMXaNlqd+jp+PHd6HbKl4ozzycMWkh4X0muSBfja+MN4 c+3Q== X-Gm-Message-State: AMke39nQCmxeyeEQ5e03ZWnN87Pc755boV2BfhOOk480TY238QcCH2piMQPw2Hum4kLHYA== X-Received: by 10.46.77.70 with SMTP id a67mr2179778ljb.25.1488136366633; Sun, 26 Feb 2017 11:12:46 -0800 (PST) Received: from localhost (mobile-access-bcee80-14.dhcp.inet.fi. [188.238.128.14]) by smtp.gmail.com with ESMTPSA id g16sm241197lji.62.2017.02.26.11.12.45 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sun, 26 Feb 2017 11:12:46 -0800 (PST) From: Jani Nikula To: notmuch@notmuchmail.org Cc: Tomi Ollila , jani@nikula.org Subject: [PATCH 2/2] notmuch-config: ENOENT vs generic handling when file open fails. Date: Sun, 26 Feb 2017 21:12:39 +0200 Message-Id: <20170226191239.30887-2-jani@nikula.org> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170226191239.30887-1-jani@nikula.org> References: <20170226191239.30887-1-jani@nikula.org> X-BeenThere: notmuch@notmuchmail.org X-Mailman-Version: 2.1.22 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: Sun, 26 Feb 2017 19:12:49 -0000 From: Tomi Ollila When opening configuration file fails, ENOENT (file not found) is handled specially -- in setup missing file is ok (often expected), and otherwise user can be informed to run notmuch setup. In any other case the the reason is unknown, so there is no other option but to print generic error message to stderr. --- notmuch-config.c | 29 ++++++++++++++--------------- 1 file changed, 14 insertions(+), 15 deletions(-) diff --git a/notmuch-config.c b/notmuch-config.c index 959410cce7b8..e4aaef610173 100644 --- a/notmuch-config.c +++ b/notmuch-config.c @@ -215,24 +215,23 @@ get_config_from_file (notmuch_config_t *config, notmuch_bool_t create_new) FILE *fp = fopen(config->filename, "r"); if (fp == NULL) { - /* If create_new is true, then the caller is prepared for a - * default configuration file in the case of FILE NOT FOUND. - */ - if (create_new) { - config->is_new = TRUE; - ret = TRUE; - goto out; - } else if (errno == ENOENT) { - fprintf (stderr, "Configuration file %s not found.\n" - "Try running 'notmuch setup' to create a configuration.\n", - config->filename); - goto out; + if (errno == ENOENT) { + /* If create_new is true, then the caller is prepared for a + * default configuration file in the case of FILE NOT FOUND. + */ + if (create_new) { + config->is_new = TRUE; + ret = TRUE; + } else { + fprintf (stderr, "Configuration file %s not found.\n" + "Try running 'notmuch setup' to create a configuration.\n", + config->filename); + } } else { - fprintf (stderr, "Error opening config file '%s': %s\n" - "Try running 'notmuch setup' to create a configuration.\n", + fprintf (stderr, "Error opening config file '%s': %s\n", config->filename, strerror(errno)); - goto out; } + goto out; } config_str = talloc_zero_array (config, char, config_bufsize); -- 2.11.0