From: Johannes Sixt <j6t@kdbg.org>
To: Faiz Kothari <faiz.off93@gmail.com>,
git@vger.kernel.org, sunshine@sunshineco.com
Subject: Re: [PATCH] implemented strbuf_write_or_die()
Date: Sat, 01 Mar 2014 22:34:30 +0100 [thread overview]
Message-ID: <53125266.8040007@kdbg.org> (raw)
In-Reply-To: <1393672871-28281-1-git-send-email-faiz.off93@gmail.com>
Am 01.03.2014 12:21, schrieb Faiz Kothari:
> Signed-off-by: Faiz Kothari <faiz.off93@gmail.com>
> ---
> Implemented write_or_die.c:strbuf_write_or_die() and used in relevant places
> to substitute write_or_die(). I spotted other places where strbuf can be used
> in place of buf[MAX_PATH] but that would require a change in prototype of a
> lot of functions and functions calling them and so on....
> I'll look for more places where strbuf can be used safely.
You haven't given a justifiction of the change (why is this change good?)
> diff --git a/write_or_die.c b/write_or_die.c
> index b50f99a..5fb309b 100644
> --- a/write_or_die.c
> +++ b/write_or_die.c
> @@ -1,4 +1,5 @@
> #include "cache.h"
> +#include "strbuf.h"
I think you have the layering backwards here: strbuf_write_or_die should
be part of the (higher-level) strbuf API, and not an extension of the
low-level write_or_die function.
>
> static void check_pipe(int err)
> {
> @@ -64,6 +65,14 @@ void write_or_die(int fd, const void *buf, size_t count)
> }
> }
>
> +void strbuf_write_or_die(int fd, const struct strbuf *sbuf)
And when you make the function a strbuf API, the prototype should be
void strbuf_write_or_die(const struct strbuf *sbuf, int fd)
as in "hey, strbuf object, write your content to this file descriptor!"
> +{
> + if(write_in_full(fd, sbuf->buf, sbuf->len) < 0){
> + check_pipe(errno);
> + die_errno("write error");
> + }
> +}
> +
> int write_or_whine_pipe(int fd, const void *buf, size_t count, const char *msg)
> {
> if (write_in_full(fd, buf, count) < 0) {
>
-- Hannes
next prev parent reply other threads:[~2014-03-01 21:34 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-03-01 11:21 [PATCH] implemented strbuf_write_or_die() Faiz Kothari
2014-03-01 12:51 ` He Sun
2014-03-01 13:29 ` Faiz Kothari
2014-03-01 22:33 ` Michael Haggerty
2014-03-02 0:18 ` [PATCH v2] " Faiz Kothari
2014-03-02 2:47 ` Eric Sunshine
2014-03-02 2:55 ` Eric Sunshine
2014-03-02 7:34 ` [PATCH v3 1/2] Introduce strbuf_write_or_die() Faiz Kothari
2014-03-02 7:34 ` [PATCH v3 2/2] use strbuf_write_or_die() Faiz Kothari
2014-03-02 22:04 ` Eric Sunshine
2014-03-02 20:05 ` [PATCH v3 1/2] Introduce strbuf_write_or_die() Eric Sunshine
2014-03-02 3:08 ` [PATCH] implemented strbuf_write_or_die() Eric Sunshine
2014-03-03 18:31 ` Junio C Hamano
[not found] ` <CAFbjVckhU7NHzLjqPo5WkoBwVLrOLg=CS6mHSKkQstUxB31_eA@mail.gmail.com>
2014-03-03 18:48 ` Fwd: " Faiz Kothari
2014-03-03 19:46 ` Eric Sunshine
2014-03-03 19:51 ` David Kastrup
2014-03-03 20:35 ` Junio C Hamano
2014-03-03 21:29 ` Eric Sunshine
2014-03-04 9:18 ` Michael Haggerty
2014-03-04 17:01 ` Faiz Kothari
2014-03-04 18:45 ` Junio C Hamano
2014-03-01 21:34 ` Johannes Sixt [this message]
2014-03-03 18:27 ` 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=53125266.8040007@kdbg.org \
--to=j6t@kdbg.org \
--cc=faiz.off93@gmail.com \
--cc=git@vger.kernel.org \
--cc=sunshine@sunshineco.com \
/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).