From: Jani Nikula Date: Mon, 22 Sep 2014 09:54:53 +0000 (+0200) Subject: [PATCH 02/11] cli/insert: rename check_folder_name to is_valid_folder_name X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=466c7198c001995e04d4b9c659fe367e4be93b14;p=notmuch-archives.git [PATCH 02/11] cli/insert: rename check_folder_name to is_valid_folder_name --- diff --git a/f9/6570a876dc0d4ff1f36a9bd8b0aeb34281f555 b/f9/6570a876dc0d4ff1f36a9bd8b0aeb34281f555 new file mode 100644 index 000000000..68e7cfa46 --- /dev/null +++ b/f9/6570a876dc0d4ff1f36a9bd8b0aeb34281f555 @@ -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 olra.theworths.org (Postfix) with ESMTP id 2FCE3431FB6 + for ; Mon, 22 Sep 2014 02:54:59 -0700 (PDT) +X-Virus-Scanned: Debian amavisd-new at olra.theworths.org +X-Amavis-Alert: BAD HEADER SECTION, Duplicate header field: "References" +X-Spam-Flag: NO +X-Spam-Score: -0.7 +X-Spam-Level: +X-Spam-Status: No, score=-0.7 tagged_above=-999 required=5 + tests=[RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled +Received: from olra.theworths.org ([127.0.0.1]) + by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024) + with ESMTP id 92e17x6fqpmf for ; + Mon, 22 Sep 2014 02:54:54 -0700 (PDT) +Received: from mail-wi0-f181.google.com (mail-wi0-f181.google.com + [209.85.212.181]) (using TLSv1 with cipher RC4-SHA (128/128 bits)) + (No client certificate requested) + by olra.theworths.org (Postfix) with ESMTPS id 46F16431FC3 + for ; Mon, 22 Sep 2014 02:54:51 -0700 (PDT) +Received: by mail-wi0-f181.google.com with SMTP id z2so2607626wiv.8 + for ; Mon, 22 Sep 2014 02:54:50 -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:in-reply-to + :references:in-reply-to:references; + bh=BnALWtTzG3/QUxA4HNgdSMGE4TMNTwo6KMYLSHf6SPA=; + b=L2P9Q3sP2CFs9NWnhbEGYGlHfMKCp+87z3q/wOP5vo6Z11gRihk62qX26ZoNeO7QEP + 7VKybyMTAiukg6ZFr62NhO1x1zplwzPQH5ah2FO5jY0IdLERNv8qYc8n5XUCaYgl50cX + 9bxN60qSaFC/Xvr08fCJedNuFRQHKv0E+hOGfDaG49g59UXoG4r7vHGYvw6AH1ENtJ/G + 4zGJfdYEuHf6BZY5fXWCbbim2lJOYBXvP9yhvwGXugqmFR3F7XLrCH5AfsKjaqN783jV + yo7eR0fzIcrQKll0ZnWN8VCAtCncQv2kgxfd7zdVdswkp/lqxrfk/pYI1oFzGA3oO1lI + G6kA== +X-Gm-Message-State: + ALoCoQkz2tKQNPv4itfIvO5a9g8EhXpeNp449lNSzPo1sLIT5WJ+XCw1idlOZmoYSjdpZ4ONSPKA +X-Received: by 10.194.203.8 with SMTP id km8mr19296884wjc.51.1411379690249; + Mon, 22 Sep 2014 02:54:50 -0700 (PDT) +Received: from localhost ([2001:4b98:dc0:43:216:3eff:fe1b:25f3]) + by mx.google.com with ESMTPSA id mc4sm4390990wic.6.2014.09.22.02.54.49 + for + (version=TLSv1.1 cipher=RC4-SHA bits=128/128); + Mon, 22 Sep 2014 02:54:49 -0700 (PDT) +From: Jani Nikula +To: notmuch@notmuchmail.org +Subject: [PATCH 02/11] cli/insert: rename check_folder_name to + is_valid_folder_name +Date: Mon, 22 Sep 2014 11:54:53 +0200 +Message-Id: + +X-Mailer: git-send-email 1.7.2.5 +In-Reply-To: +References: +In-Reply-To: +References: +X-BeenThere: notmuch@notmuchmail.org +X-Mailman-Version: 2.1.13 +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: Mon, 22 Sep 2014 09:54:59 -0000 + +An "is something" predicate conveys the meaning better. While at it, +improve the function documentation and error message. Besides the +error message change, no functional changes. +--- + notmuch-insert.c | 13 ++++++++----- + 1 files changed, 8 insertions(+), 5 deletions(-) + +diff --git a/notmuch-insert.c b/notmuch-insert.c +index 8dfc8bb..770275b 100644 +--- a/notmuch-insert.c ++++ b/notmuch-insert.c +@@ -83,10 +83,13 @@ sync_dir (const char *dir) + return ret; + } + +-/* Check the specified folder name does not contain a directory +- * component ".." to prevent writes outside of the Maildir hierarchy. */ ++/* ++ * Check the specified folder name does not contain a directory ++ * component ".." to prevent writes outside of the Maildir ++ * hierarchy. Return TRUE on valid folder name, FALSE otherwise. ++ */ + static notmuch_bool_t +-check_folder_name (const char *folder) ++is_valid_folder_name (const char *folder) + { + const char *p = folder; + +@@ -449,8 +452,8 @@ notmuch_insert_command (notmuch_config_t *config, int argc, char *argv[]) + if (folder == NULL) { + maildir = db_path; + } else { +- if (! check_folder_name (folder)) { +- fprintf (stderr, "Error: bad folder name: %s\n", folder); ++ if (! is_valid_folder_name (folder)) { ++ fprintf (stderr, "Error: invalid folder name: '%s'\n", folder); + return EXIT_FAILURE; + } + maildir = talloc_asprintf (config, "%s/%s", db_path, folder); +-- +1.7.2.5 +