summaryrefslogtreecommitdiff
path: root/imap-send.c
diff options
context:
space:
mode:
authorÆvar Arnfjörð Bjarmason <avarab@gmail.com>2021-07-07 09:05:24 (GMT)
committerJunio C Hamano <gitster@pobox.com>2021-07-07 21:29:12 (GMT)
commit351bca2d1f814e69740ac0b023bdfb7978b5c215 (patch)
tree9165ada9878d5e111a428c5437ac0512c3b3eedb /imap-send.c
parent670b81a890388c60b7032a4f5b879f2ece8c4558 (diff)
downloadgit-351bca2d1f814e69740ac0b023bdfb7978b5c215.zip
git-351bca2d1f814e69740ac0b023bdfb7978b5c215.tar.gz
git-351bca2d1f814e69740ac0b023bdfb7978b5c215.tar.bz2
imap-send.c: use less verbose strbuf_fread() idiom
When looking for things that hardcoded a non-zero "hint" parameter to strbuf_fread() I discovered that since f2561fda364 (Add git-imap-send, derived from isync 1.0.1., 2006-03-10) we've been passing a hardcoded 4096 in imap-send.c to read stdin. Since we're not doing anything unusual here let's use a less verbose pattern used in a lot of other places (the hint of "0" will default to 8192). We don't need to take a FILE * here either, so we can use "0" instead of "stdin". While we're at it improve the error message if we can't read the input to use error_errno(). Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'imap-send.c')
-rw-r--r--imap-send.c16
1 files changed, 2 insertions, 14 deletions
diff --git a/imap-send.c b/imap-send.c
index bb085d6..9d06ef7 100644
--- a/imap-send.c
+++ b/imap-send.c
@@ -1266,18 +1266,6 @@ static void wrap_in_html(struct strbuf *msg)
*msg = buf;
}
-#define CHUNKSIZE 0x1000
-
-static int read_message(FILE *f, struct strbuf *all_msgs)
-{
- do {
- if (strbuf_fread(all_msgs, CHUNKSIZE, f) <= 0)
- break;
- } while (!feof(f));
-
- return ferror(f) ? -1 : 0;
-}
-
static int count_messages(struct strbuf *all_msgs)
{
int count = 0;
@@ -1582,8 +1570,8 @@ int cmd_main(int argc, const char **argv)
}
/* read the messages */
- if (read_message(stdin, &all_msgs)) {
- fprintf(stderr, "error reading input\n");
+ if (strbuf_read(&all_msgs, 0, 0) < 0) {
+ error_errno(_("could not read from stdin"));
return 1;
}