Thread (1 message) 1 message, 1 author, 2021-04-15

Re: [PATCH] pkt-line: do not report packet write errors twice

From: Junio C Hamano <hidden>
Date: 2021-04-15 20:56:17

Matheus Tavares [off-list ref] writes:
On Thu, Apr 15, 2021 at 5:32 PM Junio C Hamano [off-list ref] wrote:
quoted
Matheus Tavares Bernardino [off-list ref] writes:
quoted
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.
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help