From 438c4085a40cd9610534ac3758356dce4d258cab Mon Sep 17 00:00:00 2001 From: Jani Nikula Date: Mon, 22 Sep 2014 11:54:55 +0200 Subject: [PATCH] [PATCH 04/11] cli/insert: rename file copy function --- 4f/b5e4d7cc1d559f57db5f7d48fd0068805f309c | 109 ++++++++++++++++++++++ 1 file changed, 109 insertions(+) create mode 100644 4f/b5e4d7cc1d559f57db5f7d48fd0068805f309c diff --git a/4f/b5e4d7cc1d559f57db5f7d48fd0068805f309c b/4f/b5e4d7cc1d559f57db5f7d48fd0068805f309c new file mode 100644 index 000000000..69e6fa662 --- /dev/null +++ b/4f/b5e4d7cc1d559f57db5f7d48fd0068805f309c @@ -0,0 +1,109 @@ +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 E856B431FC0 + for ; Mon, 22 Sep 2014 02:55:06 -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 f8KYWg97Tttb for ; + Mon, 22 Sep 2014 02:55:02 -0700 (PDT) +Received: from mail-we0-f180.google.com (mail-we0-f180.google.com + [74.125.82.180]) (using TLSv1 with cipher RC4-SHA (128/128 bits)) + (No client certificate requested) + by olra.theworths.org (Postfix) with ESMTPS id 05017431FD0 + for ; Mon, 22 Sep 2014 02:54:53 -0700 (PDT) +Received: by mail-we0-f180.google.com with SMTP id u56so2583109wes.25 + for ; Mon, 22 Sep 2014 02:54:52 -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=P9e7ZaLq41xEXo51NDDCfSXP57SgGz+bE5dNFBHRAq8=; + b=DnLCDO8qm+EJXxSvhnNjeXYsTBtD6vBNysesmrGT87skAaccN0yDVaBwA/meGCgdxl + NOCGSNFDHaR7jLPfk3m6KEpy5OEvZPC9mPLKgNVCaQYso8/YrKBmxoabHoBSv9P50OIn + 5WrrPwD4nR1WXCQu2J8OlVngdLaogusWI2rVoL3acC0JD3OAee31SsWfnmC4C2gzkofV + 7Pm+7QZDAijlYEo5QNIoPmD02c9x3zck4IrtbQ9jxk6DawOFb0qvosRzNu63goStgR/V + aV0cuBer9+UaqqM/vRvYJOKKzlLU2QGsdUeb69eHb2l17GTJqCUwCfzenaERNefBitIZ + mlrw== +X-Gm-Message-State: + ALoCoQknu/SWX8DGTrK7CWRJAp27zB8/8Wkk/jYQe01XEXPpWyXJ4X1SRHtdbJVF6LsE95FcUur7 +X-Received: by 10.194.119.193 with SMTP id kw1mr2859680wjb.82.1411379692925; + Mon, 22 Sep 2014 02:54:52 -0700 (PDT) +Received: from localhost ([2001:4b98:dc0:43:216:3eff:fe1b:25f3]) + by mx.google.com with ESMTPSA id hm5sm11747345wjb.2.2014.09.22.02.54.52 + for + (version=TLSv1.1 cipher=RC4-SHA bits=128/128); + Mon, 22 Sep 2014 02:54:52 -0700 (PDT) +From: Jani Nikula +To: notmuch@notmuchmail.org +Subject: [PATCH 04/11] cli/insert: rename file copy function +Date: Mon, 22 Sep 2014 11:54:55 +0200 +Message-Id: + <250d83c50e2fbca0d6cc49f96927c200aa7f1720.1411379395.git.jani@nikula.org> +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:55:07 -0000 + +The copying has nothing to do with stdin, so call it copy_fd +instead. While at it, improve documentation and reverse the +parameters, as destination is traditionally the first parameter. +--- + notmuch-insert.c | 11 ++++++----- + 1 files changed, 6 insertions(+), 5 deletions(-) + +diff --git a/notmuch-insert.c b/notmuch-insert.c +index ccb091a..5d47806 100644 +--- a/notmuch-insert.c ++++ b/notmuch-insert.c +@@ -251,11 +251,12 @@ maildir_open_tmp_file (void *ctx, const char *dir, + return fd; + } + +-/* Copy the contents of standard input (fdin) into fdout. +- * Returns TRUE if a non-empty file was written successfully. +- * Otherwise, return FALSE. */ ++/* ++ * Copy fdin to fdout, return TRUE on success, and FALSE on errors and ++ * empty input. ++ */ + static notmuch_bool_t +-copy_stdin (int fdin, int fdout) ++copy_fd (int fdout, int fdin) + { + notmuch_bool_t empty = TRUE; + +@@ -308,7 +309,7 @@ write_message (void *ctx, int fdin, const char *dir, char **newpath) + + cleanup_path = tmppath; + +- if (! copy_stdin (fdin, fdout)) ++ if (! copy_fd (fdout, fdin)) + goto FAIL; + + if (fsync (fdout) != 0) { +-- +1.7.2.5 + -- 2.26.2