git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: Matheus Tavares <matheus.bernardino@usp.br>
Cc: git@jeffhostetler.com, git@vger.kernel.org
Subject: Re: [PATCH] pkt-line: do not report packet write errors twice
Date: Thu, 15 Apr 2021 13:56:09 -0700	[thread overview]
Message-ID: <xmqqczuvp8ra.fsf@gitster.g> (raw)
In-Reply-To: <20210415204809.1818959-1-matheus.bernardino@usp.br> (Matheus Tavares's message of "Thu, 15 Apr 2021 17:48:09 -0300")

Matheus Tavares <matheus.bernardino@usp.br> writes:

> On Thu, Apr 15, 2021 at 5:32 PM Junio C Hamano <gitster@pobox.com> wrote:
>>
>> Matheus Tavares Bernardino <matheus.bernardino@usp.br> writes:
>>
>> > Nice! :) Maybe we could also avoid the static strings without
>> > repeating the literals by making `do_packet_write()` receive a `struct
>> > strbuf *err` and save the error message in it? Then the two callers
>> > can decide whether to pass it to error() or die() accordingly.
>>
>> Sorry, but I do not understand what benefit we are trying to gain by
>> introducing an extra strbuf (which I assume is used to strbuf_add()
>> the error message into).  Wouldn't the caller need two messages and
>> flip between <error,error_errno> vs <die,die_errno> pair?
>
> Hmm, I'm not sure I understand what you mean by the two messages, but
> what I was thinking of is something like this (on top of my original
> patch):

Ah, OK, you meant that you'd make do_packet_write() handle
die/error_errno itself by manually calling strerror(errno).

One small downside with the approach is that do_packet_write() needs
to hardcode how die/error_errno() mixes the strerror() with the
caller supplied error message, but I do not care too strongly either
way.  My original motivation of suggesting the rewrite was to avoid
overlong lines in the main flow of the code by replacing the long
messages with variable names that are much shorter, so as long as
that is done, I am fine either way.

Thanks.

  reply	other threads:[~2021-04-15 20:56 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-04-15 19:10 [PATCH] pkt-line: do not report packet write errors twice Matheus Tavares
2021-04-15 20:06 ` Junio C Hamano
2021-04-15 20:24   ` Matheus Tavares Bernardino
2021-04-15 20:32     ` Junio C Hamano
2021-04-15 20:48       ` Matheus Tavares
2021-04-15 20:56         ` Junio C Hamano [this message]
2021-04-15 21:57 ` [PATCH v2] " Matheus Tavares
2021-04-15 21:59   ` 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=xmqqczuvp8ra.fsf@gitster.g \
    --to=gitster@pobox.com \
    --cc=git@jeffhostetler.com \
    --cc=git@vger.kernel.org \
    --cc=matheus.bernardino@usp.br \
    /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).