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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 2020-06-14 05:07:54-0400, Denton Liu <liu.denton@xxxxxxxxx> wrote:
> Hi Đoàn,

Sorry for this late reply, I have another stuff to work on.

> Perhaps something like this?

This looks better, but ...

> 
>  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



[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux