git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH v2] pkt-line: use string versions of functions

From
Đoàn Trần Công Danh <congdanhqx@gmail.com>
Date
Jun 15, 2020, 12:32 UTC
Message-ID
<20200615123257.GA20389@danh.dev>
In-Reply-To
<da9ba5fb2d0fb9481f81ce525cbabaedd722858d.1592125442.git.liu.denton@gmail.com>
On 2020-06-14 05:07:54-0400, Denton Liu <liu.denton@gmail.com> wrote:
> Hi Đoàn,
Sorry for this late reply, I have another stuff to work on.
> Perhaps something like this?
This looks better, but ...
Show 20 quoted lines
> 
>  pkt-line.c | 48 ++++++++++++++++++++++++++++++------------------
>  1 file changed, 30 insertions(+), 18 deletions(-)
> 
> diff --git a/pkt-line.c b/pkt-line.c
> index 8f9bc68ee2..022376f00f 100644
> --- a/pkt-line.c
> +++ b/pkt-line.c
> @@ -81,49 +81,61 @@ static void packet_trace(const char *buf, unsigned int len, int write)
>  	strbuf_release(&out);
>  }
>  
> +static inline void packet_trace_str(const char *buf, int write)
> +{
> +	packet_trace(buf, strlen(buf), write);
> +}
> +
> +#define control_packet_write(fd, s, errstr) \
> +	do { \
> +		(void)s"is a string constant"; \
If we are going to not wrap s inside () here,
> +		packet_trace_str((s), 1); \

I see no point in wrapping it here. And wrapping around "string" is not standard C, some (or most) compilers support it as an extension.

See USE_PARENS_AROUND_GETTEXT_N
Can we just put it straight?
	packet_trace(s, strlen(s), 1);
> +		if (write_str_in_full((fd), (s)) < 0) \
> +			die_errno((errstr)); \
> +	} while (0)
> +
-- 
Danh
Previous: Denton LiuNext: Denton Liu
Message 12 of 22 in “pkt-line: extract out PACKET_HEADER_SIZE”
  1. pkt-line: extract out PACKET_HEADER_SIZEDenton Liu, Jun 13, 2020
  2. Đoàn Trần Công DanhJun 13, 2020
  3. Denton LiuJun 13, 2020
  4. Junio C HamanoJun 13, 2020
  5. Junio C HamanoJun 14, 2020
  6. 0/3 pkt-line: war on magical `4` literalDenton Liu, Jun 14, 2020
  7. 2/3 pkt-line: use string versions of functionsDenton Liu, Jun 14, 2020
  8. Đoàn Trần Công DanhJun 14, 2020
  9. pkt-line: use string versions of functionsDenton Liu, Jun 14, 2020
  10. Junio C HamanoJun 14, 2020
  11. Denton LiuJun 14, 2020
  12. Đoàn Trần Công DanhJun 15, 2020
  13. 1/3 remote-curl: use strlen() instead of magic numbersDenton Liu, Jun 14, 2020
  14. 3/3 pkt-line: extract out PACKET_HEADER_SIZEDenton Liu, Jun 14, 2020
  15. Junio C HamanoJun 14, 2020
  16. 0/3 pkt-line: war on magical `4` literalDenton Liu, Jun 23, 2020
  17. 1/3 remote-curl: use strlen() instead of magic numbersDenton Liu, Jun 23, 2020
  18. Jeff KingJun 23, 2020
  19. Junio C HamanoJun 23, 2020
  20. 2/3 pkt-line: use string versions of functionsDenton Liu, Jun 23, 2020
  21. Jeff KingJun 23, 2020
  22. 3/3 pkt-line: extract out PACKET_HEADER_SIZEDenton Liu, Jun 23, 2020

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.