From: larsxschneider@gmail.com
To: git@vger.kernel.org
Cc: peff@peff.net, gitster@pobox.com, sbeller@google.com,
Johannes.Schindelin@gmx.de, jnareb@gmail.com, mlbright@gmail.com,
tboegi@web.de, jacob.keller@gmail.com,
Lars Schneider <larsxschneider@gmail.com>
Subject: [PATCH v7 09/10] convert: make apply_filter() adhere to standard Git error handling
Date: Thu, 8 Sep 2016 20:21:31 +0200 [thread overview]
Message-ID: <20160908182132.50788-10-larsxschneider@gmail.com> (raw)
In-Reply-To: <20160908182132.50788-1-larsxschneider@gmail.com>
From: Lars Schneider <larsxschneider@gmail.com>
apply_filter() returns a boolean that tells the caller if it
"did convert or did not convert". The variable `ret` was used throughout
the function to track errors whereas `1` denoted success and `0`
failure. This is unusual for the Git source where `0` denotes success.
Rename the variable and flip its value to make the function easier
readable for Git developers.
Signed-off-by: Lars Schneider <larsxschneider@gmail.com>
---
convert.c | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/convert.c b/convert.c
index 986c239..a068df7 100644
--- a/convert.c
+++ b/convert.c
@@ -451,7 +451,7 @@ static int apply_filter(const char *path, const char *src, size_t len, int fd,
*
* (child --> cmd) --> us
*/
- int ret = 1;
+ int err = 0;
struct strbuf nbuf = STRBUF_INIT;
struct async async;
struct filter_params params;
@@ -478,22 +478,22 @@ static int apply_filter(const char *path, const char *src, size_t len, int fd,
if (strbuf_read(&nbuf, async.out, len) < 0) {
error("read from external filter '%s' failed", cmd);
- ret = 0;
+ err = -1;
}
if (close(async.out)) {
error("read from external filter '%s' failed", cmd);
- ret = 0;
+ err = -1;
}
if (finish_async(&async)) {
error("external filter '%s' failed", cmd);
- ret = 0;
+ err = -1;
}
- if (ret) {
+ if (!err) {
strbuf_swap(dst, &nbuf);
}
strbuf_release(&nbuf);
- return ret;
+ return !err;
}
static struct convert_driver {
--
2.10.0
next prev parent reply other threads:[~2016-09-08 18:22 UTC|newest]
Thread overview: 45+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-09-08 18:21 [PATCH v7 00/10] Git filter protocol larsxschneider
2016-09-08 18:21 ` [PATCH v7 01/10] pkt-line: rename packet_write() to packet_write_fmt() larsxschneider
2016-09-08 18:21 ` [PATCH v7 02/10] pkt-line: extract set_packet_header() larsxschneider
2016-09-08 18:21 ` [PATCH v7 03/10] pkt-line: add packet_write_fmt_gently() larsxschneider
2016-09-08 21:18 ` Stefan Beller
2016-09-11 11:36 ` Lars Schneider
2016-09-11 16:01 ` Stefan Beller
2016-09-12 9:22 ` Lars Schneider
2016-09-08 18:21 ` [PATCH v7 04/10] pkt-line: add packet_flush_gently() larsxschneider
2016-09-12 23:30 ` Junio C Hamano
2016-09-13 22:12 ` Lars Schneider
2016-09-13 22:44 ` Junio C Hamano
2016-09-15 16:42 ` Lars Schneider
2016-09-15 19:44 ` Jeff King
2016-09-15 20:19 ` Lars Schneider
2016-09-15 20:33 ` Junio C Hamano
2016-09-08 18:21 ` [PATCH v7 05/10] pkt-line: add packet_write_gently() larsxschneider
2016-09-08 21:24 ` Stefan Beller
2016-09-11 11:44 ` Lars Schneider
2016-09-12 23:31 ` Junio C Hamano
2016-09-08 18:21 ` [PATCH v7 06/10] pkt-line: add functions to read/write flush terminated packet streams larsxschneider
2016-09-08 21:49 ` Stefan Beller
2016-09-11 12:33 ` Lars Schneider
2016-09-11 16:03 ` Stefan Beller
2016-09-11 21:42 ` Junio C Hamano
2016-09-08 18:21 ` [PATCH v7 07/10] convert: quote filter names in error messages larsxschneider
2016-09-08 18:21 ` [PATCH v7 08/10] convert: modernize tests larsxschneider
2016-09-08 22:05 ` Stefan Beller
2016-09-11 12:34 ` Lars Schneider
2016-09-08 18:21 ` larsxschneider [this message]
2016-09-08 18:21 ` [PATCH v7 10/10] convert: add filter.<driver>.process option larsxschneider
2016-09-10 6:29 ` Torsten Bögershausen
2016-09-12 9:49 ` Lars Schneider
2016-09-13 14:44 ` Torsten Bögershausen
2016-09-13 16:42 ` Junio C Hamano
2016-09-15 17:23 ` Lars Schneider
2016-09-15 20:04 ` Junio C Hamano
2016-09-29 6:33 ` Torsten Bögershausen
2016-09-29 9:37 ` Jakub Narębski
2016-09-10 16:40 ` Torsten Bögershausen
2016-09-13 22:04 ` Lars Schneider
2016-09-13 15:22 ` Junio C Hamano
2016-09-15 20:16 ` Lars Schneider
2016-09-15 20:24 ` Junio C Hamano
2016-09-13 16:00 ` [PATCH v7 00/10] Git filter protocol Junio C Hamano
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20160908182132.50788-10-larsxschneider@gmail.com \
--to=larsxschneider@gmail.com \
--cc=Johannes.Schindelin@gmx.de \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=jacob.keller@gmail.com \
--cc=jnareb@gmail.com \
--cc=mlbright@gmail.com \
--cc=peff@peff.net \
--cc=sbeller@google.com \
--cc=tboegi@web.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).