From: Stefan Beller <sbeller@google.com>
To: Lars Schneider <larsxschneider@gmail.com>
Cc: "git@vger.kernel.org" <git@vger.kernel.org>,
"Jeff King" <peff@peff.net>, "Junio C Hamano" <gitster@pobox.com>,
"Johannes Schindelin" <Johannes.Schindelin@gmx.de>,
"Jakub Narębski" <jnareb@gmail.com>,
"Martin-Louis Bright" <mlbright@gmail.com>,
"Torsten Bögershausen" <tboegi@web.de>,
"Jacob Keller" <jacob.keller@gmail.com>
Subject: Re: [PATCH v7 05/10] pkt-line: add packet_write_gently()
Date: Thu, 8 Sep 2016 14:24:02 -0700 [thread overview]
Message-ID: <CAGZ79kZdroDdD5SHP+-9svSTYbJfn2vsFXAwC4aen3hMVEOOPA@mail.gmail.com> (raw)
In-Reply-To: <20160908182132.50788-6-larsxschneider@gmail.com>
On Thu, Sep 8, 2016 at 11:21 AM, <larsxschneider@gmail.com> wrote:
> From: Lars Schneider <larsxschneider@gmail.com>
>
> packet_write_fmt_gently() uses format_packet() which lets the caller
> only send string data via "%s". That means it cannot be used for
> arbitrary data that may contain NULs.
Makes sense.
>
> Add packet_write_gently() which writes arbitrary data and returns `0`
> for success and `-1` for an error.
I think documenting the return code is better done in either the header file
or in a commend preceding the implementation instead of the commit message?
Maybe just a generic comment for *_gently is good enough, maybe even no
comment. So the commit is fine, too. I dunno.
> This function is used by other
> pkt-line functions in a subsequent patch.
That's what I figured. Do we also need to mention that in the preceding patch
for packet_flush_gently ?
>
> Signed-off-by: Lars Schneider <larsxschneider@gmail.com>
> ---
> pkt-line.c | 19 +++++++++++++++++++
> 1 file changed, 19 insertions(+)
>
> diff --git a/pkt-line.c b/pkt-line.c
> index 37345ca..1d3d725 100644
> --- a/pkt-line.c
> +++ b/pkt-line.c
> @@ -181,6 +181,25 @@ int packet_write_fmt_gently(int fd, const char *fmt, ...)
> return status;
> }
>
> +int packet_write_gently(const int fd_out, const char *buf, size_t size)
> +{
> + static char packet_write_buffer[LARGE_PACKET_MAX];
> +
> + if (size > sizeof(packet_write_buffer) - 4) {
> + error("packet write failed");
> + return -1;
> + }
> + packet_trace(buf, size, 1);
> + size += 4;
> + set_packet_header(packet_write_buffer, size);
> + memcpy(packet_write_buffer + 4, buf, size - 4);
> + if (write_in_full(fd_out, packet_write_buffer, size) == size)
> + return 0;
> +
> + error("packet write failed");
> + return -1;
> +}
> +
> void packet_buf_write(struct strbuf *buf, const char *fmt, ...)
> {
> va_list args;
> --
> 2.10.0
>
next prev parent reply other threads:[~2016-09-08 21:24 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 [this message]
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 ` [PATCH v7 09/10] convert: make apply_filter() adhere to standard Git error handling larsxschneider
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
List information: http://vger.kernel.org/majordomo-info.html
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=CAGZ79kZdroDdD5SHP+-9svSTYbJfn2vsFXAwC4aen3hMVEOOPA@mail.gmail.com \
--to=sbeller@google.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=larsxschneider@gmail.com \
--cc=mlbright@gmail.com \
--cc=peff@peff.net \
--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.
Code repositories for project(s) associated with this public inbox
https://80x24.org/mirrors/git.git
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 read-only IMAP folder(s) and NNTP newsgroup(s).